freqtrade / freqtrade

Free, open source crypto trading bot

Home Page:https://www.freqtrade.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation: Different bot logic execution order in Live/Dry Run vs Backtest Hyperoptimization

dnuno89 opened this issue · comments

Describe your environment

  • Operating system: Windows 11
  • Python Version: 3.11
  • CCXT version: 4.2.47
  • Freqtrade Version: 2024.2

Your question

Reading the freqtrade documentation it seems to me that the detailed execution order differs in live/dry run vs backtest/hyperopt.

In Live/Dry Run, open trade adjustments by calling adjust_trade_position() are executed before opening new positions. In the detailed order for Backtesting/Hyperopt this goes the other way around, and "check for trade entry signals" is executed before adjust_trade_position().

Is this a documentation issue? Which one is it?
Thanks

I don't see that as an issue. There is slight difference in the execution logic. But it won't matter much. Unless you have different opinion?

I don't see why this would make a difference, really.
The only case where (i think) it "might" actually matter is when adjust_trade_position() closes the trade (opening a new trade slot - with previously having all filled) - and a new signal would open a new position on the same candle - filling this just opened trade-slot again.
This is however not dependent on adjust_trade_position() - but is also not supported for regular exits.

Reasons for this are multi-fold - but mainly rooted in the processing order for backtesting - where the pairlist is processed from top to bottom - so if your 2nd to last pair sells - only the last pair would be checked for new entries.
We don't want to iterate over the pairlist multiple times per candle, either - as that would significantly slow backtesting.

Live will behave slightly differently in this case - as you have more than iteration per candle - so a trade that exits WILL free a trade slot - which may be filled immediately after by a different pair.

This can also affect with strategies with a tendency to (sometimes) use all its available stake, since it could either finish the stake with opened trades or opening new trades, or when the requisites to open a new trade depend on the % of used stake (my case).

Anyway, I understand the technical reasons for this. Could I suggest to specify this difference in the documentation, maybe in section Assumptions made by backtesting ?

Thanks

Closed by 43aee21 ... messed up the commit link 😆