From 336f062794cbce9a1791d4c87f43b8d31139e19c Mon Sep 17 00:00:00 2001 From: Victor Grau Serrat Date: Thu, 28 Sep 2017 14:42:47 -0600 Subject: [PATCH] poloniex autogeneration of symbols.json with cached start_date --- catalyst/exchange/poloniex/poloniex.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/catalyst/exchange/poloniex/poloniex.py b/catalyst/exchange/poloniex/poloniex.py index 4fc541de..d280ef59 100644 --- a/catalyst/exchange/poloniex/poloniex.py +++ b/catalyst/exchange/poloniex/poloniex.py @@ -28,7 +28,8 @@ from catalyst.exchange.exchange_execution import ExchangeLimitOrder, \ ExchangeStopLimitOrder, ExchangeStopOrder from catalyst.finance.order import Order, ORDER_STATUS from catalyst.protocol import Account -from catalyst.exchange.exchange_utils import get_exchange_symbols_filename +from catalyst.exchange.exchange_utils import get_exchange_symbols_filename, \ + download_exchange_symbols from catalyst.finance.transaction import Transaction @@ -466,13 +467,25 @@ class Poloniex(Exchange): def generate_symbols_json(self, filename=None): symbol_map = {} + + fn, r = download_exchange_symbols(self.name) + with open(fn) as data_file: + cached_symbols = json.load(data_file) + response = self.api.returnticker() + for exchange_symbol in response: base, market = self.sanitize_curency_symbol(exchange_symbol).split('_') symbol = '{market}_{base}'.format( market=market, base=base ) + + try: + start_date = cached_symbols[exchange_symbol]['start_date'] + except KeyError as e: + start_date = time.strftime('%Y-%m-%d') + symbol_map[exchange_symbol] = dict( symbol = symbol, - start_date = '2010-01-01' + start_date = start_date ) if(filename is None):