Freqtrade: Recorded value for sell is not correct. - FTX leveraged tokens

Created on 2 Jun 2020  路  3Comments  路  Source: freqtrade/freqtrade

Describe your environment

  • Operating system: Ubuntu 19.10
  • Python Version: 3.8
  • CCXT version: 1.27.85
  • Freqtrade Version: freqtrade develop-003724e4

Note: All issues other than enhancement requests will be closed without further comment if the above template is deleted or not filled out.

Describe the problem:

The bot buys accurately but has different value when selling.

Steps to reproduce:

  1. Run on FTX leveraged tokens
  2. Run on LIVE mode and not dry-run
  3. wait

Observed Results:

  • What happened? The bot bought market

```Ftx: Buying THETABULL/USD
Amount: 0.17013233
Open Rate: 1587.00000000
Current Rate: 1587.00000000
Total: (270.000000 USD, 270.000 USD)

Close message:

```Ftx: Selling THETABULL/USD
Amount: 0.17010000
Open Rate: 1616.00000000
Current Rate: 1750.00000000
Close Rate: 1750.00000000
Sell Reason: roi
Duration: 0:04:32 (4.5 min)
Profit: 8.17% (profit: 22.47683346 USD / 22.477 USD)
  • What did you expect to happen? The close rate to be the same as actual close. There's a difference. I use market sell to close and the bot closed at 1715.5. I understand there's significant spread on these pairs but shouldnt freqtrade record the actual sell price rather than mark price?

Relevant code exceptions or logs

Note: Please copy/paste text of the messages, no screenshots of logs please.

2020-06-02 01:00:44,379 - freqtrade.freqtradebot - INFO - Executing Buy for THETABULL/USD 2020-06-02 01:00:44,379 - freqtrade.freqtradebot - INFO - Using Last Bid / Last Price 2020-06-02 01:00:44,668 - freqtrade.wallets - INFO - Wallets synced. 2020-06-02 01:00:44,671 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: {'type': buy, 'exchange': 'Ftx', 'pair': 'THETABULL/USD', 'limit': 1587.0, 'order_type': 'market', 'stake_amount': 270.0, 'stake_currency': 'USD', 'fiat_currency': 'USD', 'amount': 0.17013232514177692, 'open_date': datetime.datetime(2020, 6, 2, 1, 0, 44, 597306), 'current_rate': 1587.0} 2020-06-02 01:00:45,110 - freqtrade.freqtradebot - INFO - Found open order for Trade(id=47, pair=THETABULL/USD, amount=0.17013233, open_rate=1587.00000000, open_since=2020-06-02 01:00:44) 2020-06-02 01:00:45,319 - freqtrade.wallets - INFO - Wallets synced. 2020-06-02 01:00:45,319 - freqtrade.freqtradebot - INFO - Fee amount for Trade(id=47, pair=THETABULL/USD, amount=0.17013233, open_rate=1587.00000000, open_since=2020-06-02 01:00:44) was in base currency - Eating Fee 9.404829e-05 into dust. 2020-06-02 01:00:45,319 - freqtrade.persistence - INFO - Updating trade (id=47) ... 2020-06-02 01:00:45,320 - freqtrade.persistence - INFO - MARKET_BUY has been fulfilled for Trade(id=47, pair=THETABULL/USD, amount=0.17010000, open_rate=1616.00000000, open_since=2020-06-02 01:00:44). 2020-06-02 01:01:00,070 - freqtrade.worker - INFO - Bot heartbeat. PID=82947, version='develop-003724e4', state='RUNNING' 2020-06-02 01:02:00,103 - freqtrade.worker - INFO - Bot heartbeat. PID=82947, version='develop-003724e4', state='RUNNING' 2020-06-02 01:03:00,139 - freqtrade.worker - INFO - Bot heartbeat. PID=82947, version='develop-003724e4', state='RUNNING' 2020-06-02 01:04:00,175 - freqtrade.worker - INFO - Bot heartbeat. PID=82947, version='develop-003724e4', state='RUNNING' 2020-06-02 01:05:00,215 - freqtrade.worker - INFO - Bot heartbeat. PID=82947, version='develop-003724e4', state='RUNNING' 2020-06-02 01:05:16,576 - freqtrade.freqtradebot - INFO - Executing Sell for THETABULL/USD. Reason: SellType.ROI 2020-06-02 01:05:16,685 - freqtrade.wallets - INFO - Wallets synced. 2020-06-02 01:05:16,821 - freqtrade.freqtradebot - INFO - Using cached sell rate for THETABULL/USD. 2020-06-02 01:05:16,822 - freqtrade.rpc.rpc_manager - INFO - Sending rpc message: {'type': sell, 'exchange': 'Ftx', 'pair': 'THETABULL/USD', 'gain': 'profit', 'limit': 1750.0, 'order_type': 'market', 'amount': 0.1701, 'open_rate': 1616.0, 'current_rate': 1750.0, 'profit_amount': 22.47683346, 'profit_ratio': 0.08172396, 'sell_reason': 'roi', 'open_date': datetime.datetime(2020, 6, 2, 1, 0, 44, 597306), 'close_date': datetime.datetime(2020, 6, 2, 1, 5, 16, 822253), 'stake_currency': 'USD', 'fiat_currency': 'USD'} 2020-06-02 01:05:17,263 - freqtrade.wallets - INFO - Wallets synced. 2020-06-02 01:05:20,286 - freqtrade.freqtradebot - INFO - Found open order for Trade(id=47, pair=THETABULL/USD, amount=0.17010000, open_rate=1616.00000000, open_since=2020-06-02 01:00:44) 2020-06-02 01:05:20,398 - freqtrade.persistence - INFO - Updating trade (id=47) ... 2020-06-02 01:05:20,398 - freqtrade.persistence - INFO - Marking Trade(id=47, pair=THETABULL/USD, amount=0.17010000, open_rate=1616.00000000, open_since=closed) as closed as the trade is fulfilled and found no open orders for it. 2020-06-02 01:05:20,398 - freqtrade.persistence - INFO - MARKET_SELL has been fulfilled for Trade(id=47, pair=THETABULL/USD, amount=0.17010000, open_rate=1616.00000000, open_since=closed).

Triage Needed

Most helpful comment

Sorry,I forgot to post it. I verified on the database. Will post log tomorrow

All 3 comments

I think we need to be careful with wording - one thing is sending the notification (which is what we're talking about) - and one thing is "recording" - which is how it's in the database.

freqtrade sends the message when it places the sell order.

Depending on the API, the response to the order posting will contain the filled price (works for market orders on binance ...) - but may not work for FTX (did not test that yet).
If the filled price IS contained, then that price will be used for the notificat, otherwise the price used to post the order (which corresponds to "current_sell_rate" - as configured in "ask_stategy").

Anyhow - upon closing the order, the final price WILL be updated in the database, as you'll see.

please post the output of the following command:

freqtrade show-trades --db-url sqlite:///pathtoyourdb.sqlite --trade-ids 47 --print-json

Sorry,I forgot to post it. I verified on the database. Will post log tomorrow

You are correct. It seems i got confused, the closed rate actually matches! sorry for the inconvenience, will close.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aak-dev picture aak-dev  路  4Comments

issamBD picture issamBD  路  4Comments

hroff-1902 picture hroff-1902  路  4Comments

macd2 picture macd2  路  4Comments

rraallvv picture rraallvv  路  3Comments