mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.91k stars 854 forks source link

Can you please add a simple SMA example for 2-3 stocks? #335

Closed jainraje closed 8 months ago

jainraje commented 4 years ago

Can a example be provided how to run a simple single sma cross strategy for several symbols?

Example:

Very good see work on this new version being done.

TIA. --Rajeev

mhallsmoore commented 4 years ago

Hi @jainraje,

Apologies for the delay in responding to this issue!

Yes, I'll certainly be adding more realistic examples of proper trading strategies into the /examples folder in subsequent releases. I previously had a Moving Average Crossover style strategy on a single instrument in the previous version.

I'll utilise the approach you describe above. One interesting issue is determining the weights for each symbol. This can either be done statically, that is, irrespective of the 'strength' of the crossover, or the weights themselves can be dynamically generated based on the current distance between the two moving averages. Both are valid approaches.

I'll leave this Issue open until a suitable example has been added.

Kind regards,

Mike.

jainraje commented 4 years ago

HI Mike,

Very good to see you are starting to think about adding the multi instrument as an example. I like the idea to build in flexibility such that the weights can dynamically be generated. The weights could be dynamic based on economic macro conditions or conditions specific to the instrument being traded or other.

Can the new version of qstrader be used "as is" to back test a single instrument MA crossover similar as was done with the old qstrader or is a update to qstrader required?

Thanks for your message.

Kind regards, --Rajeev