commit
This commit is contained in:
16
new_prac.py
16
new_prac.py
@@ -84,8 +84,8 @@ def main():
|
||||
last_refresh = time.time()
|
||||
last_stock_refresh = time.time()
|
||||
|
||||
# hello 메시지에서 기존 포지션 로드
|
||||
for sym_info in hello_message["symbols"]: # "symbol" → "symbols"
|
||||
# hello 메시지에서 기존 포지션 로드 (재접속 시 필수) ← 들여쓰기 수정
|
||||
for sym_info in hello_message["symbols"]:
|
||||
sym = sym_info["symbol"]
|
||||
pos = sym_info["position"]
|
||||
if sym in om.positions:
|
||||
@@ -160,11 +160,11 @@ for sym_info in hello_message["symbols"]: # "symbol" → "symbols"
|
||||
info = stock_orders[oid]
|
||||
if symbol is None or info["symbol"] == symbol:
|
||||
size = info.get("size", 0)
|
||||
sym = info["symbol"]
|
||||
s = info["symbol"]
|
||||
if info["dir"] == Dir.BUY:
|
||||
om.future_positions[sym] -= size
|
||||
om.future_positions[s] -= size
|
||||
else:
|
||||
om.future_positions[sym] += size
|
||||
om.future_positions[s] += size
|
||||
om.cancel(oid)
|
||||
stock_orders.pop(oid, None)
|
||||
|
||||
@@ -185,7 +185,6 @@ for sym_info in hello_message["symbols"]: # "symbol" → "symbols"
|
||||
pos = om.positions[sym]
|
||||
limit = STOCK_MAX_POSITION
|
||||
|
||||
# 기존 해당 심볼 주문 취소
|
||||
cancel_stock_orders(sym)
|
||||
|
||||
buy_sz = max(0, min(STOCK_ORDER_SIZE, limit - pos))
|
||||
@@ -206,7 +205,8 @@ for sym_info in hello_message["symbols"]: # "symbol" → "symbols"
|
||||
# ── XLF 차익거래 ─────────────────────────────────────────────
|
||||
|
||||
def try_xlf_arb():
|
||||
nonlocal xlf_state, xlf_direction, xlf_pending, xlf_arb_size, xlf_convert_oid
|
||||
# nonlocal에 xlf_last_fail 추가 ← 수정
|
||||
nonlocal xlf_state, xlf_direction, xlf_pending, xlf_arb_size, xlf_convert_oid, xlf_last_fail
|
||||
|
||||
if not market_open or xlf_state != "IDLE":
|
||||
return
|
||||
@@ -505,7 +505,7 @@ for sym_info in hello_message["symbols"]: # "symbol" → "symbols"
|
||||
if sym in ["VALE", "VALBZ"]:
|
||||
try_vale_arb()
|
||||
|
||||
# GS/MS/WFC 마켓 메이킹 갱신 (호가 바뀔 때마다)
|
||||
# GS/MS/WFC 마켓 메이킹 갱신 (2초마다)
|
||||
if sym in ("GS", "MS", "WFC") and xlf_state == "IDLE":
|
||||
now = time.time()
|
||||
if now - last_stock_refresh > 2.0:
|
||||
|
||||
Reference in New Issue
Block a user