I have two goals in mind:
- Keeping leverage < 1
I am using the ExposureMngr
class which I found on these forums and only purchasing stocks when context.exposure.get_available_cash(context) >= 300 * data.current(s, "close")
. If that is true, the purchase going through is order(s, 300)
. Given slippage and a few other things, I can see the leverage going up a small bit but it jumps to 8x. Presumably I am utilizing this helper class ExponsureMngr
wrong?.
- Determining why fill values can be in the thousands exist
Given what I mentioned earlier, I only ever buy stocks in quantities of 300 only if they don't exist as a position s not in context.portfolio.positions
and it doesn't exist in an open order, s not in get_open_orders()
. However my logs are still littered with Your order for 6596 shares of LNC failed to fill by the end of day and was canceled.
Any idea why there would be so many shares of LNC trying to fill? Controlling how many buy orders there are seems pretty straight forward, but something here is not being considered.
Thanks !