Cannot figure out why my portfolio doubles in size with two short sales in a row.
Log output:
2013-06-07PRINTPrev Hi: 217.93
2013-06-07PRINTOpen: 219.03
2013-06-07PRINTBuy Short on 2013-06-07 13:31:00+00:00
2013-06-07PRINTPortfolio value: 10214.7381812
2013-06-07PRINTPosition shares: -46.6362515691
2013-06-07PRINT----
2013-06-07PRINTPortfolio value: 20314.4238187
2013-06-07PRINTPosition shares: -46
2013-06-07PRINTSell- cover short on 2013-06-07 13:36:00+00:00
2013-06-07PRINTTarget: 217.93
2013-06-07PRINTCurrent: 217.401
2013-06-07PRINTPortfolio value: 20314.4238187
2013-06-07PRINTPosition shares: 46
My algo should only have one position open at a time. Looks like for some reason a position is not closing out and begins building and borrowing to do so.
What is the best way to ensure no cash is borrowed, and positions are closed out before another position is opened?
Thanks