Hi,
my algo is designed to enter in the market with a fixed number of stocks and it works like this:
for each sector:
- select good and bad stocks
- check if the number of good and bad stocks is enough (greather than c.num_stocks)
- save those stocks in a dict
update universe with those stocks
now for the order part...
- check if the stocks is delisted
- check if the stocks has open orders
- exit all previous positions no matter what (to be shure that i'm flat every rebalance day)
- order stocks
The problem i'm stuck with:
As you can see i never have the same amount of positions for the long side and for the short side as i would expect since the correct number of stocks is available for shure.
The leverage is never the same maybe this is related to the number of stocks....
What i have done to avoid this:
filter the pipeline with this
price_filter = (price >= 1.0)
volume_filter = (volume >= 100 * 60 * 6.30)
mkt_cap_filter = mkt_cap > 3000e6
dollar_volume_filter = dollar_volume > 10**7
and as i have written before i have avoided open orders stocks and delisted stocks.
Thank you very much for any help..