diff --git a/docs/sql_cheatsheet.md b/docs/sql_cheatsheet.md index 168d416ab..569af33ff 100644 --- a/docs/sql_cheatsheet.md +++ b/docs/sql_cheatsheet.md @@ -43,52 +43,6 @@ sqlite3 .schema ``` -### Trade table structure - -```sql -CREATE TABLE trades( - id INTEGER NOT NULL, - exchange VARCHAR NOT NULL, - pair VARCHAR NOT NULL, - is_open BOOLEAN NOT NULL, - fee_open FLOAT NOT NULL, - fee_open_cost FLOAT, - fee_open_currency VARCHAR, - fee_close FLOAT NOT NULL, - fee_close_cost FLOAT, - fee_close_currency VARCHAR, - open_rate FLOAT, - open_rate_requested FLOAT, - open_trade_price FLOAT, - close_rate FLOAT, - close_rate_requested FLOAT, - close_profit FLOAT, - close_profit_abs FLOAT, - stake_amount FLOAT NOT NULL, - amount FLOAT, - open_date DATETIME NOT NULL, - close_date DATETIME, - open_order_id VARCHAR, - stop_loss FLOAT, - stop_loss_pct FLOAT, - initial_stop_loss FLOAT, - initial_stop_loss_pct FLOAT, - stoploss_order_id VARCHAR, - stoploss_last_update DATETIME, - max_rate FLOAT, - min_rate FLOAT, - sell_reason VARCHAR, - strategy VARCHAR, - timeframe INTEGER, - PRIMARY KEY (id), - CHECK (is_open IN (0, 1)) -); -CREATE INDEX ix_trades_stoploss_order_id ON trades (stoploss_order_id); -CREATE INDEX ix_trades_pair ON trades (pair); -CREATE INDEX ix_trades_is_open ON trades (is_open); - -``` - ## Get all trades in the table ```sql @@ -98,11 +52,11 @@ SELECT * FROM trades; ## Fix trade still open after a manual sell on the exchange !!! 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. + 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. + This should not be necessary after /forcesell, as forcesell orders are closed automatically by the bot on the next iteration. ```sql UPDATE trades @@ -128,23 +82,12 @@ SET is_open=0, WHERE id=31; ``` -## Manually insert a new trade - -```sql -INSERT INTO trades (exchange, pair, is_open, fee_open, fee_close, open_rate, stake_amount, amount, open_date) -VALUES ('binance', 'ETH/BTC', 1, 0.0025, 0.0025, , , , '') -``` - -### Insert trade example - -```sql -INSERT INTO trades (exchange, pair, is_open, fee_open, fee_close, open_rate, stake_amount, amount, open_date) -VALUES ('binance', 'ETH/BTC', 1, 0.0025, 0.0025, 0.00258580, 0.002, 0.7715262081, '2020-06-28 12:44:24.000000') -``` - ## Remove trade from the database -Maybe you'd like to remove a trade from the database, because something went wrong. +!!! Tip "Use RPC Methods to delete trades" + Consider using `/delete ` 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. ```sql DELETE FROM trades WHERE id = ;