diff --git a/bot bond sell.py b/bot bond sell.py index ec8bc7e..c4264c9 100644 --- a/bot bond sell.py +++ b/bot bond sell.py @@ -46,7 +46,7 @@ def main(): # pick? Also, you will need to send more orders over time. # --- 설정 --- BOND_FAIR_VALUE = 1000 # BOND fair value (고정) - BOND_ORDER_SIZE = 80 # BOND 주문당 수량 (크게 설정해서 체결 기회 극대화) + BOND_ORDER_SIZE = 50 # BOND 주문당 수량 (한도 초과 방지) XLF_CONVERSION_FEE = 100 # XLF 변환 비용 VALE_CONVERSION_FEE = 10 # VALE 변환 비용 VALE_ARB_SIZE = 10 # VALE 차익거래 단위 @@ -58,7 +58,7 @@ def main(): xlf_state = "IDLE" xlf_pending = {} xlf_direction = None - xlf_arb_size = 0 # 현재 차익거래 수량 추적 + xlf_arb_size = 0 # VALE state machine # IDLE → BUYING_VALBZ → CONVERTING → SELLING_VALE → IDLE @@ -66,7 +66,7 @@ def main(): vale_state = "IDLE" vale_pending = {} vale_direction = None - vale_arb_size = 0 # 현재 차익거래 수량 추적 + vale_arb_size = 0 state = StateManager() om = OrderManager(exchange) @@ -111,8 +111,8 @@ def main(): sell_size = base_size # 포지션 한도 초과 방지 - buy_size = min(buy_size, 100 - position) - sell_size = min(sell_size, 100 + position) + buy_size = max(0, min(buy_size, 100 - position)) + sell_size = max(0, min(sell_size, 100 + position)) if buy_size > 0: bid = next_id() @@ -325,16 +325,16 @@ def main(): vale_direction = None elif message["type"] == "ack": - # XLF 변환 ack 처리 + # XLF 변환 ack 처리 - om.positions 직접 수정 if xlf_state == "CONVERTING": print(" XLF 변환 완료 → 매도 시작") if xlf_direction == "BASKET_TO_XLF": # 변환: BOND -3, GS -2, MS -3, WFC -2, XLF +10 - om.update_position("BOND", -1, -3) - om.update_position("GS", -1, -2) - om.update_position("MS", -1, -3) - om.update_position("WFC", -1, -2) - om.update_position("XLF", -1, xlf_arb_size) + om.positions["BOND"] -= 3 + om.positions["GS"] -= 2 + om.positions["MS"] -= 3 + om.positions["WFC"] -= 2 + om.positions["XLF"] += xlf_arb_size xlf_state = "SELLING_XLF" oid = next_id() exchange.send_add_message( @@ -343,11 +343,11 @@ def main(): xlf_pending[oid] = xlf_arb_size elif xlf_direction == "XLF_TO_BASKET": # 변환: XLF -10, BOND +3, GS +2, MS +3, WFC +2 - om.update_position("XLF", -1, -xlf_arb_size) - om.update_position("BOND", -1, 3) - om.update_position("GS", -1, 2) - om.update_position("MS", -1, 3) - om.update_position("WFC", -1, 2) + om.positions["XLF"] -= xlf_arb_size + om.positions["BOND"] += 3 + om.positions["GS"] += 2 + om.positions["MS"] += 3 + om.positions["WFC"] += 2 xlf_state = "SELLING_BASKET" for sym, qty in [("BOND", 3), ("GS", 2), ("MS", 3), ("WFC", 2)]: oid = next_id() @@ -356,13 +356,13 @@ def main(): ) xlf_pending[oid] = qty - # VALE 변환 ack 처리 + # VALE 변환 ack 처리 - om.positions 직접 수정 elif vale_state == "CONVERTING": print(" VALE 변환 완료 → 매도 시작") if vale_direction == "VALBZ_TO_VALE": # 변환: VALBZ -size, VALE +size - om.update_position("VALBZ", -1, -vale_arb_size) - om.update_position("VALE", -1, vale_arb_size) + om.positions["VALBZ"] -= vale_arb_size + om.positions["VALE"] += vale_arb_size vale_state = "SELLING_VALE" oid = next_id() exchange.send_add_message( @@ -371,8 +371,8 @@ def main(): vale_pending[oid] = vale_arb_size elif vale_direction == "VALE_TO_VALBZ": # 변환: VALE -size, VALBZ +size - om.update_position("VALE", -1, -vale_arb_size) - om.update_position("VALBZ", -1, vale_arb_size) + om.positions["VALE"] -= vale_arb_size + om.positions["VALBZ"] += vale_arb_size vale_state = "SELLING_VALBZ" oid = next_id() exchange.send_add_message(