iterativv / NostalgiaForInfinity

Trading strategy for the Freqtrade crypto bot
GNU General Public License v3.0
2k stars 498 forks source link

Grinding feature causes constant massive losses in NFIX2 #275

Closed BillyYan13 closed 1 year ago

BillyYan13 commented 1 year ago

Grinding keeps selling at lower price than open rate. My bot has already traded over 30 trades with grinding for two open trades; all of them ended up with losses.

Mandark-droid commented 1 year ago

Please provide more details to check into the issue. Just posting a one liner statement is not going to help anyone.

  1. Freqtrade and the strategy versions used.
  2. Your config with pairlist.
  3. The pairs your bot entered for grinding and all the trade details. (entry/exit details).
  4. It will eventually exit the first trade in profit. I have seen grinding perform more than 100 trades for other users and come of the bad trade without any loss.
BillyYan13 commented 1 year ago

Thanks for your reply:

  1. Freqtrade version: 2023.2 NFIX2 v12.0.239
  2. Config:

{ "max_open_trades": 4, "stake_currency": "USDT", "stake_amount": "unlimited", "tradable_balance_ratio": 0.99, "dry_run_wallet": 1000, "fiat_display_currency": "USD", "dry_run": false, "force_entry_enable": true, "trading_mode": "spot", "margin_mode": "", "unfilledtimeout": { "entry": 15, "exit": 15, "exit_timeout_count": 0, "unit": "minutes" }, "order_types": { "entry": "limit", "exit": "market", "emergency_exit": "market", "force_entry": "limit", "force_exit": "market", "stoploss": "limit", "stoploss_on_exchange": false, "stoploss_on_exchange_interval": 60 }, "entry_pricing": { "price_side": "other", "use_order_book": false, "order_book_top": 1, "price_last_balance": 0.0, "check_depth_of_market": { "enabled": false, "bids_to_ask_delta": 1 } }, "exit_pricing":{ "price_side": "other", "use_order_book": false, "order_book_top": 1, "price_last_balance": 0.0 }, "exchange": { "name": "binance", "key": "**", "secret": "***", "ccxt_config": { "enableRateLimit": true }, "ccxt_async_config": { "enableRateLimit": true, "rateLimit": 100 }, "pair_whitelist": [

    ],
    "pair_blacklist": [
        "(BNB)/.*",
        ".*(_PREMIUM|BEAR|BULL|HALF|HEDGE|UP|DOWN|[1235][SL])/.*",
        "(AUD|BRZ|CAD|CHF|EUR|GBP|HKD|IDRT|JPY|NGN|RUB|SGD|TRY|UAH|USD|ZAR)/.*",
        "(BUSD|CUSD|CUSDT|DAI|PAXG|SUSD|TUSD|USDC|USDN|USDP|USDT|VAI|UST|USTC|AUSD)/.*",
        "(ACM|AFA|ALA|ALL|ALPINE|APL|ASR|ATM|BAR|CAI|CHZ|CITY|FOR|GAL|GOZ|IBFK|JUV|LEG|LOCK-1|NAVI|NMR|NOV|PFL|PSG|ROUSH|STV|TH|TRA|UCH|UFC|YBO)/.*",
        "(1EARTH|ILA|BOBA|CTXC|CWAR|HBAR|NMR|OMG|ONG|ARDR|DMTR|MLS|TORN|ANC|LUNA|BTS|QKC|COS|ACA|FTT|SRM|YFII|SNM|BNX|WAVES|MIR)/.*"

    ]

},
"pairlists": [
    {
        "method": "VolumePairList",
        "number_assets": 70,
        "sort_key": "quoteVolume",
        "refresh_period": 1800
},
{"method": "AgeFilter", "min_days_listed": 30},
{
    "method": "PriceFilter",
    "low_price_ratio": 0.003
},
{
    "method": "SpreadFilter",
    "max_spread_ratio": 0.0075
},
{
    "method": "RangeStabilityFilter",
    "lookback_days": 3,
    "min_rate_of_change": 0.03,
    "refresh_period": 1800
},
    {
        "method": "VolatilityFilter",
        "lookback_days": 3,
        "min_volatility": 0.01,
        "max_volatility": 0.75,
        "refresh_period": 43200
    },
    {
        "method": "VolumePairList",
        "number_assets": 65,
        "sort_key": "quoteVolume"
    },
    {"method": "ShuffleFilter"}
],
"edge": {
    "enabled": false,
    "process_throttle_secs": 3600,
    "calculate_since_number_of_days": 7,
    "allowed_risk": 0.01,
    "stoploss_range_min": -0.01,
    "stoploss_range_max": -0.1,
    "stoploss_range_step": -0.01,
    "minimum_winrate": 0.60,
    "minimum_expectancy": 0.20,
    "min_trade_number": 10,
    "max_trade_duration_minute": 1440,
    "remove_pumps": false
},
"telegram": {
    "enabled": true,
    "token": "*********",
    "chat_id": "*******"
},
"api_server": {
    "enabled": true,
    "listen_ip_address": "*****",
    "listen_port": 8080,
    "verbosity": "error",
    "enable_openapi": false,
    "jwt_secret_key": "*********",
    "CORS_origins": [],
    "username": "*****r",
    "password": "*****"
},
"bot_name": "*****",
"initial_state": "running",
"internals": {
    "process_throttle_secs": 5
}

}

  1. I will share the last trade details from Telegram. Otherwise tell me if you need the details of all trades. I don't know how to recall them all from the Terminal.

    Freqtrade: ❌ Binance: Exiting DYDX/USDT (#217) Unrealized Sub Profit: -3.29% (loss: -280.13361843 USDT / -280.117 USD) Cumulative Profit: (-3712.45799813 USDT / -3712.239 USD) Enter Tag: 1 Exit Reason: partial_exit Direction: Long Amount: 3659.56000000 Open Rate: 2.32656343 Current Rate: 2.25400000 Exit Rate: 2.25459615 Remaining: (60589.762 USDT, 60586.187 USD)

Freqtrade: ❌ Binance: Exited DYDX/USDT (#217) Sub Profit: -3.29% (loss: -280.13361843 USDT / -280.117 USD) Cumulative Profit: (-3992.59161656 USDT / -3992.356 USD) Enter Tag: 1 Exit Reason: partial_exit Direction: Long Amount: 3659.56000000 Open Rate: 2.32656343 Exit Rate: 2.25459615 Remaining: (52075.564 USDT, 52072.491 USD)

Freqtrade: Grinding exit DYDX/USDT | Rate: 2.254 | Stake amount: 8248.64824| Coin amount: 3659.56 | Total profit: -9.20% | Grind profit: 1.21%

The other pair:

❌ Binance: Exiting QTUM/USDT (#202) Unrealized Sub Profit: -8.37% (loss: -22.01463100 USDT / -22.037 USD) Cumulative Profit: (-25.14181056 USDT / -25.167 USD) Enter Tag: 57 Exit Reason: partial_exit Direction: Long Amount: 80.20000000 Open Rate: 3.27820844 Current Rate: 3.01100000 Exit Rate: 3.01000000 Remaining: (1878.854 USDT, 1880.733 USD) 10:17 Thumbs Up ❌ Binance: Exited QTUM/USDT (#202) Sub Profit: -8.37% (loss: -22.01463100 USDT / -22.037 USD) Cumulative Profit: (-47.15644156 USDT / -47.204 USD) Enter Tag: 57 Exit Reason: partial_exit Direction: Long Amount: 80.20000000 Open Rate: 3.27820844 Exit Rate: 3.01000000 Remaining: (1615.942 USDT, 1617.558 USD)

  1. The trades haven't closed yet. Although they're open since several days

Thanks once again

Mandark-droid commented 1 year ago

You can get the details for all the grinding buy/sell in the FreqUI

iterativv commented 1 year ago

Grinding keeps selling at lower price than open rate. My bot has already traded over 30 trades with grinding for two open trades; all of them ended up with losses.

Could you verify which version of X2 you have ? Maybe if old, there was such an issue. The other it can be market sells, but should work generally.

BillyYan13 commented 1 year ago

You can get the details for all the grinding buy/sell in the FreqUI

I can't find them. As I said those trades aren't closed yet. They're subtrades for two open trades. I would be grateful if there's a command that I can use on the terminal to recall all those subtrades. P.S. I user docker-compose

BillyYan13 commented 1 year ago

Grinding keeps selling at lower price than open rate. My bot has already traded over 30 trades with grinding for two open trades; all of them ended up with losses.

Could you verify which version of X2 you have ? Maybe if old, there was such an issue. The other it can be market sells, but should work generally.

I keep updating my NFIX2 daily. I get emails with the updates and do update it accordingly. My last update was last night.

dida1990 commented 1 year ago

Those are no losses. The percentage Telegram shows you is incorrect! Check on Frequi -> Trade -> Your pair. You will see an entry at a specific rate with a specific amount. You will see an exit further down with the same amount, but a higher rate. Therefore that partial trade has been a profit, but the way Freqtrade functions it is shown as a loss ;)

BillyYan13 commented 1 year ago

Those are no losses. The percentage Telegram shows you is incorrect! Check on Frequi -> Trade -> Your pair. You will see an entry at a specific rate with a specific amount. You will see an exit further down with the same amount, but a higher rate. Therefore that partial trade has been a profit, but the way Freqtrade functions it is shown as a loss ;)

So how do you explain the discrepancies between the minus profit amount on Binance and the bot?

ID Pair Since Profit (USD) # Entries


202 QTUM/USDT 2 weeks -13.02% (-241.69) 7 217 DYDX/USDT 5 d -11.96% (-7211.85) 19 224 IMX/USDT 5 min -0.61% (-203.01) 1


Total -7656.55 USD

photo1678303869

PS I can see my pairs and closed trades on FreqUI. The issue is those trades are still open and I can't recall the sub-trades history (the grinded amounts)

dida1990 commented 1 year ago

You are talking about 2 different things here: Yes the trade in general is going down, however not a loss, as the trade is still open... Open trades are not counting towards gain/loss, they are increasing/decreasing your wallet/balance though.

You are talking about partial exits, those are actually partial wins because the shown percentage ("sub-profit") is miscalculated.

However, in your last post you are talking about a wallet decrease because the trade is going down -> that is correct, but no loss until the trade closes

BillyYan13 commented 1 year ago

You are talking about 2 different things here:

Yes the trade in general is going down, however not a loss, as the trade is still open... Open trades are not counting towards gain/loss, they are increasing/decreasing your wallet/balance though.

You are talking about partial exits, those are actually partial wins because the shown percentage ("sub-profit") is miscalculated.

However, in your last post you are talking about a wallet decrease because the trade is going down -> that is correct, but no loss until the trade closes

Thanks once again for the explanation. As far as I know, my wallet decreased before as much as the bot has shown me, how much minus profit I have. Now there's about 3000$ difference. My wallet has only open trades through NFIX2. I mean the amount still doesn't fit. Anyway, I think I have to wait until the bot closes the trade completely to judge. Let's see what happens.

I think the miscalculation of "sub-profits" should be reported to Freqtrade to have it fixed.

iterativv commented 1 year ago

I think the miscalculation of "sub-profits" should be reported to Freqtrade to have it fixed.

Technically is correct. Example, we buy 1000 at 100 rate. Then it drops to 90, we buy another 1000. The open rate is 95 now. We go up to 92 and we sell 1000. On the last buy we make profit. But overall, because the open rate is 95 and we sold at 92 it's a loss. To break even now we have to go higher than 95, to 98 or so, but not to 100 (the original buy rate).

DYDX was not a good trade and at the time the grinding was not perfected enough. But it looks now found support, so we wait for that, as long as there is chance to make it. Remember to update X2 with the latest too.

BillyYan13 commented 1 year ago

I think the miscalculation of "sub-profits" should be reported to Freqtrade to have it fixed.

Technically is correct. Example, we buy 1000 at 100 rate. Then it drops to 90, we buy another 1000. The open rate is 95 now. We go up to 92 and we sell 1000. On the last buy we make profit. But overall, because the open rate is 95 and we sold at 92 it's a loss. To break even now we have to go higher than 95, to 98 or so, but not to 100 (the original buy rate).

DYDX was not a good trade and at the time the grinding was not perfected enough. But it looks now found support, so we wait for that, as long as there is chance to make it. Remember to update X2 with the latest too.

Thanks again for the reply. So one of the trades I had with the grinding feature closed with loss. Here are the details. I know that reason of existing is stop loss.

❌ Binance: Partially exited QTUM/USDT (#202) Sub Profit: -19.55% (loss: -362.62620588 USDT / -364.802 USD) Cumulative Profit: (-409.78264744 USDT / -412.241 USD) Enter Tag: 57 Exit Reason: exit_normal_bull_stoploss_u_e_m ( 57 ) Direction: Long Amount: 573.40000000 Open Rate: 3.23230742 Exit Rate: 2.60573143 Remaining: (0.82 USDT, 0.825 USD)

BillyYan13 commented 1 year ago

DYDX was not a good trade and at the time the grinding was not perfected enough. But it looks now found support, so we wait for that, as long as there is chance to make it. Remember to update X2 with the latest too.

Update: Guys, I do know my portfolio very well. the DYDX is getting worse on Binance using Grinding. Moreover Binance does not show the real losses in Status table. My pervious trade as I show you ended with loss. In my case, as I trade relatively large volumes. I use in my config "exit": "market" not "limit". Until now it caused a few losses with normal trades without grinding. I don't know if that something to do with it.

My current open trades:

ID Pair Since Profit (USD) # Entries


202 QTUM/USDT 2 weeks -12.65% (-235.05) 7 217 DYDX/USDT 5 d -12.44% (-7505.53) 19 224 IMX/USDT 1 h -1.42% (-475.89) 1


Total -8216.47 USD

And here is the DYDX that was opened with Freqtrade and since then grinded frequently until this moment.

photo1678531473

Notice the huge discrepancy between "Profits" on Binance and in "status table" of Freqtrade. It's around -9000 euros not documented on Freqtrade status table. Otherwise it does show in Roi: All trades

ROI: All trades ∙ -3840.272 USDT (0.10%) (-3.29 Σ%) ∙ -3851.793 USD

I'm not a newbie trader and I am sure that this trade is losing because of grinding! I do update the strategy daily with every new update.

iterativv commented 1 year ago

DYDX as I mentioned was not a great trade to begin with. And the first grinds occurred with the old version of the method.

Can you confirm that the grind buys are 1/4 of the original stake ? Also, the X2 version you are using now ?

Telegram will show 99% as loss those "partial_exit", I explained why. But you can check the coin amount bought, sell and the rates for those buys and sell. It always starts selling the last buy, then the previous one and so on.

BillyYan13 commented 1 year ago

DYDX as I mentioned was not a great trade to begin with. And the first grinds occurred with the old version of the method.

Yes, that's true. However DYDX was opened on March, 2nd. Since then I daily updated the NFIX2 with every small rework you guys undergo on NFIX2. Still despite the constant updates, the performance didn't get better. One the contrary loss increased and the discrepancy between what the bot shows and what binance shows got more bigger,

Can you confirm that the grind buys are 1/4 of the original stake ? Also, the X2 version you are using now ?

Yes, it does buy with 1/4 of the original stake. I use v12.0.263 I last updated yesterday about 19 hours ago. Along with your latest rework.

Telegram will show 99% as loss those "partial_exit", I explained why. But you can check the coin amount bought, sell and the rates for those buys and sell. It always starts selling the last buy, then the previous one and so on.

I will try to go through all of the trades and check them all. If the difference between exist rates aren't huge, then a lot of money will be wasted as trading fees, which might lead to losses.

iterativv commented 1 year ago

I will try to go through all of the trades and check them all. If the difference between exist rates aren't huge, then a lot of money will be wasted as trading fees, which might lead to losses.

You use market orders or orderbook maybe ? Though from this: 'Grinding exit DYDX/USDT | Rate: 2.254 | Stake amount: 8248.64824| Coin amount: 3659.56 | Total profit: -9.20% | Grind profit: 1.21%" then check the exit rate above from FT too. Rate: 2.254 is the rate that I calculate and there is match with the exit notification from FT. That is 1.21% higher than the respective entry.

It's 1%+ higher than entry.

iterativv commented 1 year ago

DYDX trade exited with profit, for those that had grinding on. Yes, back at the start there was a bug. an update caused it, and caused to exit there for some others. That fixed.

All right, I am closing this now. If you like, open a new issue with more questions or join discord to discuss it there.

BillyYan13 commented 1 year ago

DYDX trade exited with profit, for those that had grinding on. Yes, back at the start there was a bug. an update caused it, and caused to exit there for some others. That fixed.

All right, I am closing this now. If you like, open a new issue with more questions or join discord to discuss it there.

Thanks for your help during this. I wanted to share my feed back here anyway, even if the issue was closed. So DYDX did close with profit. Still upon watching it closely Freqtrade miscalculated the profit with comparison to the real profit on Binance. I want to point out to another smaller issue; that the trade could've closed with better profit than it did. DYDX reached a rate of 2,77 USDT but decided to sell at 2,53 USDT later.

Anyway, I'm happy and satisfied with the result. Grinding helped massively after the latest updates. Thanks for your help once again. 😊