-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_scans.py
83 lines (66 loc) · 2.22 KB
/
update_scans.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from eodstockscans.src.gen_site import Site
from eodstockscans.src.run_scans import Scans
from eodstockscans.src.scans import EOD
# from fintwit_stockmarket_scans.src.config import MARKETS,CHART_PARAMS,EOD
from pathlib import Path
import typer
import yaml
import datetime as dt
app = typer.Typer()
# MARKETS = {
# "United States": {
# "exchanges": ["NASDAQ", "NYSE"],
# "scale": {"volume": 1, "price": 1},
# },
# }
with open(Path(__file__).parent / "config.yaml", "r") as f:
config = yaml.full_load(f)
MARKETS = config["MARKETS"]
CHART_PARAMS = config["CHART_PARAMS"]
@app.command()
def run(
market: str = None, run_scans: bool = True, gen_site: bool = True, date: str = None
):
if market is None:
market = MARKETS
else:
if isinstance(market, str):
market = [market.replace("-", " ") for market in market.split(",")]
#if date is None:
# date = str(dt.date.today())
success = []
failed = []
for market_ in market:
try:
exchanges = MARKETS[market_]["exchanges"]
scale = MARKETS[market_]["scale"]
eod_scans = EOD(scale=scale)
scanner = Scans(
exchanges=exchanges, market=market_.lower().replace(" ", "_"), date=date
)
if run_scans:
print(f"Running EOD Scans for market {market_}")
scanner.run_scans(eod_scans=eod_scans)
scanner.gen_charts(chart_params=CHART_PARAMS)
print(f"Done.")
if gen_site:
print(f"Generating sites for market {market_}")
site = Site(
market=market_, date=scanner._date, all_markets=list(MARKETS.keys())
)
site.render(eod_scans=eod_scans)
print("Done.\n")
success.append(market_)
except:
print(f"{market_} failed.")
failed.append(market_)
print("Success:", success)
print("Failed:", failed)
return success, failed
if __name__ == "__main__":
import time
s = time.time()
success, failed = app()
print("Finished in:", time.time() - s, "seconds")
print("Success:", success)
print("Failed:", failed)