backtesting.py icon indicating copy to clipboard operation
backtesting.py copied to clipboard

[WIP] Support multiple instruments(symbols) backtest

Open robert1003 opened this issue 3 years ago • 6 comments

Fixes https://github.com/kernc/backtesting.py/issues/20

An incomplete attempt to add multiple-symbol backtest, which is mentioned in #20. Not sure if this fits the current structure.

Lots of necessary changes haven't been done yet, including docs and code related graphing part.

robert1003 avatar May 08 '22 08:05 robert1003

How do you think @kernc? If you think it is inappropriate I will withdraw it, thanks.

robert1003 avatar May 09 '22 01:05 robert1003

It looks like the current attempt is not backwards compatible. For example, the signature of Strategy.position has changed from Position to dict[str, Position]. 😞

Maybe we can include a flag which enables multi-symbol mode and return Union[Position, dict[str, Position]] based on whether the mode is enabled or not?

AgarwalPragy avatar May 09 '22 05:05 AgarwalPragy

There is also something wrong with Broker.last_price and other functions.

AgarwalPragy avatar May 09 '22 05:05 AgarwalPragy

I've made a parallel attempt here https://github.com/kernc/backtesting.py/pull/641

AgarwalPragy avatar May 09 '22 05:05 AgarwalPragy

How is this coming along?

luketych avatar Aug 02 '22 05:08 luketych

Not related in anyway with him but @dodid did an awesome job extending this backtesting.py library to his minitrade package which enables multiasset backtesting, check it out: https://github.com/dodid/minitrade

PabloCanovas avatar Mar 24 '24 18:03 PabloCanovas