ccGains icon indicating copy to clipboard operation
ccGains copied to clipboard

KeyError

Open alanblake opened this issue 6 years ago • 1 comments

I'm getting the following error when running ccGains. No error reported when ccGains was run on the previous years data .

INFO    : TRADE #1
INFO    : Exchange on 2018-01-07 09:38:26+00:00: Acquired ...
INFO    : Processing trade: Exchange, 2018-01-07 09:38:26+00:00, BTC, ...
INFO    : Selling ... XRP for ... BTC at Poloniex (2018-01-07 09:38:26+00:00, fee: ... BTC)
WARNING : Date 2018-01-07 09:38:26+00:00 missing in cached data. Repeating request to API
INFO    : Fetched historical price data with request: https://poloniex.com/public?command=returnTradeHistory&currencyPair=BTC_XRP&start=1515283200&end=1515369600
INFO    : Successfully fetched 1000 trades
INFO    : Saved bags' state to /ccGains/profile-XX/precrash.json
Traceback (most recent call last):
  File "pandas/_libs/index.pyx", line 439, in pandas._libs.index.DatetimeEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 987, in pandas._libs.hashtable.Int64HashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 993, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 1515315600000000000

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/ccGains/env3/lib/python3.6/site-packages/ccgains/bags.py", line 843, in pay
    self.relation.get_rate(dtime, currency, self.currency))
  File "/ccGains/env3/lib/python3.6/site-packages/ccgains/relations.py", line 280, in get_rate
    result *= self.historic_prices[step_key].get_price(dtime)
  File "/ccGains/env3/lib/python3.6/site-packages/ccgains/historic_data.py", line 113, in get_price
    return df.at[pd.Timestamp(dtime).floor(df.index.freq)]
  File "/ccGains/env3/lib/python3.6/site-packages/pandas/core/indexing.py", line 2270, in __getitem__
    return self.obj._get_value(*key, takeable=self._takeable)
  File "/ccGains/env3/lib/python3.6/site-packages/pandas/core/series.py", line 1187, in _get_value
    return self.index.get_value(self._values, label)
  File "/ccGains/env3/lib/python3.6/site-packages/pandas/core/indexes/datetimes.py", line 939, in get_value
    return self.get_value_maybe_box(series, key)
  File "/ccGains/env3/lib/python3.6/site-packages/pandas/core/indexes/datetimes.py", line 971, in get_value_maybe_box
    key, tz=self.tz)
  File "pandas/_libs/index.pyx", line 81, in pandas._libs.index.IndexEngine.get_value
  File "pandas/_libs/index.pyx", line 89, in pandas._libs.index.IndexEngine.get_value
  File "pandas/_libs/index.pyx", line 441, in pandas._libs.index.DatetimeEngine.get_loc
KeyError: Timestamp('2018-01-07 09:00:00+0000', tz='UTC')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ccGains-XX-2018.py", line 386, in <module>
    main()
  File "ccGains-XX-2018.py", line 249, in main
    bf.process_trade(trade)
  File "/ccGains/env3/lib/python3.6/site-packages/ccgains/bags.py", line 1087, in process_trade
    'buy_ratio': trade.buyval / trade.sellval})
  File "/ccGains/env3/lib/python3.6/site-packages/ccgains/bags.py", line 848, in pay
    currency, self.currency, dtime))
  File "/ccGains/env3/lib/python3.6/site-packages/ccgains/bags.py", line 240, in _abort
    raise exception_type(msg)
ValueError: Could not fetch the price for currency_pair XRP_AUD on 2018-01-07 09:38:26+00:00 from provided CurrencyRelation object.

alanblake avatar Jul 07 '19 03:07 alanblake

I've resolved this temporarily by limiting the poloniex history data fetch. I set the end time to the transaction timestamp. I'll post more details soon

alanblake avatar Jul 08 '19 06:07 alanblake