freqtrade / freqtrade

Free, open source crypto trading bot
https://www.freqtrade.io
GNU General Public License v3.0
31.71k stars 6.43k forks source link

cost in backtesting code seems wrong? #11003

Closed JsonAC closed 5 days ago

JsonAC commented 5 days ago

Describe your environment

Your question

Ask the question you have not been able to find an answer in the Documentation

In backtesting.py, line 1142, the code is: cost=amount * propose_rate + trade.fee_open

Note that amount propose_rate is the stake_amount, and trade.fee_open=self.fee is percentage, they seem to have different dimensions. Is there an error? Is the correct way as follows? cost=amount propose_rate * (1+ trade.fee_open)

xmatthias commented 5 days ago

possible - would need a closer look. It's however very close to irrelevant if you note the italic section of the relevant docs

Cost of the order - usually average * filled (Exchange dependent on futures, may contain the cost with or without leverage and may be in contracts.)

As such - also the strategy must be very careful in using this (don't use stake_amount instead).- as dry and live may have different contents (we know how it's filled in dry - but live exchanges may behave differently - and in live trading, this value is assigned directly as it comes from ccxt).


As it's content is not reliable - Cost on the order object has no operational meaning to freqtrade - and is only really kept for reference. As such, i doubt there's tests around this - and i doubt anyone cares if this is correct in backtesting 😆

JsonAC commented 5 days ago

possible - would need a closer look. It's however very close to irrelevant if you note the italic section of the relevant docs

Cost of the order - usually average * filled (Exchange dependent on futures, may contain the cost with or without leverage and may be in contracts.)

As such - also the strategy must be very careful in using this (don't use stake_amount instead).- as dry and live may have different contents (we know how it's filled in dry - but live exchanges may behave differently - and in live trading, this value is assigned directly as it comes from ccxt).

As it's content is not reliable - Cost on the order object has no operational meaning to freqtrade - and is only really kept for reference. As such, i doubt there's tests around this - and i doubt anyone cares if this is correct in backtesting 😆

Thank you for your reply. I actually won't be using this feature in practice, and I hope it won't have any real impact. I'm just getting started with this project, so I went through all the backtesting code and only noticed this issue.