PacktPublishing / Learn-Algorithmic-Trading

Learn Algorithmic Trading, Published by Packt
MIT License
802 stars 302 forks source link

chapter 5 mean reversion #4

Closed rezam71 closed 3 years ago

rezam71 commented 3 years ago

mark the remaining position to market i.e. pnl would be what it would be if we closed at current price

open_pnl += abs(sell_sum_qty - position) * (close_price - buy_sum_price_qty / buy_sum_qty)

Above block of code is wrong. it should be open_pnl += abs(position)*(.........). Position is the amount the should be marked to market

jiripik commented 3 years ago

Hello:

Thank you for your question.

The issue is more complex: