From fa912160529479f3b6bbf1ba33f3c5305e4a25fd Mon Sep 17 00:00:00 2001 From: fibonacci998 Date: Tue, 15 Oct 2024 13:50:28 +0700 Subject: [PATCH] feat: update strategy --- scripts/create_mid_volumn.py | 42 ++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/scripts/create_mid_volumn.py b/scripts/create_mid_volumn.py index c8a18cd56e..52cb412382 100644 --- a/scripts/create_mid_volumn.py +++ b/scripts/create_mid_volumn.py @@ -53,20 +53,34 @@ def on_tick(self): self.logger().info(f"Mid price: {mid_price}") if (self.numberBuyOrder == 0 & self.numberSellOrder == 0): amount = Decimal(random.randint(self.config.minimum_amount_limit, self.config.maximum_amount_limit)) - self.buy(connector_name=connector_name, - amount=amount, - trading_pair=self.config.trading_pair, - order_type=OrderType.LIMIT, - price=mid_price, - ) - self.numberBuyOrder += 1 - self.sell(connector_name=connector_name, - amount=amount, - trading_pair=self.config.trading_pair, - order_type=OrderType.LIMIT, - price=mid_price) - self.numberSellOrder += 1 - + if (bool(random.getrandbits(1))): + self.buy(connector_name=connector_name, + amount=amount, + trading_pair=self.config.trading_pair, + order_type=OrderType.LIMIT, + price=mid_price, + ) + self.numberBuyOrder += 1 + self.sell(connector_name=connector_name, + amount=amount, + trading_pair=self.config.trading_pair, + order_type=OrderType.LIMIT, + price=mid_price) + self.numberSellOrder += 1 + else: + self.sell(connector_name=connector_name, + amount=amount, + trading_pair=self.config.trading_pair, + order_type=OrderType.LIMIT, + price=mid_price) + self.numberSellOrder += 1 + self.buy(connector_name=connector_name, + amount=amount, + trading_pair=self.config.trading_pair, + order_type=OrderType.LIMIT, + price=mid_price, + ) + self.numberBuyOrder += 1 cron = croniter.croniter(self.config.cron_expression, current_time) self.next_time = cron.get_next() self.logger().debug(f"Next time is {self.next_time}")