From bbcf3d35cee4b1a2abd97e5cdeb2fecfe396c477 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Wed, 14 Jul 2021 18:22:36 +0100 Subject: [PATCH] Changed the way SimpleMarketMaker calculates position sizes to be in line with what it has on each side instead of the total. --- mango/marketmaking/simplemarketmaker.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mango/marketmaking/simplemarketmaker.py b/mango/marketmaking/simplemarketmaker.py index 5e3879e..9914831 100644 --- a/mango/marketmaking/simplemarketmaker.py +++ b/mango/marketmaking/simplemarketmaker.py @@ -82,6 +82,7 @@ class SimpleMarketMaker: price = self.oracle.fetch_price(self.context) self.logger.info(f"Price is: {price}") inventory = self.fetch_inventory() + print(inventory) # Calculate what we want the orders to be. bid, ask = self.calculate_order_prices(price) @@ -163,11 +164,8 @@ class SimpleMarketMaker: if quote_tokens is None: raise Exception(f"Could not find market-maker quote token {price.market.quote.symbol} in inventory.") - total = (base_tokens.value * price.mid_price) + quote_tokens.value - position_size = total * self.position_size_ratio - - buy_size = position_size / price.mid_price - sell_size = position_size / price.mid_price + buy_size = base_tokens.value * self.position_size_ratio + sell_size = (quote_tokens.value / price.mid_price) * self.position_size_ratio return (buy_size, sell_size) def orders_require_action(self, orders: typing.Sequence[mango.Order], price: Decimal, size: Decimal) -> bool: