BUG: troubleshooting and minor fixes

This commit is contained in:
Frederic Fortier
2018-01-10 23:25:27 -05:00
parent b60b50e99a
commit 713d487808
4 changed files with 94 additions and 3 deletions
+2 -2
View File
@@ -244,7 +244,7 @@ def analyze(context=None, perf=None):
if __name__ == '__main__':
# The execution mode: backtest or live
live = False
live = True
if live:
run_algorithm(
@@ -257,7 +257,7 @@ if __name__ == '__main__':
algo_namespace=NAMESPACE,
base_currency='btc',
live_graph=False,
simulate_orders=False,
simulate_orders=True,
stats_output=None,
)
+4 -1
View File
@@ -129,7 +129,10 @@ def get_exchange_symbols(exchange_name, is_local=False, environ=None):
if not is_local and (not os.path.isfile(filename) or pd.Timedelta(
pd.Timestamp('now', tz='UTC') - last_modified_time(
filename)).days > 1):
download_exchange_symbols(exchange_name, environ)
try:
download_exchange_symbols(exchange_name, environ)
except Exception as e:
pass
if os.path.isfile(filename):
with open(filename) as data_file:
+44
View File
@@ -0,0 +1,44 @@
from logbook import Logger
from catalyst import run_algorithm
from catalyst.api import order_target_percent
NAMESPACE = 'goose7'
log = Logger(NAMESPACE)
from catalyst.api import record, symbol
def initialize(context):
context.asset = symbol('trx_btc')
def handle_data(context, data):
price = data.current(context.asset, 'price')
record(btc=price)
# Only ordering if it does not have any position to avoid trying some
# tiny orders with the leftover btc
pos_amount = context.portfolio.positions[context.asset].amount
if pos_amount > 0:
return
# Adding a limit price to workaround an issue with performance
# calculations of market orders
order_target_percent(
context.asset, 1, limit_price=price * 1.01
)
if __name__ == '__main__':
run_algorithm(
capital_base=0.003,
initialize=initialize,
handle_data=handle_data,
exchange_name='binance',
live=True,
algo_namespace=NAMESPACE,
base_currency='btc',
live_graph=False,
simulate_orders=False,
)
+44
View File
@@ -0,0 +1,44 @@
import pandas as pd
from catalyst import run_algorithm
from catalyst.api import symbol
def initialize(context):
context.asset = symbol('btc_usdt')
def handle_data(context, data):
df = data.history(context.asset,
'close',
bar_count=10,
frequency='5T',
)
if __name__ == '__main__':
LIVE = True
if LIVE:
run_algorithm(
capital_base=1,
initialize=initialize,
handle_data=handle_data,
exchange_name='poloniex',
algo_namespace='test_algo',
base_currency='usdt',
live=True,
simulate_orders=True,
)
else:
run_algorithm(
capital_base=1,
data_frequency='minute',
initialize=initialize,
handle_data=handle_data,
exchange_name='poloniex',
algo_namespace='test_algo',
base_currency='usdt',
live=False,
start=pd.to_datetime('2017-12-1', utc=True),
end=pd.to_datetime('2017-12-1', utc=True),
)