-
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.
* resolved * add mergers to planned data collection in readme * add get_intraday_path * comments * add institutional sentiment to readme data checklista * to compile * limit polygon save timeframe to prevent retroactive weirdness * add multiprocessing to speed up data updates * delete local data files after each file update to preserve disk space * constants tests done * conflict * conflict * polygon test_intraday * iex test_intraday * test_save_intraday + repo rename * readme * git cleanup local branches * package name change * remove package upload in dev pipeline * fix bugs and add volume weighted avg price to ohlc * start generator * polygon intraday done? * more progrress * fix polygon, still need to do iex * finish iex changes * add intraday step to dev pipeline and fix tests * fixed? * last fix? * get date from first row of intra to save properly * more inclusive time range and lower threshold
- Loading branch information
Showing
16 changed files
with
351 additions
and
130 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
python-dotenv == 0.15.0 | ||
pandas == 1.1.5 | ||
robin-stocks == 1.5.3 | ||
boto3 == 1.16.35 | ||
pandas == 1.2.0 | ||
robin-stocks == 1.6.3 | ||
boto3 == 1.16.51 | ||
polygon-api-client == 0.1.9 | ||
pytz == 2020.4 | ||
pytz == 2020.5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
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 PathFinder # noqa autopep8 | ||
import Constants as C # noqa autopep8 | ||
|
||
iex = IEXCloud() | ||
poly_stocks = Polygon() | ||
poly_crypto = Polygon(os.environ['POLYGON']) | ||
stock_symbols = iex.get_symbols() | ||
crypto_symbols = C.POLY_CRYPTO_SYMBOLS | ||
yesterday = iex.traveller.dates_in_range('1d')[0] | ||
# Double redundancy | ||
|
||
# 1st pass | ||
|
||
|
||
def update_iex_intraday(): | ||
for symbol in stock_symbols: | ||
try: | ||
iex.save_intraday(symbol=symbol, timeframe='1d', | ||
retries=1 if C.TEST else C.DEFAULT_RETRIES) | ||
except Exception as e: | ||
print(f'IEX Cloud intraday update failed for {symbol}.') | ||
print(e) | ||
finally: | ||
filename = PathFinder().get_intraday_path( | ||
symbol=symbol, | ||
date=yesterday, | ||
provider=iex.provider) | ||
if C.CI and os.path.exists(filename): | ||
os.remove(filename) | ||
# 2nd pass | ||
|
||
|
||
def update_poly_stocks_intraday(): | ||
for symbol in stock_symbols: | ||
try: | ||
poly_stocks.save_intraday( | ||
symbol=symbol, timeframe='1d', | ||
retries=1 if C.TEST else C.DEFAULT_RETRIES) | ||
except Exception as e: | ||
print(f'Polygon.io intraday update failed for {symbol}.') | ||
print(e) | ||
finally: | ||
filename = PathFinder().get_intraday_path( | ||
symbol=symbol, | ||
date=yesterday, | ||
provider=poly_stocks.provider) | ||
if C.CI and os.path.exists(filename): | ||
os.remove(filename) | ||
# Crypto pass | ||
|
||
|
||
def update_poly_crypto_intraday(): | ||
calls_per_min = 5 | ||
for idx, symbol in enumerate(crypto_symbols): | ||
try: | ||
poly_crypto.save_intraday( | ||
symbol=symbol, timeframe='1d', | ||
retries=1 if C.TEST else C.DEFAULT_RETRIES) | ||
except Exception as e: | ||
print(f'Polygon.io intraday update failed for {symbol}.') | ||
print(e) | ||
finally: | ||
filename = PathFinder().get_intraday_path( | ||
symbol=symbol, | ||
date=yesterday, | ||
provider=poly_crypto.provider) | ||
if C.CI and os.path.exists(filename): | ||
os.remove(filename) | ||
|
||
if idx != len(crypto_symbols) - 1: | ||
sleep(60 // calls_per_min + 5) | ||
|
||
|
||
p1 = Process(target=update_iex_intraday) | ||
p2 = Process(target=update_poly_stocks_intraday) | ||
p3 = Process(target=update_poly_crypto_intraday) | ||
p1.start() | ||
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
Oops, something went wrong.