mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-10 23:55:20 +08:00
BLD: updating example algos for testing
This commit is contained in:
@@ -23,7 +23,7 @@ from catalyst.api import (order_target_value, symbol, record,
|
||||
|
||||
|
||||
def initialize(context):
|
||||
context.ASSET_NAME = 'btc_usd'
|
||||
context.ASSET_NAME = 'btc_usdt'
|
||||
context.TARGET_HODL_RATIO = 0.8
|
||||
context.RESERVE_RATIO = 1.0 - context.TARGET_HODL_RATIO
|
||||
|
||||
@@ -140,9 +140,9 @@ if __name__ == '__main__':
|
||||
initialize=initialize,
|
||||
handle_data=handle_data,
|
||||
analyze=analyze,
|
||||
exchange_name='bitfinex',
|
||||
exchange_name='poloniex',
|
||||
algo_namespace='buy_and_hodl',
|
||||
base_currency='usd',
|
||||
base_currency='usdt',
|
||||
start=pd.to_datetime('2015-03-01', utc=True),
|
||||
end=pd.to_datetime('2017-10-31', utc=True),
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ import pandas as pd
|
||||
|
||||
|
||||
def initialize(context):
|
||||
context.asset = symbol('btc_usd')
|
||||
context.asset = symbol('btc_usdt')
|
||||
|
||||
|
||||
def handle_data(context, data):
|
||||
@@ -41,9 +41,9 @@ if __name__ == '__main__':
|
||||
data_frequency='daily',
|
||||
initialize=initialize,
|
||||
handle_data=handle_data,
|
||||
exchange_name='bitfinex',
|
||||
exchange_name='poloniex',
|
||||
algo_namespace='buy_and_hodl',
|
||||
base_currency='usd',
|
||||
base_currency='usdt',
|
||||
start=pd.to_datetime('2015-03-01', utc=True),
|
||||
end=pd.to_datetime('2017-10-31', utc=True),
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ from catalyst.exchange.utils.exchange_utils import get_exchange_symbols
|
||||
def initialize(context):
|
||||
context.i = -1 # minute counter
|
||||
context.exchange = list(context.exchanges.values())[0].name.lower()
|
||||
context.base_currency = context.exchanges.values()[0].base_currency.lower()
|
||||
context.base_currency = list(context.exchanges.values())[0].base_currency.lower()
|
||||
|
||||
|
||||
def handle_data(context, data):
|
||||
@@ -65,7 +65,7 @@ def handle_data(context, data):
|
||||
minutes = 30
|
||||
|
||||
# get lookback_days of history data: that is 'lookback' number of bins
|
||||
lookback = one_day_in_minutes / minutes * lookback_days
|
||||
lookback = int(one_day_in_minutes / minutes * lookback_days)
|
||||
if not context.i % minutes and context.universe:
|
||||
# we iterate for every pair in the current universe
|
||||
for coin in context.coins:
|
||||
|
||||
@@ -12,7 +12,13 @@ from logbook import TestHandler, WARNING
|
||||
from pathtools.path import listdir
|
||||
|
||||
filter_algos = [
|
||||
'mean_reversion_simple_custom_fees.py',
|
||||
'buy_and_hodl.py',
|
||||
'buy_btc_simple.py',
|
||||
'buy_low_sell_high.py',
|
||||
'mean_reversion_simple.py',
|
||||
'rsi_profit_target.py',
|
||||
'simple_loop.py',
|
||||
'simple_universe.py',
|
||||
]
|
||||
|
||||
|
||||
@@ -58,7 +64,7 @@ class TestSuiteAlgo(WithLogger, ZiplineTestCase):
|
||||
initialize=algo.initialize,
|
||||
handle_data=algo.handle_data,
|
||||
analyze=TestSuiteAlgo.analyze,
|
||||
exchange_name='bitfinex',
|
||||
exchange_name='poloniex',
|
||||
algo_namespace='test_{}'.format(namespace),
|
||||
base_currency='eth',
|
||||
start=pd.to_datetime('2017-10-01', utc=True),
|
||||
@@ -67,6 +73,7 @@ class TestSuiteAlgo(WithLogger, ZiplineTestCase):
|
||||
)
|
||||
warnings = [record for record in log_catcher.records if
|
||||
record.level == WARNING]
|
||||
self.assertEqual(0, len(warnings))
|
||||
|
||||
if len(warnings) > 0:
|
||||
print('WARNINGS:\n{}'.format(warnings))
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user