I have a very simple algo:
Buy a stock with limit price.
Sell with the limit price of that cost basis.
I am only ever buying 1 unit of stock and selling that unit only when there are no open orders for that stock. I must be missing something in the way that a limit sell order executes.
Here are some logs and it clear that pretty soon I've made a loss:
pnl: 0.000000
total value: 1000.000000
buying a unit under: 732.880000
pnl: 0.000000
total value: 1000.000000
pnl :-0.000000
total value: 1000.000000
brought at: 732.760000
selling a unit at over: 732.760000
pnl: 0.748000
total value: 1000.748000
buying a unit under: 733.508000
pnl: 0.748000
total value: 1000.748000
brought at: 732.960000
selling a unit at over: 732.960000
pnl :-0.252000
total value: 999.748000