This page contains some help if you want to edit your sqlite db.
Sqlite3 is a terminal based sqlite application. Feel free to use a visual Database editor like SqliteBrowser if you feel more comfortable with that.
sudo apt-get install sqlite3
The freqtrade docker image does contain sqlite3, so you can edit the database without having to install anything on the host system.
docker-compose exec freqtrade /bin/bash
sqlite3 <databasefile>.sqlite
sqlite3
.open <filepath>
.tables
.schema <table_name>
SELECT * FROM trades;
!!! Warning
Manually selling a pair on the exchange will not be detected by the bot and it will try to sell anyway. Whenever possible, forcesell should be used to accomplish the same thing.
It is strongly advised to backup your database file before making any manual changes.
!!! Note This should not be necessary after /forcesell, as forcesell orders are closed automatically by the bot on the next iteration.
UPDATE trades
SET is_open=0,
close_date=<close_date>,
close_rate=<close_rate>,
close_profit = close_rate / open_rate - 1,
close_profit_abs = (amount * <close_rate> * (1 - fee_close) - (amount * (open_rate * (1 - fee_open)))),
sell_reason=<sell_reason>
WHERE id=<trade_ID_to_update>;
UPDATE trades
SET is_open=0,
close_date='2020-06-20 03:08:45.103418',
close_rate=0.19638016,
close_profit=0.0496,
close_profit_abs = (amount * 0.19638016 * (1 - fee_close) - (amount * (open_rate * (1 - fee_open)))),
sell_reason='force_sell'
WHERE id=31;
!!! Tip "Use RPC Methods to delete trades"
Consider using /delete <tradeid>
via telegram or rest API. That's the recommended way to deleting trades.
If you'd still like to remove a trade from the database directly, you can use the below query.
DELETE FROM trades WHERE id = <tradeid>;
DELETE FROM trades WHERE id = 31;
!!! Warning
This will remove this trade from the database. Please make sure you got the correct id and NEVER run this query without the where
clause.