Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

[BUG] Multiple instrument doesn't work #146

Open
IlyaKrotov opened this issue Dec 4, 2019 · 4 comments
Open

[BUG] Multiple instrument doesn't work #146

IlyaKrotov opened this issue Dec 4, 2019 · 4 comments
Labels

Comments

@IlyaKrotov
Copy link

IlyaKrotov commented Dec 4, 2019

Describe the bug
Hello! Thank you for your library. It is awesome. I started to use it and now I'm trying to code my strategies with pairs trading. But I've got an issue and I cannot solve it. Here is the example. And the output is the following:

start!
/usr/local/lib/python3.7/site-packages/pandas/core/indexing.py:376: FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive ndarray with 'datetime64[ns]' dtype. In the future, this will return an ndarray with 'object' dtype where each element is a 'pandas.Timestamp' with the correct 'tz'.
        To accept the future behavior, pass 'dtype=object'.
        To keep the old behavior, pass 'dtype="datetime64[ns]"'.
  self.obj[key] = _infer_fill_value(value)
index -1 is out of bounds for axis 0 with size 0

So, what is wrong and fix it?

Thank you

To Reproduce

from qtpylib.algo import Algo

class PairsTrader(Algo):

    def on_start(self):
        print('start!')

    def on_tick(self, instrument):
        print('\Tick: ', self.get_instrument('AAPL').get_tick())
        print('\Tick: ', self.get_instrument('AMD').get_tick())

if __name__ == "__main__":
    strategy = PairsTrader(
        instruments=['AAPL',  'AMD'],
        tick_window=1000,
        resolution='32K',
        preload='100K',
        timezone="US/Eastern",
        ibport=4003,
        backtest=True,
        log='strats_results',
        output='strats_results/log.pkl',
        start='2019-12-01',
        end='2019-12-04',
        blotter="MainBlotter"
    )

    strategy.run()

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version: 16

Additional context
I built it from source.

@IlyaKrotov IlyaKrotov added the bug label Dec 4, 2019
@IlyaKrotov
Copy link
Author

#47
This also doesn't work, always the same:
On bar:
13:52:43 +1 AMD {'AAPL': 0, 'AMD': 28}

@JMA6971
Copy link

JMA6971 commented Dec 8, 2019

fyi - idk if multiple instruments is implemented

@IlyaKrotov
Copy link
Author

fyi - idk if multiple instruments is implemented

Is should be because you can find an example in docs with 2 instruments.

@etsygankov
Copy link

etsygankov commented Dec 30, 2019

index -1 is out of bounds for axis 0 with size 0

Just by the error message I would assume that the issue is caused by slicing of a numpy array of a zero size somewhere in the code as in the example below

>>> import numpy as np
>>> np.array([])[-1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: index -1 is out of bounds for axis 0 with size 0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants