Skip to content

Commit a4d8ed0

Browse files
committed
oct1 commit
1 parent 70a3bc2 commit a4d8ed0

File tree

13 files changed

+2901
-572
lines changed

13 files changed

+2901
-572
lines changed

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
{
22
"cSpell.words": [
3+
"alphavantage",
4+
"AROON",
5+
"COMOD",
6+
"DEMA",
37
"FXAIX",
8+
"MACDEXT",
9+
"ndxt",
10+
"STOCH",
11+
"STOCHF",
12+
"STOCHRSI",
13+
"TEMA",
14+
"TRIMA",
415
"VFAIX",
16+
"WILLR",
517
"yfinance"
618
]
719
}

Pipfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pandas = "*"
99
requests = "*"
1010
lxml = "*"
1111
yfinance = {extras = ["nospam", "repair"], version = "*"}
12-
secedgar = {git = "https://github.com/sec-edgar/sec-edgar.git"}
1312
pandas-datareader = "*"
1413
fastapi = "*"
1514
uvicorn = {extras = ["standard"], version = "*"}

Pipfile.lock

Lines changed: 1993 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/api.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
from fastapi import FastAPI
44
from datetime import datetime
55
import pandas as pd
6+
import logging
7+
from glob import glob
8+
9+
logger = logging.getLogger(__name__)
610

711
# import pandas_datareader as pdr
812
import json
913
import os
1014

1115
# import yfinance as yf
1216

17+
TODAY = datetime.today().strftime("%Y-%m-%d")
1318
app = FastAPI()
1419

1520
DATA_DIR = os.getenv("DATA_DIR", "/data")
@@ -20,15 +25,23 @@ async def root():
2025
return {"message": "OK"}
2126

2227

23-
@app.get("/ticker/{ticker}")
24-
async def get_ticker(ticker):
25-
print(f"Getting stock data for {ticker}")
26-
27-
# IF DATA FOUND - RETURN THIS
28+
@app.get("/symbol/{symbol}")
29+
async def get_symbol(symbol):
30+
print(f"Getting symbol data for {symbol}")
31+
# symbol = symbol.strip().replace("/", "").upper()
2832
try:
29-
with open(f"{DATA_DIR}/{ticker}.json", "w") as file:
30-
file.write(json.dumps(data))
33+
fname = f"{DATA_DIR}/MIDAS/{TODAY}-{symbol}.json"
34+
print(f"Looking for {fname}")
35+
with open(fname, "r") as file:
36+
data = json.load(file)
3137

3238
return data
33-
except:
34-
logger.info("No ticker found")
39+
except Exception as err:
40+
logger.info("No symbol found")
41+
return {"message": f"No symbol found {err}"}
42+
43+
44+
@app.get("/files")
45+
async def get_files():
46+
files = glob(f"{DATA_DIR}/MIDAS/*")
47+
return json.dumps(files)

cwe_dl.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import requests
2+
import pandas as pd
3+
from io import StringIO
4+
import re
5+
from bs4 import BeautifulSoup
6+
7+
8+
BASE = "https://cwe.mitre.org"
9+
URL = f"{BASE}/data/downloads.html"
10+
11+
12+
def main():
13+
headers = {
14+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
15+
"AppleWebKit/537.36 (KHTML, like Gecko) "
16+
"Chrome/91.0.4472.101 Safari/537.3"
17+
}
18+
# fname = f"{DATA_DIR}/500.csv"
19+
20+
# if os.path.exists(fname):
21+
# logger.info("File exists %s", fname)
22+
# return
23+
24+
# Fetch the page content
25+
response = requests.get(URL, headers=headers, timeout=30)
26+
27+
# Use pandas to read the HTML tables
28+
tables = pd.read_html(response.text)
29+
table1 = tables[0]
30+
table2 = tables[1]
31+
table3 = tables[2]
32+
table4 = tables[3]
33+
print(table1, table2, table3, table4)
34+
# soup = BeautifulSoup(response.text)
35+
36+
# for link in soup.findAll('a', attrs={'href': re.compile('.csv.zip')}):
37+
# fname = link.get("href").split('/')[-1]
38+
# link_abs = f'{BASE}{link.get("href")}'
39+
# print(link_abs)
40+
# with open(fname, 'wb') as f:
41+
# f.write(requests.get(link_abs).content)
42+
43+
44+
if __name__ == "__main__":
45+
main()

docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
context: .
77
dockerfile: Dockerfile
88
volumes:
9-
- /Volumes/DATA/data/finance:/data
9+
- /Volumes/data/finance:/data
1010
environment:
1111
- WORKERS=1
1212
entrypoint: ["python", "worker_stocks.py"]
@@ -18,14 +18,14 @@ services:
1818
context: ./api
1919
dockerfile: Dockerfile
2020
volumes:
21-
- /Volumes/DATA/data/finance:/data
21+
- /Volumes/data/finance:/data
2222
entrypoint: [
2323
"uvicorn",
2424
"--host",
2525
"0.0.0.0",
2626
"--port",
2727
"8000",
28-
"api.api:app", #{dir}/{file}:app
28+
"api.api:app", # {dir} / {file}:app
2929
"--reload",
3030
]
3131
networks:
@@ -52,7 +52,7 @@ services:
5252
context: .
5353
dockerfile: Dockerfile
5454
volumes:
55-
- /Volumes/DATA/data/finance:/data
55+
- /Volumes/data/finance:/data
5656
environment:
5757
- WORKERS=10
5858
entrypoint: ["python", "worker_sec.py"]
@@ -65,7 +65,7 @@ services:
6565
context: .
6666
dockerfile: Dockerfile
6767
volumes:
68-
- /Users/jon/Data/FINANCE:/data
68+
- /Volumes/data/finance:/data
6969
environment:
7070
- WORKERS=2
7171
# ports:

0 commit comments

Comments
 (0)