I'm trying to get Jesse set up to work on developing and testing my own strategies, but to begin with I'm trying to get an example strategy to work. I've imported Coinbase candles (I kept running into issues with Binance candles when attempting to run backtrace and just decided to move to Coinbase to get things working to begin with).
When I attempt to run "jesse backtest --debug '2021-01-01' '2021-02-01'" I can see the following in the output:
[2021-01-04T12:00:00+00:00]: SUBMITTED order: BTC-USD, MARKET, buy, 0.32, $30774.11
[2021-01-04T12:00:00+00:00]: EXECUTED order: BTC-USD, MARKET, buy, 0.32, $30774.11
[2021-01-04T12:00:00+00:00]: Charged 49.24 as fee. Balance for USD on Coinbase changed from 10000 to 9950.76
[2021-01-04T12:00:00+00:00]: OPENED long position: Coinbase, BTC-USD, 0.32, $30774.11
==== BTC-USD | 2021-01-04T12:00 | 30774.11 | 31771.01 | 32246.07 | 30500.0 | 8793.18
==== BTC-USD | 2021-01-04T16:00 | 31771.01 | 31690.76 | 31930.55 | 30607.88 | 7212.94
==== BTC-USD | 2021-01-04T20:00 | 31690.76 | 32019.99 | 32050.0 | 30864.66 | 5330.11
[2021-01-05T00:00:00+00:00]: SUBMITTED order: BTC-USD, MARKET, sell, -0.32, $32019.99
Uncaught Exception: InsufficientMargin: You cannot submit an order for $10246 when your margin balance is $103
However, if my understanding is correct, it should have purchased 0.32 BTC at the price of $30,774.11 then sold 0.32 BTC at $32,019.99, resulting in a balance of $10,398.68 (minus fees). Next it then looks like it attempts to buy with $10,246 (which should be fine, right? since it just sold and now has at least that much USD?), however it receives the exception stating that the account only has $103 in it.
What is the issue with the strategy/backtesting that is preventing it from using the funds that it just obtained by selling?