add pennying

This commit is contained in:
2026-05-09 14:35:05 +09:00
parent 4e736c6080
commit 7dcb0538e3

21
bot.py
View File

@@ -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 ==============~~~~~