Differences between "spot" and "futures" modes ​
It's important to know the differences between spot and futures trading modes when writing your strategies.
- Short selling is not supported in spot trading so strategies should either avoid
should_short()
or make sure it returnsFalse
. - In futures mode, you can set
self.take_profit
andself.stop_loss
in thego_long()
. This means before opening a position you can set your exit targets. In the spot mode, however, fees are deducted from the assets you're trading. So we can't be sure about our position size (qty
) until it's actually open. Hence, we made the decision to not allow for setting exit targets in thego_long()
method when in the spot mode. Instead, you can do it inside the on_open_position() method. Example:
py
def on_open_position(self, order):
self.stop_loss = self.position.qty, self.price - 10
self.take_profit = self.position.qty, self.price + 10
- The self.leverage property always returns 1 in spot trading mode. In fact, if you backtest a strategy in futures mode with leverage of 1, and only open long positions, you should get very similar results as if you had backtested it in the spot mode.
- When Futures trading, your wallet balance (or
self.balance
in Jesse's API) only changes when a position is closed and the PNL is added or subtracted. It also does when fees are being charged. But in spot trading, it changes on order submission. In most cases this is not a problem; but nonetheless, if you're using the self.balance property in your strategies in a creative way, you should be aware of this. - self.available_margin equals to self.balance in the spot trading mode.
TIP
On the settings page, you can select the trading mode for the exchange you're using. That means you can use candle data for your backtests from Binance Spot
but run your backtests in the "futures" mode.
This is useful as spot exchanges usually provide more data than futures exchanges.