FXBot icon indicating copy to clipboard operation
FXBot copied to clipboard

Bot crash on trade creation (Pandas iloc)

Open ajeanselme opened this issue 4 years ago • 3 comments

When the bot tries to open a position, a crash occurs with the following traceback:

  File "/home/user/FXBot/main.py", line 139, in <module>
    trader = MomentumLive(cfg, instrument, granularity, window, units, stop_loss=stop_loss,
  File "/home/user/FXBot/livetrading/MomentumLive.py", line 34, in __init__
    super().__init__(
  File "/home/user/FXBot/livetrading/LiveTrader.py", line 77, in __init__
    self.stream_data(self._instrument)
  File "/home/user/.local/lib/python3.9/site-packages/tpqoa/tpqoa.py", line 357, in stream_data
    self.on_success(msg.time,
  File "/home/user/FXBot/livetrading/LiveTrader.py", line 199, in on_success
    self.trade()
  File "/home/user/FXBot/livetrading/LiveTrader.py", line 206, in trade
    if self._data["position"].iloc[-1] == 1:
  File "/home/user/.local/lib/python3.9/site-packages/pandas/core/indexing.py", line 895, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "/home/user/.local/lib/python3.9/site-packages/pandas/core/indexing.py", line 1501, in _getitem_axis
    self._validate_integer(key, axis)
  File "/home/user/.local/lib/python3.9/site-packages/pandas/core/indexing.py", line 1444, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds

ajeanselme avatar Feb 24 '22 12:02 ajeanselme

What happened with this? I'm getting this error. I'm using a demo account, trying to use momentum strategy. It crashes with the exact error when it tries to open a trade.

CaffeinatedTech avatar May 16 '22 08:05 CaffeinatedTech

What happened with this? I'm getting this error. I'm using a demo account, trying to use momentum strategy. It crashes with the exact error when it tries to open a trade.

No idea, Trent closed the issue with no answer

ajeanselme avatar May 29 '22 18:05 ajeanselme

Oh, I apologize. I mustve mistakenly thought this was an old ticket of mine.

Ill take a look!

trentstauff avatar May 30 '22 03:05 trentstauff