Files
kis_bot/remove/legacy_root/sample_python/tr/tr_master.py
Your Name 6d2a706a48 커밋 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 (일회성)
2026-08-18 00:13:17 +09:00

67 lines
2.4 KiB
Python

import os
the_path=os.path.dirname(__file__)
#XAQueryEvents
class Tr_master:
master_arr=[]
master_dict={}
query_state = False
def OnReceiveData(self, tr_code):
Tr_master.query_state = True
block_count=self.GetBlockCount("t8430OutBlock")
#print('block_count: ',block_count)
if block_count is not None:
for i in range(block_count):
hname = self.GetFieldData("t8430OutBlock", "hname", i).strip()
shcode = self.GetFieldData("t8430OutBlock", "shcode", i).strip()
gubun = self.GetFieldData("t8430OutBlock", "gubun", i).strip() #1은 코스피, 2는 코스닥
self.master_dict[shcode]={
'hname':hname,
'shcode':shcode,
'gubun':gubun
}
self.master_dict[hname]={
'hname':hname,
'shcode':shcode,
'gubun':gubun
}
# print('삼전: ',self.master_dict['005930'])
#print('삼전2: ',self.master_dict['삼성전자'])
self.tr_0424.init_get_account(self.balance_window)#잔고
self.tr_pending.get_pending(self.balance_window)#미체결
self.tr_0424.init_sc1()
# hname = self.GetFieldData("t8430OutBlock", "hname", 0)
# shcode = self.GetFieldData("t8430OutBlock", "shcode", 0)
# #print('tr_code: ',tr_code)
# #print('hname: ',hname)
# #print('shcode: ',shcode)
# param['hname']=hname
# param['shcode']=shcode
def OnReceiveMessage(self, error, nMessageCode, szMessage):
# #print('OnReceiveMessage: ',szMessage)
pass
def single_request(self,tr_0424,balance_window,tr_pending):
# self.ResFileName = "C:\\eBEST\\xingAPI\\Res\\t8430.res"
self.tr_0424=tr_0424
self.tr_pending=tr_pending
self.balance_window=balance_window
the_path=os.environ.get('ROOT_FILE_PATH')
self.ResFileName = the_path+"\\Res\\t8430.res"
#print('the_path2: ',the_path+"\\Res\\t8430.res")
self.SetFieldData("t8430InBlock", "gubun", 0, 0)
err_code = self.Request(False)
if err_code is not None:
if err_code < 0:
#print("error... {0}".format(err_code))
pass