add: bot bond selling
This commit is contained in:
@@ -52,6 +52,7 @@ def main():
|
|||||||
position = 0 # 현재 BOND 포지션
|
position = 0 # 현재 BOND 포지션
|
||||||
order_id = 0 # 단조 증가하는 주문 ID
|
order_id = 0 # 단조 증가하는 주문 ID
|
||||||
active_orders = {} # {order_id: {"dir": ..., "price": ...}}
|
active_orders = {} # {order_id: {"dir": ..., "price": ...}}
|
||||||
|
market_open = False # 시장 open 여부 (open 전에는 주문 불가)
|
||||||
|
|
||||||
def next_id():
|
def next_id():
|
||||||
nonlocal order_id
|
nonlocal order_id
|
||||||
@@ -66,6 +67,9 @@ def main():
|
|||||||
|
|
||||||
def place_bond_orders():
|
def place_bond_orders():
|
||||||
"""포지션 한도 안에서 bid/ask 양방향 주문"""
|
"""포지션 한도 안에서 bid/ask 양방향 주문"""
|
||||||
|
if not market_open:
|
||||||
|
return
|
||||||
|
|
||||||
cancel_all_bond_orders()
|
cancel_all_bond_orders()
|
||||||
|
|
||||||
buy_price = FAIR_VALUE - SPREAD # 999
|
buy_price = FAIR_VALUE - SPREAD # 999
|
||||||
@@ -88,9 +92,6 @@ def main():
|
|||||||
)
|
)
|
||||||
active_orders[ask] = {"dir": Dir.SELL, "price": sell_price}
|
active_orders[ask] = {"dir": Dir.SELL, "price": sell_price}
|
||||||
|
|
||||||
# 시작 시 첫 BOND 주문 배치
|
|
||||||
place_bond_orders()
|
|
||||||
|
|
||||||
# Set up some variables to track the bid and ask price of a symbol. Right
|
# Set up some variables to track the bid and ask price of a symbol. Right
|
||||||
# now this doesn't track much information, but it's enough to get a sense
|
# now this doesn't track much information, but it's enough to get a sense
|
||||||
# of the VALE market.
|
# of the VALE market.
|
||||||
@@ -124,9 +125,10 @@ def main():
|
|||||||
print("The round has ended")
|
print("The round has ended")
|
||||||
break
|
break
|
||||||
elif message["type"] == "open":
|
elif message["type"] == "open":
|
||||||
|
# 시장이 열렸을 때 주문 시작 (open 전에 주문하면 reject됨)
|
||||||
print("Market opened:", message)
|
print("Market opened:", message)
|
||||||
market_open = True
|
market_open = True
|
||||||
place_bond_orders() # open 받은 후에만 주문
|
place_bond_orders()
|
||||||
elif message["type"] == "error":
|
elif message["type"] == "error":
|
||||||
print(message)
|
print(message)
|
||||||
elif message["type"] == "reject":
|
elif message["type"] == "reject":
|
||||||
@@ -214,7 +216,7 @@ class ExchangeConnection:
|
|||||||
"dir": dir,
|
"dir": dir,
|
||||||
"price": price,
|
"price": price,
|
||||||
"size": size,
|
"size": size,
|
||||||
"tif" : "GFD", # Good-For-Day (주문이 체결되거나 취소될 때까지 유효)
|
"tif": "DAY", # 설명서 필수 필드: DAY or IOC
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user