Upload SP500_Date_Offset.py
Browse files- SP500_Date_Offset.py +14 -6
SP500_Date_Offset.py
CHANGED
@@ -10,21 +10,29 @@ Created on Wed May 1 13:17:02 2024
|
|
10 |
|
11 |
|
12 |
# ================================ LIBRARIES ================================ #
|
13 |
-
import numpy as np
|
14 |
import pandas as pd
|
15 |
-
import yfinance as yf
|
16 |
import datasets
|
17 |
from typing import List
|
18 |
-
import csv
|
19 |
-
import json
|
20 |
import logging
|
21 |
|
22 |
import warnings
|
23 |
-
from fredapi import Fred
|
24 |
from time import sleep
|
25 |
from urllib.request import Request, urlopen
|
26 |
-
from bs4 import BeautifulSoup as soup
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
|
30 |
|
|
|
10 |
|
11 |
|
12 |
# ================================ LIBRARIES ================================ #
|
|
|
13 |
import pandas as pd
|
|
|
14 |
import datasets
|
15 |
from typing import List
|
|
|
|
|
16 |
import logging
|
17 |
|
18 |
import warnings
|
|
|
19 |
from time import sleep
|
20 |
from urllib.request import Request, urlopen
|
|
|
21 |
|
22 |
+
# Special Libraries
|
23 |
+
import importlib
|
24 |
+
import subprocess
|
25 |
+
specialLibraries = ['bs4', 'fredapi', 'yfinance']
|
26 |
+
for lib in specialLibraries:
|
27 |
+
try:
|
28 |
+
importlib.import_module(lib)
|
29 |
+
except ImportError:
|
30 |
+
subprocess.check_call(['pip', 'install', lib])
|
31 |
+
# end try
|
32 |
+
# end for
|
33 |
+
from bs4 import BeautifulSoup as soup
|
34 |
+
import yfinance as yf
|
35 |
+
from fredapi import Fred
|
36 |
|
37 |
|
38 |
|