커밋 1 — 실매 가격 TTL 구멍 (본체)
왜: 체결이 없어도 마지막가는 유지인데, TTL로 None 만들고 매도/EOD를 건너뛰어 8/5 돌파·금요일 leftover가 남음. 호가필터 TTL 구멍과 같은 병. 넣을 파일 신규: kis_trader/engine/live_sell_price.py kis_trader/strategies/base.py (_ws_last_quote, _resolve_sell_price) 전략: momentum.py scalping.py tail_catch.py breakout.py range_break.py dart_strategy.py updow_strategy.py updown_feed.py us_momentum.py WS: ws_manager.py kis_ws.py kiwoom_ws.py ls_ws.py kis_ws_overseas.py kis_trader/web/live_config_schema.py (WS_PRICE_MAX_AGE_SEC 기본 0) database.py (키 주석 + legacy/ sys.path) kis_trader/execution/order_manager.py (잔고 있는데 40240000 ghost_purge 금지 — 같은 EOD 사고) EOD가 min_hold에 안 막히게 손본 momentum_hts_logic.py / scalping_engine.py / tail_engine.py (이 대화에서 손본 부분만 확인 후) 문서: docs/like_mcp.md/db_erd.md code_architecture.md (가격 TTL 문구) 메시지 초안 fix: 매수·매도 현재가를 TTL로 버리지 않음 (마지막 RAM) 횡보·체결 공백을 죽은 캐시로 오인해 None 처리하면 손절·EOD가 스킵된다. 호가필터와 같이 나이는 무시하고 마지막 체결가를 유지한다. EOD는 매수가 폴백. 영향: 실매 O / 백테·옵투나 봉 경로 거의 무관 (엔진 식 변경 아님) 커밋 2 — 루트 정리 (remove/ vs legacy/) 왜: 루트 단독봇·테스트는 지울 보관함으로. 웹·알람이 아직 쓰는 모듈은 remove에 두면 나중에 폴더째 삭제 때 깨짐. 넣을 파일 이동: 미사용 → remove/legacy_root/ (래퍼, ETF/키움 옛봇, 테스트, kiwoom_rest_api 등) 이동: 사용 중 → legacy/ (holding_bot kis_holding_ver1 news_analyzer kis_long_ver1/2) 신규: kis_trader/utils/legacy_root.py legacy/README.md remove/README.md import 경로: backtest_web.py mm_butler.py mm_remote.py updow_holding_cfg.py dbband_stock_cfg.py param_search_updow*.py dbband_param_search.py param_search_apply_snapshot.py verify_three_paths.py docs/like_mcp.md/code_architecture.md 수동 노트 메시지 초안 chore: 미사용 루트는 remove/, 웹·알람 구모듈은 legacy/ remove는 나중에 통째 삭제 예정. holding_bot·news_analyzer·kis_long은 ensure_legacy_root로 legacy/만 본다. 빼기: scratch/set_ws_price_max_age_zero.py (일회성)
This commit is contained in:
351
remove/legacy_root/sample_python/order_window.py
Normal file
351
remove/legacy_root/sample_python/order_window.py
Normal file
@@ -0,0 +1,351 @@
|
||||
from PySide2 import QtCore, QtWidgets
|
||||
from PySide2.QtUiTools import QUiLoader
|
||||
from PySide2.QtWidgets import QApplication
|
||||
import sys
|
||||
# from .ui.ui_test import Ui_Test
|
||||
# from ui.ui_test import Ui_Test
|
||||
# from ui.ui_second_window import Ui_Second_Window
|
||||
from tr.tr_master import Tr_master
|
||||
from tr.tr_order import Tr_order
|
||||
from tr.tr_redo_order import Tr_redo_order
|
||||
from tr.tr_cancel_order import Tr_cancel_order
|
||||
from tr.tr_0424 import Tr_0424
|
||||
from tr.tr_sc0 import Tr_sc0
|
||||
# from tr.tr_sc1 import Tr_sc1
|
||||
import win32com.client #이베스트 관련
|
||||
import pythoncom #이베스트 관련
|
||||
tr_master=Tr_master()
|
||||
tr_0424=Tr_0424()
|
||||
|
||||
# app=QApplication(sys.argv)
|
||||
|
||||
loader=QUiLoader()
|
||||
|
||||
class Order_window(QtCore.QObject):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.ui=loader.load('./ui/order-window.ui',None)
|
||||
|
||||
|
||||
if self.ui is None:
|
||||
return
|
||||
|
||||
self.ui.setWindowTitle("주문")
|
||||
self.orderType='normal'
|
||||
self.orderStockCode=''
|
||||
self.orderStyle='ask'
|
||||
self.is_all_qty=True
|
||||
|
||||
self.query_order=win32com.client.DispatchWithEvents("XA_DataSet.XAQuery",Tr_order)
|
||||
self.query_order.init_set_text(self.set_status_label)
|
||||
self.query_order_redo=win32com.client.DispatchWithEvents("XA_DataSet.XAQuery",Tr_redo_order)
|
||||
self.query_order_cancel=win32com.client.DispatchWithEvents("XA_DataSet.XAQuery",Tr_cancel_order)
|
||||
|
||||
|
||||
self.ui.order_tab_widget.currentChanged.connect(self.orderTabChanged)
|
||||
|
||||
self.ui.stock_input.textChanged.connect(lambda:self.onChangeStockInput(1))
|
||||
self.ui.stock_input_3.textChanged.connect(lambda:self.onChangeStockInput(2))
|
||||
|
||||
self.ui.stock_input_4.textChanged.connect(lambda:self.onChangeStockInput(3))
|
||||
self.ui.stock_input_5.textChanged.connect(lambda:self.onChangeStockInput(4))
|
||||
self.ui.normal_radio.setChecked(True)
|
||||
self.ui.normal_radio_2.setChecked(True)
|
||||
self.ui.all_qty_radio.setChecked(True)
|
||||
self.ui.all_qty_radio.hide()
|
||||
self.ui.some_qty_radio.hide()
|
||||
self.ui.all_qty_radio_2.hide()
|
||||
self.ui.some_qty_radio_2.hide()
|
||||
self.ui.normal_radio.clicked.connect(self.radioSelected)
|
||||
self.ui.normal_radio_2.clicked.connect(self.radioSelected_2)
|
||||
self.ui.market_radio.clicked.connect(self.radioSelected)
|
||||
self.ui.market_radio_2.clicked.connect(self.radioSelected_2)
|
||||
self.ui.order_btn.clicked.connect(self.shootOrder)
|
||||
self.ui.order_btn_2.clicked.connect(self.shootOrder)
|
||||
self.ui.order_btn_3.clicked.connect(self.shootOrder)
|
||||
self.ui.order_btn_4.clicked.connect(self.shootOrder)
|
||||
|
||||
|
||||
self.ui.all_qty_radio.clicked.connect(self.qty_radioSelected)
|
||||
self.ui.some_qty_radio.clicked.connect(self.qty_radioSelected)
|
||||
|
||||
|
||||
self.ui.status_label.setText('')
|
||||
self.ui.status_label.setStyleSheet("color: red;")
|
||||
|
||||
|
||||
|
||||
# #print('the_balance: ',tr_0424.the_balance)
|
||||
# self.submit_btn.clicked.connect(self.do_action)
|
||||
# self.login_label.clicked.connect(self.do_action)
|
||||
|
||||
|
||||
def set_status_label(self, string):
|
||||
|
||||
self.ui.status_label.setText(string)
|
||||
|
||||
def orderTabChanged(self,tabIndex):
|
||||
#print('tabIndex: ',tabIndex)
|
||||
if tabIndex==0:
|
||||
self.orderStyle='ask'
|
||||
elif tabIndex==1:
|
||||
self.orderStyle='bid'
|
||||
elif tabIndex==2:
|
||||
self.orderStyle='redo'
|
||||
elif tabIndex==3:
|
||||
self.orderStyle='cancel'
|
||||
|
||||
|
||||
self.ui.normal_radio.setChecked(True)
|
||||
self.ui.normal_radio_2.setChecked(True)
|
||||
self.orderType='normal'
|
||||
res_1=self.onChangeStockInput(1)
|
||||
res_2=self.onChangeStockInput(2)
|
||||
res_3=self.onChangeStockInput(3)
|
||||
res_4=self.onChangeStockInput(4)
|
||||
|
||||
|
||||
if (res_1 is not None and
|
||||
res_2 is not None and
|
||||
res_3 is not None and
|
||||
res_4 is not None):
|
||||
|
||||
self.ui.stock_input.setText('')
|
||||
self.ui.stock_input_3.setText('')
|
||||
self.ui.stock_input_4.setText('')
|
||||
self.ui.stock_input_5.setText('')
|
||||
|
||||
|
||||
|
||||
def onChangeStockInput(self,num):
|
||||
|
||||
theInput=self.ui.stock_input.text()
|
||||
|
||||
if num==1:
|
||||
theInput=self.ui.stock_input.text()
|
||||
elif num==2:
|
||||
theInput=self.ui.stock_input_3.text()
|
||||
elif num==3:
|
||||
theInput=self.ui.stock_input_4.text()
|
||||
elif num==4:
|
||||
theInput=self.ui.stock_input_5.text()
|
||||
|
||||
|
||||
theDict=tr_master.master_dict.get(theInput,None)
|
||||
#print('theDict: ',theDict)
|
||||
|
||||
if theDict != None:
|
||||
stockName=theDict['hname']
|
||||
self.ui.stock_name_label.setText(stockName)
|
||||
self.ui.stock_name_label_2.setText(stockName)
|
||||
self.ui.stock_name_label_3.setText(stockName)
|
||||
self.ui.stock_name_label_4.setText(stockName)
|
||||
self.orderStockCode=theDict['shcode']
|
||||
else:
|
||||
self.ui.stock_name_label.setText('')
|
||||
self.ui.stock_name_label_2.setText('')
|
||||
self.ui.stock_name_label_3.setText('')
|
||||
self.ui.stock_name_label_4.setText('')
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
def onChangeStockInput_3(self):
|
||||
theInput=self.ui.stock_input_3.text()
|
||||
|
||||
theDict=tr_master.master_dict.get(theInput,None)
|
||||
#print('theDict: ',theDict)
|
||||
|
||||
if theDict != None:
|
||||
stockName=theDict['hname']
|
||||
self.ui.stock_name_label.setText(stockName)
|
||||
self.orderStockCode=theDict['shcode']
|
||||
else:
|
||||
self.ui.stock_name_label.setText('')
|
||||
|
||||
|
||||
|
||||
|
||||
def onChangeStockInput_4(self):
|
||||
theInput=self.ui.stock_input_4.text()
|
||||
|
||||
theDict=tr_master.master_dict.get(theInput,None)
|
||||
#print('theDict: ',theDict)
|
||||
|
||||
if theDict != None:
|
||||
stockName=theDict['hname']
|
||||
self.ui.stock_name_label.setText(stockName)
|
||||
self.orderStockCode=theDict['shcode']
|
||||
else:
|
||||
self.ui.stock_name_label.setText('')
|
||||
|
||||
|
||||
|
||||
|
||||
def onChangeStockInput_5(self):
|
||||
theInput=self.ui.stock_input_5.text()
|
||||
|
||||
theDict=tr_master.master_dict.get(theInput,None)
|
||||
#print('theDict: ',theDict)
|
||||
|
||||
if theDict != None:
|
||||
stockName=theDict['hname']
|
||||
self.ui.stock_name_label.setText(stockName)
|
||||
self.orderStockCode=theDict['shcode']
|
||||
else:
|
||||
self.ui.stock_name_label.setText('')
|
||||
|
||||
|
||||
def onChangeOrderQtInput(self):
|
||||
theInput=self.ui.order_qt_input.text()
|
||||
|
||||
|
||||
|
||||
def onChangeOrderWonInput(self):
|
||||
theInput=self.ui.order_won_input.text()
|
||||
|
||||
|
||||
def qty_radioSelected(self):
|
||||
|
||||
if self.ui.all_qty_radio.isChecked()==True:
|
||||
self.is_all_qty=True
|
||||
elif self.ui.some_qty_radio.isChecked()==True:
|
||||
self.is_all_qty=False
|
||||
|
||||
#print('is_all_qty: ',self.is_all_qty)
|
||||
|
||||
|
||||
def radioSelected(self):
|
||||
#print('radioSelected: ',self.ui.normal_radio.isChecked())
|
||||
#print('radioSelected2: ',self.ui.market_radio.isChecked())
|
||||
|
||||
if self.ui.normal_radio.isChecked()==True:
|
||||
self.orderType='normal'
|
||||
elif self.ui.market_radio.isChecked()==True:
|
||||
self.orderType='market'
|
||||
|
||||
#print('orderType: ',self.orderType)
|
||||
|
||||
|
||||
def radioSelected_2(self):
|
||||
#print('radioSelected: ',self.ui.normal_radio.isChecked())
|
||||
#print('radioSelected2: ',self.ui.market_radio.isChecked())
|
||||
|
||||
if self.ui.normal_radio_2.isChecked()==True:
|
||||
self.orderType='normal'
|
||||
elif self.ui.market_radio_2.isChecked()==True:
|
||||
self.orderType='market'
|
||||
|
||||
#print('orderType: ',self.orderType)
|
||||
|
||||
|
||||
def show(self):
|
||||
self.ui.show()
|
||||
# app.exec_()
|
||||
|
||||
def shootOrder(self):
|
||||
#print('orderStyle: ',self.orderStyle)
|
||||
|
||||
if self.orderStyle=='ask':
|
||||
|
||||
#print('stockInput: ',self.ui.stock_input.text())
|
||||
#print('orderType: ',self.orderType)
|
||||
#print('orderQtInput: ',self.ui.order_qt_input.text())
|
||||
#print('orderWonInput: ',self.ui.order_won_input.text())
|
||||
#print('orderStockCode: ',self.orderStockCode)
|
||||
#print('orderStyle: ',self.orderStyle)
|
||||
|
||||
self.query_order.shoot_order(
|
||||
self.orderStockCode,
|
||||
self.ui.order_qt_input.text(),
|
||||
1,
|
||||
2,
|
||||
self.ui.order_won_input.text(),
|
||||
self.orderStyle,
|
||||
self.orderType
|
||||
)
|
||||
|
||||
self.ui.status_label.setText('매도 주문 완료')
|
||||
self.ui.status_label.setStyleSheet("color: blue;")
|
||||
|
||||
|
||||
elif self.orderStyle=='bid':
|
||||
#print('stockInput: ',self.ui.stock_input_3.text())
|
||||
#print('orderType: ',self.orderType)
|
||||
#print('orderQtInput_2: ',self.ui.order_qt_input_2.text())
|
||||
#print('orderWonInput_2: ',self.ui.order_won_input_2.text())
|
||||
#print('orderStockCode: ',self.orderStockCode)
|
||||
#print('orderStyle: ',self.orderStyle)
|
||||
|
||||
|
||||
self.query_order.shoot_order(
|
||||
self.orderStockCode,
|
||||
self.ui.order_qt_input_2.text(),
|
||||
1,
|
||||
2,
|
||||
self.ui.order_won_input_2.text(),
|
||||
self.orderStyle,
|
||||
self.orderType
|
||||
)
|
||||
self.ui.status_label.setText('매수 주문 완료')
|
||||
self.ui.status_label.setStyleSheet("color: red;")
|
||||
|
||||
elif self.orderStyle=='redo':
|
||||
#print('orgNoInput: ',self.ui.org_no_input.text())
|
||||
#print('stockInput: ',self.ui.stock_input_4.text())
|
||||
#print('orderType: ',self.orderType)
|
||||
|
||||
#print('order_qt_input_3: ',self.ui.order_qt_input_3.text())
|
||||
#print('orderWonInput_3: ',self.ui.order_won_input_3.text())
|
||||
#print('orderStyle: ',self.orderStyle)
|
||||
#print('is_all_qty: ',self.is_all_qty)
|
||||
|
||||
self.query_order_redo.shoot_order(
|
||||
self.orderStockCode,
|
||||
self.ui.order_qt_input_3.text(),
|
||||
1,
|
||||
2,
|
||||
self.ui.order_won_input_3.text(),
|
||||
self.orderStyle,
|
||||
self.orderType,
|
||||
self.ui.org_no_input.text(),
|
||||
)
|
||||
|
||||
|
||||
self.ui.status_label.setText('정정 주문 완료')
|
||||
self.ui.status_label.setStyleSheet("color: black;")
|
||||
|
||||
elif self.orderStyle=='cancel':
|
||||
#print('orgNoInput: ',self.ui.org_no_input_2.text())
|
||||
#print('orderType: ',self.orderStyle)
|
||||
|
||||
#print('order_qt_input_4: ',self.ui.order_qt_input_4.text())
|
||||
#print('orderStyle: ',self.orderStyle)
|
||||
|
||||
self.query_order_cancel.shoot_order(
|
||||
self.orderStockCode,
|
||||
self.ui.order_qt_input_4.text(),
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
self.orderStyle,
|
||||
self.orderType,
|
||||
self.ui.org_no_input_2.text(),
|
||||
)
|
||||
|
||||
|
||||
self.ui.status_label.setText('취소 주문 완료')
|
||||
self.ui.status_label.setStyleSheet("color: black;")
|
||||
|
||||
def do_action(self):
|
||||
#print('doing: ',self.name_line_edit.text())
|
||||
#print('doing2: ',self.job_line_edit.text())
|
||||
self.login_label.setText('되냐?')
|
||||
|
||||
def set_the_text(self,the_thing):
|
||||
#print('세팅한다: ',the_thing)
|
||||
self.login_label.setText(the_thing)
|
||||
def set_the_stock_code(self,the_thing):
|
||||
#print('세팅한다2: ',the_thing)
|
||||
self.stock_code_label.setText(the_thing)
|
||||
Reference in New Issue
Block a user