-
I am currently working on a trading strategy that relies on a proprietary index and a self-developed indicator. I have successfully implemented a rotation strategy that buys a calculated set of stocks and rotates them. However, I am encountering two issues:
I must admit that I am not a Python expert, but I am trying to navigate through with my Perl knowledge and documentation. So far, I find the module really great, as it has immediately reflected my rotation strategy. I would greatly appreciate any guidance or suggestions on how to address these issues. Thank you in advance for your help! Code to reproduce the error. 'AIR.PA' seems to be the problem here, _verify_input fails since fill_price is nan
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @McHill007, Sorry for the late response.
You can use pybroker.param to store index constituents and check for membership in your strategy e.g.
It looks like this is due to bad data being returned from YF as NaN. By default, the bar's close price is used as the fill price. Running this code:
Returns 68 rows with NaN close prices. What you can do is query your data separately, drop all NaN values, and then use the resulting DataFrame as your Strategy's DataSource:
|
Beta Was this translation helpful? Give feedback.
Hi @McHill007,
Sorry for the late response.
You can use pybroker.param to store index constituents and check for membership in your strategy e.g.
pybroker.param('qqq', ...)
if ctx.symbol in pybroker.param('qqq'):