Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
possible bug. cost_basis showing very different from tick price

I understand the below:
- Order gets executed after the current tick is completed
- Commissions apply
- Slippage happens

But despite all these, I am seeing a big difference in tick price and cost_basis when I try to buy SPY with only 10% capital. Here are some samples from log. Is it due to the 10% thing the cost_basis average is coming down?

tick price: 99.19, bought price based on cost_basis 105.464947648

5 responses

sa.

we cannot see your code to troubleshoot it. :)

Sorry here is the code; I am trying to buy with only 10% of the total capital and I see the bought price to be very different from the tick price

The basic algo logic is to buy SPY at 15 day low and sell for 5$ profit. I am trying to buy with only 10 pct of capital and if you see the log the bought price is very different from the tick price

Sa, are you aware of this?

You log the bought price, but the actual price (that is the cost basis) is the close price of the next minute bar. This should explain the first discrepancy between log and real buy price.

Then you log the sold price, but the actual price at which you sell is the close price of next minute bar. This is the second discrepancy between log and real sell price.

You may also want to correct for that using function shared by Anthony Mole here]1
TradeAtTheOpenSlippageModel

Thank you all