catalyst
catalyst copied to clipboard
Question in paper-trading mode: 1. how to get data in 5H , 2. how to get data only every 5 hours but not every minute? 3.how to show my log
Dear Catalyst Maintainers,
I am running algorithm in paper-trading mode, data_frequency = 'minute'
, exchange_name=binance
I want the 5H data. So I set
def handle_data(context, data):
context.i += 1
if context.i % 300:
return
prices = data.history(
context.asset,
fields=['price', 'open', 'high', 'low', 'close', 'volume'],
bar_count=60,
frequency="5H")
log.info('- check every 5H')
I have three questions:
- How could I use "5H" data in live mode? Is there util method can merge 1H data into 5H data?
In live mode binance does not support candle frequency 5H, but in backtest mode it's ok to use "5H".
catalyst.exchange.exchange_errors.UnsupportedHistoryFrequencyError:
binance does not support candle frequency 5H,
please choose from: ['1T', '3T', '5T', '15T', '30T', '1H', '2H', '4H', '6H', '8H', '12H', '1D', '3D', '1W', '1M'].
- How to get data only every 5 hours but not every minute? I only need to check the candle bar data every 5 hours, but in the log, it shows that it will fetch data every minute. I have set
if context.i % 300:
return
in the handle_data method, why it still get data every minute?
- How to show my log?
I have write some log script such aslog.info('- check every 5H')
. But in the .out log file, it only shows something like that :
[2019-02-25 17:09:03.456831] INFO: run_algo: running algo in paper-trading mode
[2019-02-25 17:09:04.714342] INFO: ExchangeClock: The algorithm is waiting for the specified start date: 2019-02-26 00:00:00+00:00
[2019-02-26 00:00:00.001327] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:00:00.102716] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:01:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
[2019-02-26 00:01:00.209680] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:01:00.225672] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:02:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
[2019-02-26 00:02:00.326567] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:02:00.342804] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:03:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
[2019-02-26 00:03:00.447369] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:03:00.462581] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:04:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
[2019-02-26 00:04:00.570380] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:04:00.659012] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:05:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
[2019-02-26 00:05:00.766580] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:05:00.782073] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:06:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
[2019-02-26 00:06:00.863535] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:06:00.879477] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:07:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
[2019-02-26 00:07:00.988808] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:07:01.005339] INFO: exchange_algorithm: statistics for the last 1 minutes:
How can I make my log sentence in the .out file? How to ignore the every minute log such as:
[2019-02-26 00:06:00.863535] INFO: exchange_algorithm: portfolio balances, cash: 1000000.0, positions: 0.0
[2019-02-26 00:06:00.879477] INFO: exchange_algorithm: statistics for the last 1 minutes:
starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions
period_close
2019-02-26 00:07:00+00:00 1000000 1000000.0 1000000.0 0.0 0 0 0 0
Thank you very much!
...
Sincerely, chairy11