This commit is contained in:
2026-05-09 17:01:58 +09:00
parent a8ad37d35c
commit 01cd34058d

View File

@@ -35,8 +35,8 @@ def main():
print("First message from exchange:", hello_message) print("First message from exchange:", hello_message)
# #
man.orderMan.sell("BOND", 1002, 99) man.orderMan.buy("BOND", 999, 99)
man.orderMan.buy("BOND", 998, 99) man.orderMan.sell("BOND", 1001, 99)
last_print_time = time.time() last_print_time = time.time()
@@ -78,10 +78,8 @@ def on_book(message, man: Manager):
now = time.time() now = time.time()
if now > last_print_time: if now >= last_print_time+1:
last_print_time = now last_print_time = now
print(message)
print()
valePos = man.positionMan.get_position("VALE") valePos = man.positionMan.get_position("VALE")
valeBid = man.valueMan.get_bid("VALE") valeBid = man.valueMan.get_bid("VALE")
@@ -98,16 +96,17 @@ def on_book(message, man: Manager):
valePos * valeBid > valePos * valeBid >
valbzPos * valbzBid + FEE): valbzPos * valbzBid + FEE):
man.orderMan.convert("VALBZ", Dir.SELL, valbzPos) man.orderMan.convert("VALBZ", Dir.SELL, valbzPos)
elif message["symbol"] == "BOND": elif message["symbol"] == "MS" or message["symbol"] == "GS":
now = time.time() now = time.time()
if now > last_print_time: if now >= last_print_time+1:
last_print_time = now last_print_time = now
print(message)
print()
bondPos = man.positionMan.get_position("BOND") if (man.valueMan.get_bid(message["symbol"])+10 < man.valueMan.get_ask(message["symbol"])):
bondBid = man.valueMan.get_bid("BOND") man.orderMan.buy(message["symbol"], man.valueMan.get_bid(message["symbol"])-1, 10)
else:
man.orderMan.sell(message["symbol"], man.valueMan.get_ask(message["symbol"])+1, 10)