Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
dex = True if args.dex == "true" else False
tickspread_password = args.tickspread_password

logging.basicConfig(level=logging.WARN,
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)-8s %(message)s')
if log_file != "shell":
# log_handler = logging.handlers.WatchedFileHandler(
Expand Down Expand Up @@ -194,10 +194,11 @@ def set_new_price(self, new_price):
if (self.side == Side.BID):
new_top_price = Decimal(math.floor(
new_price / self.tick_jump) * self.tick_jump)
#print("BID", new_price, new_top_price)
print("BID", new_price, new_top_price)
else:
new_top_price = Decimal(math.ceil(
new_price / self.tick_jump) * self.tick_jump)
print("ASK", new_price, new_top_price)
self.old_top_price = self.top_price
self.top_price = new_top_price
self.old_top_order = self.top_order
Expand Down Expand Up @@ -624,6 +625,7 @@ def update_orders(self):
# When price falls, cancel bottom asks to maintain the desired number of orders. When price rises, cancel bottom bids.
self.bids.maybe_cancel_bottom_orders()
self.asks.maybe_cancel_bottom_orders()
self.api.dispatch_batch()

def tickspread_market_data_partial(self, payload):
print("MARKET DATA PARTIAL: ", payload)
Expand Down Expand Up @@ -737,6 +739,7 @@ def tickspread_user_data_partial(self, payload):
self.position = 0
self.has_user_position = True
print("Read user_data partial successfully")
input("Press key to continue")

def cancel_old_orders(self):
print("Old orders:")
Expand Down Expand Up @@ -786,6 +789,7 @@ def tickspread_callback(self, data):
#print("OK_1")
self.cancel_old_orders()
#print("FINISH_OK")
input("Press key to continue (again)")
return 0

if (topic == "market_data"):
Expand Down Expand Up @@ -966,7 +970,7 @@ async def main():
if args.market == "ETH-TEST":
# mmaker = MarketMaker(api, tick_jump=Decimal("0.2"), orders_per_side8,
# order_size=Decimal("1.5"), max_position=Decimal("40.0"))
mmaker = MarketMaker(api, tick_jump=Decimal("0.2"), orders_per_side=10,
mmaker = MarketMaker(api, tick_jump=Decimal("1.0"), orders_per_side=10,
order_size=Decimal("0.001"), max_position=Decimal("1.0"))
# mmaker = MarketMaker(api, tick_jump=Decimal("0.2"), orders_per_side=10,
# order_size=Decimal("0.2"), max_position=Decimal("1.0"))
Expand Down
34 changes: 12 additions & 22 deletions kafka_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@

producer = Producer({'bootstrap.servers': '%s:9092' % host})

topic = 'user_data'
topic = 'results'
key = 'transfer_balance'


messages = [
{
"event": "transfer_balance",
"user_group_id": 0,
"user_id_from": 0,
"user_id_to": 4,
"asset": "testUSD",
"asset_id": 8,
"balance_amount": 10000000000,
"asset_precision": 6
},
# {
# "event": "transfer_balance",
# "user_group_id": 0,
Expand Down Expand Up @@ -54,16 +44,16 @@
# "balance_amount": 10000000000,
# "asset_precision": 6
# },
{
"event": "transfer_balance",
"user_group_id": 0,
"user_id_from": 0,
"user_id_to": 5,
"asset": "testUSD",
"asset_id": 8,
"balance_amount": 10000000000,
"asset_precision": 6
},
# {
# "event": "transfer_balance",
# "user_group_id": 0,
# "user_id_from": 0,
# "user_id_to": 5,
# "asset": "testUSD",
# "asset_id": 8,
# "balance_amount": 10000000000,
# "asset_precision": 6
# },
# {
# "event": "transfer_balance",
# "user_group_id": 0,
Expand Down Expand Up @@ -154,7 +144,7 @@
]

for value in messages:
producer.produce(topic, json.dumps(value), key, 0)
producer.produce(topic, json.dumps(value), key, 3)
print(value)
producer.flush()

Expand Down
Loading