diff --git a/bot split/bot split.py b/bot split/bot split.py index be4cc2c..13f5b74 100644 --- a/bot split/bot split.py +++ b/bot split/bot split.py @@ -35,8 +35,8 @@ def main(): print("First message from exchange:", hello_message) # - man.orderMan.sell("BOND", 1002, 99) - man.orderMan.buy("BOND", 998, 99) + man.orderMan.buy("BOND", 999, 99) + man.orderMan.sell("BOND", 1001, 99) last_print_time = time.time() @@ -78,10 +78,8 @@ def on_book(message, man: Manager): now = time.time() - if now > last_print_time: + if now >= last_print_time+1: last_print_time = now - print(message) - print() valePos = man.positionMan.get_position("VALE") valeBid = man.valueMan.get_bid("VALE") @@ -98,16 +96,17 @@ def on_book(message, man: Manager): valePos * valeBid > valbzPos * valbzBid + FEE): man.orderMan.convert("VALBZ", Dir.SELL, valbzPos) - elif message["symbol"] == "BOND": + elif message["symbol"] == "MS" or message["symbol"] == "GS": now = time.time() - if now > last_print_time: + if now >= last_print_time+1: last_print_time = now - print(message) - print() - bondPos = man.positionMan.get_position("BOND") - bondBid = man.valueMan.get_bid("BOND") + if (man.valueMan.get_bid(message["symbol"])+10 < man.valueMan.get_ask(message["symbol"])): + 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) +