def __init__(self): load_dotenv(find_dotenv('config.env')) self.writer = FileWriter() self.reader = FileReader() self.finder = PathFinder() self.traveller = TimeTraveller() self.provider = 'iexcloud'
def update_poly_ohlc(): for symbol in all_symbols: try: poly.save_ohlc(symbol=symbol, timeframe=FEW_DAYS, retries=1) except Exception as e: print(f'Polygon.io OHLC update failed for {symbol}.') print(e) finally: filename = PathFinder().get_ohlc_path( symbol=symbol, provider=poly.provider) if C.CI and os.path.exists(filename): os.remove(filename)
def update_poly_dividends(): for symbol in symbols: filename = PathFinder().get_dividends_path( symbol=symbol, provider=poly.provider) try: poly.save_dividends(symbol=symbol, timeframe='max') except Exception as e: print(f'Polygon.io dividend update failed for {symbol}.') print(e) finally: if CI and os.path.exists(filename): os.remove(filename)
def update_iex_ohlc(): for symbol in stock_symbols: filename = PathFinder().get_ohlc_path(symbol=symbol, provider=iex.provider) try: iex.save_ohlc(symbol=symbol, timeframe=timeframe) except Exception as e: print(f'IEX Cloud OHLC update failed for {symbol}.') print(e) finally: if CI and os.path.exists(filename): os.remove(filename)
def update_iex_dividends(): for symbol in symbols: filename = PathFinder().get_dividends_path( symbol=symbol, provider=iex.provider) try: iex.save_dividends(symbol=symbol, timeframe='5y') except Exception as e: print(f'IEX Cloud dividend update failed for {symbol}.') print(e) finally: if CI and os.path.exists(filename): os.remove(filename)
def __init__(self, usr=None, pwd=None, mfa=None): # Authentication load_dotenv() username = usr or os.environ['RH_USERNAME'] password = pwd or os.environ['RH_PASSWORD'] mfa_code = mfa or pyotp.TOTP(os.environ['RH_2FA']).now() rh.login(username, password, mfa_code=mfa_code) self.api = rh self.writer = FileWriter() self.reader = FileReader() self.finder = PathFinder()
def update_iex_ohlc(): for symbol in stock_symbols: try: iex.save_ohlc(symbol=symbol, timeframe='1d', retries=1 if C.TEST else C.DEFAULT_RETRIES) except Exception as e: print(f'IEX Cloud OHLC update failed for {symbol}.') print(e) finally: filename = PathFinder().get_ohlc_path( symbol=symbol, provider=iex.provider) if C.CI and os.path.exists(filename): os.remove(filename)
def update_poly_splits(): for symbol in symbols: try: poly.save_splits(symbol=symbol, timeframe='3m', retries=1 if C.TEST else C.DEFAULT_RETRIES) except Exception as e: print(f'Polygon.io split update failed for {symbol}.') print(e) finally: filename = PathFinder().get_splits_path(symbol=symbol, provider=poly.provider) if C.CI and os.path.exists(filename): os.remove(filename)
def __init__(self, broker=None): self.writer = FileWriter() self.reader = FileReader() self.finder = PathFinder()
def __init__(self): load_dotenv() self.bucket_name = self.get_bucket_name() self.finder = PathFinder()
import os import sys sys.path.append('src') from DataSource import Glassnode # noqa autopep8 from Constants import PathFinder # noqa autopep8 import Constants as C # noqa autopep8 glass = Glassnode() try: glass.save_s2f(timeframe='max', retries=1 if C.TEST else 2) except Exception as e: print('Glassnode S2F update failed.') print(e) finally: filename = PathFinder().get_s2f_path() if C.CI and os.path.exists(filename): os.remove(filename)
def test_init(self): assert type(PathFinder()).__name__ == 'PathFinder'
import sys sys.path.append('src') from Constants import PathFinder # noqa autopep8 finder = PathFinder() class TestPathFinder(): def test_init(self): assert type(PathFinder()).__name__ == 'PathFinder' def test_get_symbols_path(self): assert finder.get_symbols_path() == 'data/symbols.csv' def test_get_dividends_path(self): assert finder.get_dividends_path( 'aapl') == 'data/dividends/iexcloud/AAPL.csv' assert finder.get_dividends_path( 'AMD') == 'data/dividends/iexcloud/AMD.csv' assert finder.get_dividends_path( 'TSLA', 'polygon') == 'data/dividends/polygon/TSLA.csv' def test_get_splits_path(self): assert finder.get_splits_path( 'aapl') == 'data/splits/iexcloud/AAPL.csv' assert finder.get_splits_path('AMD') == 'data/splits/iexcloud/AMD.csv' assert finder.get_splits_path( 'TSLA', 'polygon') == 'data/splits/polygon/TSLA.csv' def test_get_sentiment_path(self): assert finder.get_sentiment_path(
from Constants import PathFinder # noqa autopep8 import Constants as C # noqa autopep8 twit = StockTwits() symbols = twit.get_symbols() crypto_symbols = ['BTC-X', 'ETH-X', 'LTC-X', 'XMR-X', 'IOT-X'] if C.TEST: symbols = crypto_symbols twit.token = '' else: symbols.extend(crypto_symbols) BATCH = int(os.environ.get('BATCH')) if os.environ.get('BATCH') else 1 # better solution is to dynamically choose 175 most outdated symbols # First batch for symbol in symbols[C.TWIT_RATE*(BATCH-1):C.TWIT_RATE*BATCH]: if symbol in C.SENTIMENT_SYMBOLS_IGNORE: continue try: twit.save_social_sentiment(symbol=symbol, timeframe='1d', retries=1 if C.TEST else 2) except Exception as e: print(f'Stocktwits sentiment update failed for {symbol}.') print(e) finally: filename = PathFinder().get_sentiment_path( symbol=symbol, provider=twit.provider) if C.CI and os.path.exists(filename): os.remove(filename)
def __init__(self): load_dotenv(find_dotenv('config.env')) self.bucket_name = self.get_bucket_name() self.finder = PathFinder()