Update price timeout example

This commit is contained in:
Matthias 2020-04-25 17:25:18 +02:00
parent 431b244f43
commit 255a43c98e

View File

@ -56,7 +56,6 @@ class Awesomestrategy(IStrategy):
!!! Note !!! Note
For the above example, `unfilledtimeout` must be set to something bigger than 24h, otherwise that type of timeout will apply first. For the above example, `unfilledtimeout` must be set to something bigger than 24h, otherwise that type of timeout will apply first.
### Custom order timeout example (using additional data) ### Custom order timeout example (using additional data)
``` python ``` python
@ -77,7 +76,7 @@ class Awesomestrategy(IStrategy):
ob = self.dp.orderbook(pair, 1) ob = self.dp.orderbook(pair, 1)
current_price = ob['bids'][0][0] current_price = ob['bids'][0][0]
# Cancel buy order if price is more than 2% above the order. # Cancel buy order if price is more than 2% above the order.
if order['price'] > current_price * 1.02: if current_price > order['price'] * 1.02:
return True return True
return False return False
@ -86,7 +85,7 @@ class Awesomestrategy(IStrategy):
ob = self.dp.orderbook(pair, 1) ob = self.dp.orderbook(pair, 1)
current_price = ob['asks'][0][0] current_price = ob['asks'][0][0]
# Cancel sell order if price is more than 2% below the order. # Cancel sell order if price is more than 2% below the order.
if order['price'] < current_price * 0.98: if current_price < order['price'] * 0.98:
return True return True
return False return False
``` ```