add pennying
This commit is contained in:
15
bot.py
15
bot.py
@@ -13,6 +13,7 @@ import json
|
|||||||
|
|
||||||
from state import StateManager
|
from state import StateManager
|
||||||
from order import OrderManager
|
from order import OrderManager
|
||||||
|
|
||||||
# ~~~~~============== CONFIGURATION ==============~~~~~
|
# ~~~~~============== CONFIGURATION ==============~~~~~
|
||||||
# Replace "REPLACEME" with your team name!
|
# Replace "REPLACEME" with your team name!
|
||||||
team_name = "HanyangFloorFunction"
|
team_name = "HanyangFloorFunction"
|
||||||
@@ -71,6 +72,7 @@ def on_book(message: dict, state: StateManager):
|
|||||||
|
|
||||||
state.update_bid_ask_price(symbol, best_price("buy"), best_price("sell"))
|
state.update_bid_ask_price(symbol, best_price("buy"), best_price("sell"))
|
||||||
|
|
||||||
|
|
||||||
def on_fill(message: dict, orderman: OrderManager, state: StateManager):
|
def on_fill(message: dict, orderman: OrderManager, state: StateManager):
|
||||||
symbol = message["symbol"]
|
symbol = message["symbol"]
|
||||||
dir = message["dir"]
|
dir = message["dir"]
|
||||||
@@ -88,7 +90,9 @@ def on_trade(message: dict, orderman: OrderManager, state: StateManager):
|
|||||||
|
|
||||||
# 거래도
|
# 거래도
|
||||||
if symbol == "VALBZ" or symbol == "VALE":
|
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_valbz = state.get_last_price("VALBZ")
|
||||||
p_vale = state.get_last_price("VALE")
|
p_vale = state.get_last_price("VALE")
|
||||||
|
|
||||||
@@ -98,12 +102,11 @@ def on_trade(message: dict, orderman: OrderManager, state: StateManager):
|
|||||||
|
|
||||||
FEE = 10
|
FEE = 10
|
||||||
SZ = 10
|
SZ = 10
|
||||||
if p_vale < p_valbz:
|
if p_vale + 1 < p_valbz - 1:
|
||||||
print("Good")
|
print("Good")
|
||||||
if p_vale * SZ + FEE < p_valbz * SZ:
|
if (p_vale + 1) * SZ + FEE < (p_valbz - 1) * SZ:
|
||||||
orderman.buy("VALE", p_vale, SZ)
|
orderman.buy("VALE", p_vale + 1, -SZ)
|
||||||
orderman.sell("VALBZ", p_valbz, SZ)
|
orderman.sell("VALBZ", p_valbz - 1, SZ)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ~~~~~============== PROVIDED CODE ==============~~~~~
|
# ~~~~~============== PROVIDED CODE ==============~~~~~
|
||||||
|
|||||||
Reference in New Issue
Block a user