Documentation and cleanup from meeting with Victor

This commit is contained in:
fredfortier
2017-09-15 18:00:15 -04:00
parent ff0dc5cff9
commit 5a345a3abb
11 changed files with 32 additions and 15 deletions
+3
View File
@@ -90,6 +90,8 @@ class PoloniexBundle(BaseCryptoPricingBundle):
start_date,
end_date,
frequency):
# TODO: replace this with direct exchange call
# The end date and frequency should be used to calculate the number of bars
raw = pd.read_json(
self._format_data_url(
api_key,
@@ -153,6 +155,7 @@ class PoloniexBundle(BaseCryptoPricingBundle):
return self._format_polo_query(query_params)
def _format_polo_query(self, query_params):
# TODO: got against the exchange object
return 'https://poloniex.com/public?{query}'.format(
query=urlencode(query_params),
)
@@ -30,7 +30,7 @@ def initialize(context):
# the exchange information. This allow all other operations using
# the TradingPair to target the correct exchange.
context.trading_pairs[context.buying_exchange] = \
symbol(context.trading_pair_symbol, context.buying_exchange.name)
symbol('neo_eth', context.buying_exchange.name)
context.trading_pairs[context.selling_exchange] = \
symbol(context.trading_pair_symbol, context.selling_exchange.name)
+8 -5
View File
@@ -38,6 +38,8 @@ def initialize(context):
context.retry_update_portfolio = 10
context.retry_order = 5
context.swallow_errors = True
context.errors = []
pass
@@ -49,6 +51,7 @@ def _handle_data(context, data):
bar_count=20,
frequency='15m'
)
rsi = talib.RSI(prices.values, timeperiod=14)[-1]
log.info('got rsi: {}'.format(rsi))
@@ -135,11 +138,11 @@ def _handle_data(context, data):
def handle_data(context, data):
log.info('handling bar {}'.format(data.current_dt))
# try:
_handle_data(context, data)
# except Exception as e:
# log.warn('aborting the bar on error {}'.format(e))
# context.errors.append(e)
try:
_handle_data(context, data)
except Exception as e:
log.warn('aborting the bar on error {}'.format(e))
context.errors.append(e)
log.info('completed bar {}, total execution errors {}'.format(
data.current_dt,
+1
View File
@@ -544,6 +544,7 @@ class ExchangeTradingAlgorithm(TradingAlgorithm):
:param amount:
:return:
"""
# TODO: is this good enough? Victor has a better solution.
return amount
@api_method
+2 -2
View File
@@ -224,7 +224,8 @@ class Bitfinex(Exchange):
# TODO: fetch account data and keep in cache
return None
def get_candles(self, data_frequency, assets, bar_count=None):
def get_candles(self, data_frequency, assets, bar_count=None,
start_date=None):
"""
Retrieve OHLVC candles from Bitfinex
@@ -239,7 +240,6 @@ class Bitfinex(Exchange):
'1M'
"""
# TODO: use BcolzMinuteBarReader to read from cache
freq_match = re.match(r'([0-9].*)(m|h|d)', data_frequency, re.M | re.I)
if freq_match:
number = int(freq_match.group(1))
+2 -1
View File
@@ -1,7 +1,8 @@
{
"neobtc": {
"symbol": "neo_btc",
"start_date": "2017-09-07"
"start_date": "2017-09-07",
"precision":5
},
"neousd": {
"symbol": "neo_usd",
+1 -1
View File
@@ -208,7 +208,7 @@ class Bittrex(Exchange):
error=status['message']
)
def get_candles(self, data_frequency, assets, bar_count=None):
def get_candles(self, data_frequency, assets, bar_count=None, start_date=None):
"""
Supported Intervals
-------------------
@@ -70,6 +70,7 @@ class DataPortalExchange(DataPortal):
df_list.append(df)
# Merging the values values of each exchange
return pd.concat(df_list)
else:
+4 -1
View File
@@ -323,6 +323,7 @@ class Exchange:
)
try:
#TODO: use victor's modified branch using int64
self.minute_writer.write_sid(
sid=asset.sid,
df=df
@@ -592,7 +593,8 @@ class Exchange:
pass
@abstractmethod
def get_candles(self, data_frequency, assets, bar_count=None):
def get_candles(self, data_frequency, assets, bar_count=None,
start_date=None):
"""
Retrieve OHLCV candles for the given assets
@@ -601,6 +603,7 @@ class Exchange:
:param end_dt:
:param bar_count:
:param limit:
:param start_date:
:return:
"""
pass
+2 -2
View File
@@ -27,8 +27,6 @@ from catalyst.exchange.exchange_errors import \
log = Logger('LiveGraphClock')
style.use('dark_background')
fmt = mdates.DateFormatter('%Y-%m-%d %H:%M')
@@ -60,6 +58,8 @@ class LiveGraphClock(object):
def __init__(self, sessions, context, time_skew=pd.Timedelta('0s')):
style.use('dark_background')
self.sessions = sessions
self.time_skew = time_skew
self._last_emit = None
+7 -2
View File
@@ -152,12 +152,16 @@ def _run(handle_data,
exchange_name = exchange
start = pd.Timestamp.utcnow()
end = start + timedelta(minutes=1439)
# TODO: fix the end data.
end = start + timedelta(hours=8760)
exchange_list = [x.strip().lower() for x in exchange.split(',')]
exchanges = dict()
for exchange_name in exchange_list:
# Looking for the portfolio from the cache first
portfolio = get_algo_object(
algo_name=algo_namespace,
key='portfolio_{}'.format(exchange_name),
@@ -169,6 +173,7 @@ def _run(handle_data,
start_date=pd.Timestamp.utcnow()
)
# This corresponds to the json file containing api token info
exchange_auth = get_exchange_auth(exchange_name)
if exchange_name == 'bitfinex':
exchanges[exchange_name] = Bitfinex(
@@ -352,7 +357,7 @@ def _run(handle_data,
TradingAlgorithmClass = (
partial(ExchangeTradingAlgorithm, exchanges=exchanges,
algo_namespace=algo_namespace, live_graph=live_graph)
if live and exchanges else TradingAlgorithm)
if live and exchanges else TradingAlgorithm) # TODO: backtest trading algo class
perf = TradingAlgorithmClass(
namespace=namespace,