mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-13 17:42:42 +08:00
BUG: fixed issues with data frequencies in data.history() which was particularly noticeable in live mode and minor adjustments around the commission model
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import talib
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from catalyst import run_algorithm
|
||||
from catalyst.api import symbol
|
||||
|
||||
|
||||
def initialize(context):
|
||||
print('initializing')
|
||||
context.asset = symbol('burst_btc')
|
||||
context.asset = symbol('eth_btc')
|
||||
|
||||
|
||||
def handle_data(context, data):
|
||||
@@ -16,22 +16,22 @@ def handle_data(context, data):
|
||||
price = data.current(context.asset, 'close')
|
||||
print('got price {price}'.format(price=price))
|
||||
|
||||
prices = data.history(
|
||||
context.asset,
|
||||
fields='price',
|
||||
bar_count=15,
|
||||
frequency='1d'
|
||||
)
|
||||
rsi = talib.RSI(prices.values, timeperiod=14)[-1]
|
||||
print('got rsi: {}'.format(rsi))
|
||||
# prices = data.history(
|
||||
# context.asset,
|
||||
# fields='price',
|
||||
# bar_count=20,
|
||||
# frequency='1T'
|
||||
# )
|
||||
# rsi = talib.RSI(prices.values, timeperiod=14)[-1]
|
||||
# print('got rsi: {}'.format(rsi))
|
||||
pass
|
||||
|
||||
|
||||
run_algorithm(
|
||||
capital_base=250,
|
||||
start=pd.to_datetime('2017-08-01', utc=True),
|
||||
end=pd.to_datetime('2017-9-30', utc=True),
|
||||
data_frequency='minute',
|
||||
start=pd.to_datetime('2017-1-1', utc=True),
|
||||
end=pd.to_datetime('2017-10-22', utc=True),
|
||||
data_frequency='daily',
|
||||
initialize=initialize,
|
||||
handle_data=handle_data,
|
||||
analyze=None,
|
||||
@@ -43,7 +43,7 @@ run_algorithm(
|
||||
# initialize=initialize,
|
||||
# handle_data=handle_data,
|
||||
# analyze=None,
|
||||
# exchange_name='bitfinex',
|
||||
# exchange_name='bittrex',
|
||||
# live=True,
|
||||
# algo_namespace='simple_loop',
|
||||
# base_currency='eth',
|
||||
|
||||
Reference in New Issue
Block a user