introduction of new config with docs
This commit is contained in:
parent
d457d43999
commit
c77a6addf5
@ -13,6 +13,7 @@
|
|||||||
},
|
},
|
||||||
"bid_strategy": {
|
"bid_strategy": {
|
||||||
"ask_last_balance": 0.0,
|
"ask_last_balance": 0.0,
|
||||||
|
"timeout_even_if_buy_signal_valid": true,
|
||||||
"use_order_book": false,
|
"use_order_book": false,
|
||||||
"order_book_top": 1,
|
"order_book_top": 1,
|
||||||
"check_depth_of_market": {
|
"check_depth_of_market": {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
},
|
},
|
||||||
"bid_strategy": {
|
"bid_strategy": {
|
||||||
"use_order_book": false,
|
"use_order_book": false,
|
||||||
|
"timeout_even_if_buy_signal_valid": true,
|
||||||
"ask_last_balance": 0.0,
|
"ask_last_balance": 0.0,
|
||||||
"order_book_top": 1,
|
"order_book_top": 1,
|
||||||
"check_depth_of_market": {
|
"check_depth_of_market": {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
},
|
},
|
||||||
"bid_strategy": {
|
"bid_strategy": {
|
||||||
"use_order_book": false,
|
"use_order_book": false,
|
||||||
|
"timeout_even_if_buy_signal_valid": true,
|
||||||
"ask_last_balance": 0.0,
|
"ask_last_balance": 0.0,
|
||||||
"order_book_top": 1,
|
"order_book_top": 1,
|
||||||
"check_depth_of_market": {
|
"check_depth_of_market": {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
},
|
},
|
||||||
"bid_strategy": {
|
"bid_strategy": {
|
||||||
"use_order_book": false,
|
"use_order_book": false,
|
||||||
|
"timeout_even_if_buy_signal_valid": true,
|
||||||
"ask_last_balance": 0.0,
|
"ask_last_balance": 0.0,
|
||||||
"order_book_top": 1,
|
"order_book_top": 1,
|
||||||
"check_depth_of_market": {
|
"check_depth_of_market": {
|
||||||
|
@ -61,6 +61,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi
|
|||||||
| `unfilledtimeout.buy` | **Required.** How long (in minutes) the bot will wait for an unfilled buy order to complete, after which the order will be cancelled. [Strategy Override](#parameters-in-the-strategy).<br> ***Datatype:*** *Integer*
|
| `unfilledtimeout.buy` | **Required.** How long (in minutes) the bot will wait for an unfilled buy order to complete, after which the order will be cancelled. [Strategy Override](#parameters-in-the-strategy).<br> ***Datatype:*** *Integer*
|
||||||
| `unfilledtimeout.sell` | **Required.** How long (in minutes) the bot will wait for an unfilled sell order to complete, after which the order will be cancelled. [Strategy Override](#parameters-in-the-strategy).<br> ***Datatype:*** *Integer*
|
| `unfilledtimeout.sell` | **Required.** How long (in minutes) the bot will wait for an unfilled sell order to complete, after which the order will be cancelled. [Strategy Override](#parameters-in-the-strategy).<br> ***Datatype:*** *Integer*
|
||||||
| `bid_strategy.ask_last_balance` | **Required.** Set the bidding price. More information [below](#buy-price-without-orderbook).
|
| `bid_strategy.ask_last_balance` | **Required.** Set the bidding price. More information [below](#buy-price-without-orderbook).
|
||||||
|
| `bid_strategy.timeout_even_if_buy_signal_valid` | **Required.** Choose whether you would prefer buy orders to [timeout even if buy signal was still valid](#timeout-even-if-buy-signal-valid). If false, your buy orders will not timeout and will ignore your unfilledtimeout for buy orders, so use this option wisely. <br>*Defaults to `true`.* <br> ***Datatype:*** *Boolean*
|
||||||
| `bid_strategy.use_order_book` | Enable buying using the rates in [Order Book Bids](#buy-price-with-orderbook-enabled). <br> ***Datatype:*** *Boolean*
|
| `bid_strategy.use_order_book` | Enable buying using the rates in [Order Book Bids](#buy-price-with-orderbook-enabled). <br> ***Datatype:*** *Boolean*
|
||||||
| `bid_strategy.order_book_top` | Bot will use the top N rate in Order Book Bids to buy. I.e. a value of 2 will allow the bot to pick the 2nd bid rate in [Order Book Bids](#buy-price-with-orderbook-enabled). <br>*Defaults to `1`.* <br> ***Datatype:*** *Positive Integer*
|
| `bid_strategy.order_book_top` | Bot will use the top N rate in Order Book Bids to buy. I.e. a value of 2 will allow the bot to pick the 2nd bid rate in [Order Book Bids](#buy-price-with-orderbook-enabled). <br>*Defaults to `1`.* <br> ***Datatype:*** *Positive Integer*
|
||||||
| `bid_strategy. check_depth_of_market.enabled` | Do not buy if the difference of buy orders and sell orders is met in Order Book. [Check market depth](#check-depth-of-market). <br>*Defaults to `false`.* <br> ***Datatype:*** *Boolean*
|
| `bid_strategy. check_depth_of_market.enabled` | Do not buy if the difference of buy orders and sell orders is met in Order Book. [Check market depth](#check-depth-of-market). <br>*Defaults to `false`.* <br> ***Datatype:*** *Boolean*
|
||||||
|
@ -76,7 +76,7 @@ CONF_SCHEMA = {
|
|||||||
'amend_last_stake_amount': {'type': 'boolean', 'default': False},
|
'amend_last_stake_amount': {'type': 'boolean', 'default': False},
|
||||||
'last_stake_amount_min_ratio': {
|
'last_stake_amount_min_ratio': {
|
||||||
'type': 'number', 'minimum': 0.0, 'maximum': 1.0, 'default': 0.5
|
'type': 'number', 'minimum': 0.0, 'maximum': 1.0, 'default': 0.5
|
||||||
},
|
},
|
||||||
'fiat_display_currency': {'type': 'string', 'enum': SUPPORTED_FIAT},
|
'fiat_display_currency': {'type': 'string', 'enum': SUPPORTED_FIAT},
|
||||||
'dry_run': {'type': 'boolean'},
|
'dry_run': {'type': 'boolean'},
|
||||||
'dry_run_wallet': {'type': 'number', 'default': DRY_RUN_WALLET},
|
'dry_run_wallet': {'type': 'number', 'default': DRY_RUN_WALLET},
|
||||||
@ -109,15 +109,16 @@ CONF_SCHEMA = {
|
|||||||
'minimum': 0,
|
'minimum': 0,
|
||||||
'maximum': 1,
|
'maximum': 1,
|
||||||
'exclusiveMaximum': False,
|
'exclusiveMaximum': False,
|
||||||
'use_order_book': {'type': 'boolean'},
|
},
|
||||||
'order_book_top': {'type': 'integer', 'maximum': 20, 'minimum': 1},
|
'timeout_even_if_buy_signal_valid': {'type': 'boolean'},
|
||||||
'check_depth_of_market': {
|
'use_order_book': {'type': 'boolean'},
|
||||||
'type': 'object',
|
'order_book_top': {'type': 'integer', 'maximum': 20, 'minimum': 1},
|
||||||
'properties': {
|
'check_depth_of_market': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
'enabled': {'type': 'boolean'},
|
'enabled': {'type': 'boolean'},
|
||||||
'bids_to_ask_delta': {'type': 'number', 'minimum': 0},
|
'bids_to_ask_delta': {'type': 'number', 'minimum': 0},
|
||||||
}
|
}
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'required': ['ask_last_balance']
|
'required': ['ask_last_balance']
|
||||||
|
@ -845,44 +845,58 @@ class FreqtradeBot:
|
|||||||
:return: True if order was fully cancelled
|
:return: True if order was fully cancelled
|
||||||
"""
|
"""
|
||||||
reason = "cancelled due to timeout"
|
reason = "cancelled due to timeout"
|
||||||
if order['status'] != 'canceled':
|
|
||||||
corder = self.exchange.cancel_order(trade.open_order_id, trade.pair)
|
|
||||||
else:
|
|
||||||
# Order was cancelled already, so we can reuse the existing dict
|
|
||||||
corder = order
|
|
||||||
reason = "canceled on Exchange"
|
|
||||||
|
|
||||||
if corder.get('remaining', order['remaining']) == order['amount']:
|
# running get_signal on historical data fetched
|
||||||
# if trade is not partially completed, just delete the trade
|
(buy, sell) = self.strategy.get_signal(
|
||||||
self.handle_buy_order_full_cancel(trade, reason)
|
trade.pair, self.strategy.ticker_interval,
|
||||||
return True
|
self.dataprovider.ohlcv(trade.pair, self.strategy.ticker_interval))
|
||||||
|
|
||||||
# if trade is partially complete, edit the stake details for the trade
|
# get config for bid strategy
|
||||||
# and close the order
|
config_bid_strategy = self.config.get('bid_strategy', {})
|
||||||
# cancel_order may not contain the full order dict, so we need to fallback
|
|
||||||
# to the order dict aquired before cancelling.
|
|
||||||
# we need to fall back to the values from order if corder does not contain these keys.
|
|
||||||
trade.amount = order['amount'] - corder.get('remaining', order['remaining'])
|
|
||||||
trade.stake_amount = trade.amount * trade.open_rate
|
|
||||||
# verify if fees were taken from amount to avoid problems during selling
|
|
||||||
try:
|
|
||||||
new_amount = self.get_real_amount(trade, corder if 'fee' in corder else order,
|
|
||||||
trade.amount)
|
|
||||||
if not isclose(order['amount'], new_amount, abs_tol=constants.MATH_CLOSE_PREC):
|
|
||||||
trade.amount = new_amount
|
|
||||||
# Fee was applied, so set to 0
|
|
||||||
trade.fee_open = 0
|
|
||||||
trade.recalc_open_trade_price()
|
|
||||||
except DependencyException as e:
|
|
||||||
logger.warning("Could not update trade amount: %s", e)
|
|
||||||
|
|
||||||
trade.open_order_id = None
|
# proceed to cancel buy order by timeout if timeout_even_if_buy_signal_valid
|
||||||
logger.info('Partial buy order timeout for %s.', trade)
|
# is true (original behaviour) -OR-
|
||||||
self.rpc.send_msg({
|
# cancel buy order only if buying condition is no longer valid OR if there's
|
||||||
'type': RPCMessageType.STATUS_NOTIFICATION,
|
# a sell signal present
|
||||||
'status': f'Remaining buy order for {trade.pair} cancelled due to timeout'
|
if config_bid_strategy.get('timeout_even_if_buy_signal_valid', True) or (not buy or sell):
|
||||||
})
|
if order['status'] != 'canceled':
|
||||||
return False
|
corder = self.exchange.cancel_order(trade.open_order_id, trade.pair)
|
||||||
|
else:
|
||||||
|
# Order was cancelled already, so we can reuse the existing dict
|
||||||
|
corder = order
|
||||||
|
reason = "canceled on exchange"
|
||||||
|
|
||||||
|
if corder.get('remaining', order['remaining']) == order['amount']:
|
||||||
|
# if trade is not partially completed, just delete the trade
|
||||||
|
self.handle_buy_order_full_cancel(trade, reason)
|
||||||
|
return True
|
||||||
|
|
||||||
|
# if trade is partially complete, edit the stake details for the trade
|
||||||
|
# and close the order
|
||||||
|
# cancel_order may not contain the full order dict, so we need to fallback
|
||||||
|
# to the order dict aquired before cancelling.
|
||||||
|
# we need to fall back to the values from order if corder does not contain these keys.
|
||||||
|
trade.amount = order['amount'] - corder.get('remaining', order['remaining'])
|
||||||
|
trade.stake_amount = trade.amount * trade.open_rate
|
||||||
|
# verify if fees were taken from amount to avoid problems during selling
|
||||||
|
try:
|
||||||
|
new_amount = self.get_real_amount(trade, corder if 'fee' in corder else order,
|
||||||
|
trade.amount)
|
||||||
|
if not isclose(order['amount'], new_amount, abs_tol=constants.MATH_CLOSE_PREC):
|
||||||
|
trade.amount = new_amount
|
||||||
|
# Fee was applied, so set to 0
|
||||||
|
trade.fee_open = 0
|
||||||
|
trade.recalc_open_trade_price()
|
||||||
|
except DependencyException as e:
|
||||||
|
logger.warning("Could not update trade amount: %s", e)
|
||||||
|
|
||||||
|
trade.open_order_id = None
|
||||||
|
logger.info(f"Partial buy order timeout for {trade.pair}")
|
||||||
|
self.rpc.send_msg({
|
||||||
|
'type': RPCMessageType.STATUS_NOTIFICATION,
|
||||||
|
'status': f"Remaining buy order for {trade.pair} cancelled due to timeout"
|
||||||
|
})
|
||||||
|
return False
|
||||||
|
|
||||||
def handle_timedout_limit_sell(self, trade: Trade, order: Dict) -> bool:
|
def handle_timedout_limit_sell(self, trade: Trade, order: Dict) -> bool:
|
||||||
"""
|
"""
|
||||||
|
@ -216,6 +216,7 @@ def default_conf(testdatadir):
|
|||||||
},
|
},
|
||||||
"bid_strategy": {
|
"bid_strategy": {
|
||||||
"ask_last_balance": 0.0,
|
"ask_last_balance": 0.0,
|
||||||
|
"timeout_even_if_buy_signal_valid": True,
|
||||||
"use_order_book": False,
|
"use_order_book": False,
|
||||||
"order_book_top": 1,
|
"order_book_top": 1,
|
||||||
"check_depth_of_market": {
|
"check_depth_of_market": {
|
||||||
|
Loading…
Reference in New Issue
Block a user