robcarver17 / pysystemtrade

Systematic Trading in python
GNU General Public License v3.0
2.66k stars 837 forks source link

TypeError in build_roll_calendars #1375

Closed craigmediaservices closed 6 months ago

craigmediaservices commented 6 months ago

I was encountering the following error when building roll calendars from IB seed data which this addresses:

  File "/home/trader/pysystemtrade/sysobjects/roll_calendars.py", line 56, in create_from_prices
    adjusted_calendar = adjust_to_price_series(
  File "/home/trader/pysystemtrade/sysinit/futures/build_roll_calendars.py", line 199, in adjust_to_price_series
    adjusted_row = _adjust_row_of_approx_roll_calendar(
  File "/home/trader/pysystemtrade/sysinit/futures/build_roll_calendars.py", line 280, in _adjust_row_of_approx_roll_calendar
    adjusted_roll_date = _find_best_matching_roll_date(
  File "/home/trader/pysystemtrade/sysinit/futures/build_roll_calendars.py", line 431, in _find_best_matching_roll_date
    valid_dates = _valid_dates_from_paired_prices(paired_prices, avoid_date)
  File "/home/trader/pysystemtrade/sysinit/futures/build_roll_calendars.py", line 465, in _valid_dates_from_paired_prices
    valid_dates = _valid_dates_from_matching_prices(paired_prices_matching, avoid_date)
  File "/home/trader/pysystemtrade/sysinit/futures/build_roll_calendars.py", line 485, in _valid_dates_from_matching_prices
    valid_dates = valid_dates[valid_dates > avoid_date]
  File "/home/trader/.local/lib/python3.10/site-packages/pandas/core/ops/common.py", line 76, in new_method
    return method(self, other)
  File "/home/trader/.local/lib/python3.10/site-packages/pandas/core/arraylike.py", line 56, in __gt__
    return self._cmp_method(other, operator.gt)
  File "/home/trader/.local/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 7124, in _cmp_method
    result = ops.comparison_op(self._values, other, op)
  File "/home/trader/.local/lib/python3.10/site-packages/pandas/core/ops/array_ops.py", line 332, in comparison_op
    res_values = op(lvalues, rvalues)
TypeError: '>' not supported between instances of 'numpy.ndarray' and 'Timestamp'
craigmediaservices commented 6 months ago

This should have been made to develop