produvia / kryptos

Kryptos AI is a virtual investment assistant that manages your cryptocurrency portfolio
http://twitter.com/kryptos_ai
MIT License
48 stars 8 forks source link

Allow alternative HISTORY_FREQ values #102

Open treethought opened 6 years ago

treethought commented 6 years ago

When running a strategy in live/paper mode using poloniex exchange and 1T HISTORY_FREQ the following error occurs:

catalyst.exchange.exchange_errors.UnsupportedHistoryFrequencyError: poloniex does not support candle frequency 1T, please choose from: ['5T', '15T', '30T', '2H', '4H', '1D']

Related to https://github.com/enigmampc/catalyst/issues/247#issuecomment-368140563 and https://github.com/produvia/kryptos/issues/98#issuecomment-411838907

@bukosabino Would simply passing any of the "T" aliases work with filtering the historical data, since it is being filtered based on the MINUTE_FREQ parameter?

bukosabino commented 6 years ago

Hi @treethought ,

You are right. HISTORY_FREQ shouldn't be a fixed value. I have updated the code. Then, you can pass any value provided that it is divisible by MINUTE_FREQ.

Example:

"HISTORY_FREQ": "5T",
"MINUTE_FREQ": "300",
treethought commented 6 years ago

It seems this issue has come up again. Running a strategy in paper mode with config:

 "EXCHANGE": "poloniex",
 "DATA_FREQ": "minute",
 "HISTORY_FREQ": "5T",
 "MINUTE_FREQ": "15", "doc":"minute interval",
 "MINUTE_TO_OPERATE": "1", "doc":"minute to operate on range [0, MINUTE_FREQ]",

Produces the following error:

ile "/core/kryptos/strategy/strategy.py", line 458, in _process_data
    last_date = self._get_last_date(context, data)
  File "/core/kryptos/strategy/strategy.py", line 573, in _get_last_date
    context.prices = context.prices.loc[filter_dates]
  File "/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py", line 1312, in __getitem__
    return self._getitem_axis(key, axis=0)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py", line 1472, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py", line 1036, in _getitem_iterable
    self._has_valid_type(key, axis)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/indexing.py", line 1395, in _has_valid_type
    (key, self.obj._get_axis_name(axis)))
KeyError: "None of [DatetimeIndex(['2013-01-01 00:01:00+00:00', '2013-01-01 00:16:00+00:00',\n               '2013-01-01 00:31:00+00:00', '2013-01-01 00:46:00+00:00',\n               '2013-01-01 01:01:00+00:00', '2013-01-01 01:16:00+00:00',\n               '2013-01-01 01:31:00+00:00', '2013-01-01 01:46:00+00:00',\n               '2013-01-01 02:01:00+00:00', '2013-01-01 02:16:00+00:00',\n               ...\n               '2018-10-22 19:16:00+00:00', '2018-10-22 19:31:00+00:00',\n               '2018-10-22 19:46:00+00:00', '2018-10-22 20:01:00+00:00',\n               '2018-10-22 20:16:00+00:00', '2018-10-22 20:31:00+00:00',\n               '2018-10-22 20:46:00+00:00', '2018-10-22 21:01:00+00:00',\n               '2018-10-22 21:16:00+00:00', '2018-10-22 21:31:00+00:00'],\n              dtype='datetime64[ns, UTC]', length=203607, freq='15T')] are in the [index]"

@bukosabino can you take a look at this traceback?