round exiting orders to be MARKET orders if the price diff is very tiny
This commit is contained in:
@@ -95,7 +95,7 @@ class Broker:
|
||||
|
||||
side = jh.opposite_side(jh.type_to_side(self.position.type))
|
||||
|
||||
if price == self.position.current_price:
|
||||
if abs(price - self.position.current_price) < 0.0001:
|
||||
return self.api.market_order(
|
||||
self.exchange,
|
||||
self.symbol,
|
||||
|
||||
@@ -5,6 +5,9 @@ class TestMarketOrderForLowPriceDifference(Strategy):
|
||||
def on_open_position(self, order):
|
||||
assert order.type == 'MARKET'
|
||||
|
||||
def on_close_position(self, order) -> None:
|
||||
assert order.type == 'MARKET'
|
||||
|
||||
def should_long(self) -> bool:
|
||||
return self.index == 0
|
||||
|
||||
@@ -15,6 +18,10 @@ class TestMarketOrderForLowPriceDifference(Strategy):
|
||||
# current-price: 1
|
||||
self.buy = 1, 1.00001
|
||||
|
||||
def update_position(self) -> None:
|
||||
# submit a take-profit order that has a low difference with the current price
|
||||
self.take_profit = self.position.qty, self.price + 0.00001
|
||||
|
||||
def go_short(self):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user