Merge pull request #1632 from iuvbio/update_docs

update sql_cheatsheet
This commit is contained in:
Matthias 2019-03-08 22:19:44 +01:00 committed by GitHub
commit 21cb4eafe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,6 +44,14 @@ CREATE TABLE trades (
open_date DATETIME NOT NULL, open_date DATETIME NOT NULL,
close_date DATETIME, close_date DATETIME,
open_order_id VARCHAR, open_order_id VARCHAR,
stop_loss FLOAT,
initial_stop_loss FLOAT,
stoploss_order_id VARCHAR,
stoploss_last_update DATETIME,
max_rate FLOAT,
sell_reason VARCHAR,
strategy VARCHAR,
ticker_interval INTEGER,
PRIMARY KEY (id), PRIMARY KEY (id),
CHECK (is_open IN (0, 1)) CHECK (is_open IN (0, 1))
); );
@ -55,38 +63,45 @@ CREATE TABLE trades (
SELECT * FROM trades; SELECT * FROM trades;
``` ```
## Fix trade still open after a /forcesell ## Fix trade still open after a manual sell on the exchange
!!! Warning:
Manually selling on the exchange should not be done by default, since the bot does not detect this and will try to sell anyway.
/foresell <tradeid> should accomplish the same thing.
!!! Note:
This should not be necessary after /forcesell, as forcesell orders are closed automatically by the bot on the next iteration.
```sql ```sql
UPDATE trades UPDATE trades
SET is_open=0, close_date=<close_date>, close_rate=<close_rate>, close_profit=close_rate/open_rate-1 SET is_open=0, close_date=<close_date>, close_rate=<close_rate>, close_profit=close_rate/open_rate-1, sell_reason=<sell_reason>
WHERE id=<trade_ID_to_update>; WHERE id=<trade_ID_to_update>;
``` ```
**Example:** ##### Example
```sql ```sql
UPDATE trades UPDATE trades
SET is_open=0, close_date='2017-12-20 03:08:45.103418', close_rate=0.19638016, close_profit=0.0496 SET is_open=0, close_date='2017-12-20 03:08:45.103418', close_rate=0.19638016, close_profit=0.0496, sell_reason='force_sell'
WHERE id=31; WHERE id=31;
``` ```
## Insert manually a new trade ## Insert manually a new trade
```sql ```sql
INSERT INSERT INTO trades (exchange, pair, is_open, fee_open, fee_close, open_rate, stake_amount, amount, open_date)
INTO trades (exchange, pair, is_open, fee_open, fee_close, open_rate, stake_amount, amount, open_date) VALUES ('bittrex', 'ETH/BTC', 1, 0.0025, 0.0025, <open_rate>, <stake_amount>, <amount>, '<datetime>')
VALUES ('BITTREX', 'BTC_<COIN>', 1, 0.0025, 0.0025, <open_rate>, <stake_amount>, <amount>, '<datetime>')
``` ```
**Example:** ##### Example:
```sql ```sql
INSERT INTO trades (exchange, pair, is_open, fee_open, fee_close, open_rate, stake_amount, amount, open_date) VALUES ('BITTREX', 'BTC_ETC', 1, 0.0025, 0.0025, 0.00258580, 0.002, 0.7715262081, '2017-11-28 12:44:24.000000') INSERT INTO trades (exchange, pair, is_open, fee_open, fee_close, open_rate, stake_amount, amount, open_date)
VALUES ('bittrex', 'ETH/BTC', 1, 0.0025, 0.0025, 0.00258580, 0.002, 0.7715262081, '2017-11-28 12:44:24.000000')
``` ```
## Fix wrong fees in the table ## Fix wrong fees in the table
If your DB was created before If your DB was created before [PR#200](https://github.com/freqtrade/freqtrade/pull/200) was merged (before 12/23/17).
[PR#200](https://github.com/freqtrade/freqtrade/pull/200) was merged
(before 12/23/17).
```sql ```sql
UPDATE trades SET fee=0.0025 WHERE fee=0.005; UPDATE trades SET fee=0.0025 WHERE fee=0.005;