many change

This commit is contained in:
2026-05-09 15:35:03 +09:00
parent 887873a141
commit 5685520f1f
3 changed files with 16 additions and 34 deletions

39
bot.py
View File

@@ -91,45 +91,24 @@ def on_trade(message: dict, orderman: OrderManager, state: StateManager):
def execute_arb(orderman: OrderManager, state: StateManager):
p_valbz = state.get_fair_value("VALBZ")
p_vale = state.get_fair_value("VALE")
p_bond = state.get_fair_value("BOND")
p_gs = state.get_fair_value("GS")
p_ms = state.get_fair_value("MS")
p_wfc = state.get_fair_value("WFC")
p_xlf = state.get_fair_value("XLF")
bid_valbz, ask_valbz = state.get_best_bid_ask("VALBZ")
bid_vale, ask_vale = state.get_fair_value("VALE")
if p_vale is None or p_valbz is None:
if bid_valbz is None or ask_valbz is None or bid_vale is None or ask_vale is None:
return
vale_to_valbz = p_valbz - p_vale
valbz_to_vale = p_vale - p_valbz
vale_to_valbz = bid_valbz - ask_vale - 2
valbz_to_vale = bid_vale - ask_valbz - 2
if vale_to_valbz > 10:
orderman.buy("VALE", Dir.BUY, p_vale, 10)
orderman.buy("VALE", bid_vale + 1, 10)
orderman.convert("VALE", Dir.SELL, 10)
orderman.sell("VALBZ", Dir.SELL, p_valbz, 10)
orderman.sell("VALBZ", ask_valbz - 1, 10)
elif valbz_to_vale > 10:
orderman.buy("VALBZ", Dir.BUY, p_valbz, 10)
orderman.buy("VALBZ", bid_valbz + 1, 10)
orderman.convert("VALE", Dir.BUY, 10)
orderman.sell("VALE", Dir.SELL, p_vale, 10)
orderman.sell("VALE", ask_vale - 1, 10)
if p_xlf is not None and all(p is not None for p in [p_bond, p_gs, p_ms, p_wfc]):
components = p_bond * 3 + p_gs * 2 + p_ms * 3 + p_wfc * 2
xlf_fair = components / 10
if p_xlf > xlf_fair + 10:
orderman.sell("XLF", Dir.SELL, p_xlf, 10)
orderman.buy("BOND", Dir.BUY, p_bond, 30)
orderman.buy("GS", Dir.BUY, p_gs, 20)
orderman.buy("MS", Dir.BUY, p_ms, 30)
orderman.buy("WFC", Dir.BUY, p_wfc, 20)
elif xlf_fair > p_xlf + 10:
orderman.buy("XLF", Dir.BUY, p_xlf, 10)
orderman.sell("BOND", Dir.SELL, p_bond, 30)
orderman.sell("GS", Dir.SELL, p_gs, 20)
orderman.sell("MS", Dir.SELL, p_ms, 30)
orderman.sell("WFC", Dir.SELL, p_wfc, 20)
# ~~~~~============== PROVIDED CODE ==============~~~~~