-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
137 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import os | ||
import sys | ||
from time import sleep | ||
from multiprocessing import Process | ||
sys.path.append('src') | ||
from DataSource import IEXCloud, Polygon # noqa autopep8 | ||
from Constants import CI, PathFinder, POLY_CRYPTO_SYMBOLS, POLY_CRYPTO_DELAY # noqa autopep8 | ||
|
||
|
||
poly_stocks = Polygon() | ||
poly_crypto = Polygon(os.environ['POLYGON']) | ||
stock_symbols = poly_stocks.get_symbols() | ||
stock_symbols = stock_symbols[stock_symbols.index('DIS')+1:] | ||
# [250:] | ||
crypto_symbols = [POLY_CRYPTO_SYMBOLS[0]] | ||
|
||
|
||
def update_poly_stocks_intraday(): | ||
for symbol in stock_symbols: | ||
filenames = [] | ||
try: | ||
filenames = poly_stocks.save_intraday( | ||
symbol=symbol, timeframe='21y') | ||
except Exception as e: | ||
print(f'Polygon.io intraday update failed for {symbol}.') | ||
print(e) | ||
finally: | ||
if CI: | ||
for filename in filenames: | ||
if os.path.exists(filename): | ||
os.remove(filename) | ||
# Crypto pass | ||
|
||
|
||
def update_poly_crypto_intraday(): | ||
|
||
for idx, symbol in enumerate(crypto_symbols): | ||
filenames = [] | ||
try: | ||
filenames = poly_crypto.save_intraday( | ||
symbol=symbol, timeframe='674d', | ||
delay=POLY_CRYPTO_DELAY, retries=2) | ||
except Exception as e: | ||
print(f'Polygon.io intraday update failed for {symbol}.') | ||
print(e) | ||
finally: | ||
if CI: | ||
for filename in filenames: | ||
if os.path.exists(filename): | ||
os.remove(filename) | ||
|
||
if idx != len(crypto_symbols) - 1: | ||
sleep(POLY_CRYPTO_DELAY) | ||
|
||
|
||
# p2 = Process(target=update_poly_stocks_intraday) | ||
p3 = Process(target=update_poly_crypto_intraday) | ||
# p2.start() | ||
p3.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.