Trading rules
Each strategy starts with init_cash and no position. On each row, the previous row's order fills at this row's price, then this row's signals set the next order. So a signal on the last row never fills.
- An entry while holding, or an exit while flat, does nothing.
- If entry and exit are both true on one row, nothing happens, even when holding. To let the exit win, set entry to false wherever exit is true.
- A buy that cannot afford one raw base unit, or a sale worth less than one raw quote unit, does not fill and charges no fee. After a skipped sale the position stays open.
- A position still open at the end stays open and is valued at the last price.