Skip to content

Commit 8932ee6

Browse files
committed
chore: remove wrong alpha bot; move that logic to the basic market maker bot
1 parent f739db9 commit 8932ee6

3 files changed

Lines changed: 36 additions & 129 deletions

File tree

ctenex/bot/bots/alpha.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

ctenex/bot/orders_generators/alpha.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

ctenex/bot/orders_generators/basic.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class BasicOrdersGenerator(IOrdersGenerator):
14-
RANDOM_TICKS_FACTOR = 3 # TODO: increase complexity
14+
RANDOM_TICKS_FACTOR = 2 # Stay close to mid-price
1515
MIN_PROFIT_TICKS = 1 # Minimum number of ticks we want to profit from spread
1616

1717
def generate_orders(
@@ -26,28 +26,49 @@ def generate_orders(
2626
) -> list[OrderAddRequest]:
2727
orders = []
2828

29+
# Calculate minimum profitable price difference
30+
min_profit = tick_size * Decimal(BasicOrdersGenerator.MIN_PROFIT_TICKS)
31+
2932
for i in range(number_of_orders):
30-
# First "match" the order with a profit margin equal to the tick size
3133
if i == 0:
32-
matching_side = (
33-
OrderSide.SELL if side == OrderSide.BUY else OrderSide.BUY
34-
)
35-
profit_margin = tick_size if side == OrderSide.BUY else -tick_size
36-
order_price = price + profit_margin
37-
# Then generate orders around the mid-price
34+
# For the first order, we want to match the incoming order
35+
# but ensure we're on the profitable side of the spread
36+
if side == OrderSide.BUY:
37+
# If someone wants to buy, we sell at a higher price
38+
matching_side = OrderSide.SELL
39+
order_price = price + min_profit
40+
else:
41+
# If someone wants to sell, we buy at a lower price
42+
matching_side = OrderSide.BUY
43+
order_price = price - min_profit
3844
else:
39-
matching_side = OrderSide.SELL if randrange(2) == 0 else OrderSide.BUY
40-
order_price = price + tick_size * Decimal(
41-
randrange(
42-
BasicOrdersGenerator.MIN_PROFIT_TICKS,
43-
BasicOrdersGenerator.RANDOM_TICKS_FACTOR,
45+
# For subsequent orders, we place orders around the mid-price
46+
# but always ensuring we're on the profitable side of the spread
47+
if randrange(2) == 0:
48+
# Place a sell order above mid-price
49+
matching_side = OrderSide.SELL
50+
order_price = price + tick_size * Decimal(
51+
randrange(
52+
BasicOrdersGenerator.MIN_PROFIT_TICKS,
53+
BasicOrdersGenerator.RANDOM_TICKS_FACTOR,
54+
)
55+
)
56+
else:
57+
# Place a buy order below mid-price
58+
matching_side = OrderSide.BUY
59+
order_price = price - tick_size * Decimal(
60+
randrange(
61+
BasicOrdersGenerator.MIN_PROFIT_TICKS,
62+
BasicOrdersGenerator.RANDOM_TICKS_FACTOR,
63+
)
4464
)
45-
)
4665

66+
# Scale quantity based on spread - larger spreads get larger orders
4767
if spread == Decimal(0.00):
4868
order_quantity = Decimal(1.00)
4969
else:
50-
order_quantity = spread
70+
# Scale quantity based on spread size, but cap it
71+
order_quantity = min(spread * Decimal(2), Decimal(10.00))
5172

5273
matching_order = OrderAddRequest(
5374
contract_id=contract_id,

0 commit comments

Comments
 (0)