edtechre / pybroker

Algorithmic Trading in Python with Machine Learning
https://www.pybroker.com
Other
2.09k stars 262 forks source link

How to use IndicatorSet with Strategy? #49

Closed Pirat83 closed 1 year ago

Pirat83 commented 1 year ago

Hello,

I have red https://www.pybroker.com/en/latest/notebooks/5.%20Writing%20Indicators.html#Computing-Multiple-Indicators and https://www.pybroker.com/en/latest/_modules/pybroker/indicator.html#IndicatorsMixin but I can not figure out how to use the IndicatorSet with pybroker's Strategy?

I am able to add and remove the Indicators to / from the IndicatorSet but I don't know where the 'DataFramementioned in the documentation cames from and how to use it inside aStrategy`?

Also I would like to calculate Indicators on dedicated symbols not on all. Is this possible?

Could you please give me a hint? Thank you very much.

edtechre commented 1 year ago

Hi Pirate83,

The IndicatorSet is only intended to be used to generate a DataFrame. If you wish, you can use data from that DataFrame with a Strategy. Otherwise, it is recommended you declare your indicators with pybroker.indicator.

Indicators are only computed on the symbols that you specify to use on a strategy execution. You can add multiple executions on a strategy with different symbols and indicators. See Strategy#add_execution.