From 7dcb0538e310e92ecc8fd0c63319c83aeb65860f Mon Sep 17 00:00:00 2001 From: yenru0 Date: Sat, 9 May 2026 14:35:05 +0900 Subject: [PATCH] add pennying --- bot.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bot.py b/bot.py index 4798af5..a470024 100644 --- a/bot.py +++ b/bot.py @@ -13,6 +13,7 @@ import json from state import StateManager from order import OrderManager + # ~~~~~============== CONFIGURATION ==============~~~~~ # Replace "REPLACEME" with your team name! team_name = "HanyangFloorFunction" @@ -68,9 +69,10 @@ def on_book(message: dict, state: StateManager): return message[side][0][0] else: return None - + state.update_bid_ask_price(symbol, best_price("buy"), best_price("sell")) + def on_fill(message: dict, orderman: OrderManager, state: StateManager): symbol = message["symbol"] dir = message["dir"] @@ -88,22 +90,23 @@ def on_trade(message: dict, orderman: OrderManager, state: StateManager): # 거래도 if symbol == "VALBZ" or symbol == "VALE": - print(f"Current prices - VALBZ: {state.get_last_price('VALBZ')}, VALE: {state.get_last_price('VALE')}") + print( + f"Current prices - VALBZ: {state.get_last_price('VALBZ')}, VALE: {state.get_last_price('VALE')}" + ) p_valbz = state.get_last_price("VALBZ") p_vale = state.get_last_price("VALE") - + if p_vale is None or p_valbz is None: print("NONE") return - + FEE = 10 SZ = 10 - if p_vale < p_valbz: + if p_vale + 1 < p_valbz - 1: print("Good") - if p_vale * SZ + FEE < p_valbz * SZ: - orderman.buy("VALE", p_vale, SZ) - orderman.sell("VALBZ", p_valbz, SZ) - + if (p_vale + 1) * SZ + FEE < (p_valbz - 1) * SZ: + orderman.buy("VALE", p_vale + 1, -SZ) + orderman.sell("VALBZ", p_valbz - 1, SZ) # ~~~~~============== PROVIDED CODE ==============~~~~~