from dotenv import load_dotenv import os load_dotenv() class Tr_cancel_order: def __init__(self): super().__init__() self.account=os.environ.get('ACCOUNT') def OnReceiveData(self, tr_code): #print('주문 에코: ',tr_code) # if tr_code=='CSPAT00600': # XAQueryEvents.query_state = True # block_count=self.GetBlockCount("t8430OutBlock") # #print('block_count: ',block_count) # 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는 코스닥 # master_dict[shcode]={ # 'hname':hname, # 'gubun':gubun # } # #print('master_dict: ',master_dict['005930']) # query_1857.set_master(master_dict) # 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 pass def OnReceiveMessage(self, error, nMessageCode, szMessage): # #print('OnReceiveMessage: ',szMessage) pass def shoot_order(self,stock_code,how_many,price,open,order_price,order_style,order_type,org_no): #order_style이 매수인지 매도인지 그거 말하는거임 #order_type은 지정가인지 시장가인지 그거임 # 00@지정가 # 03@시장가 is_market='00' if order_type=='market': is_market=='03' is_ask='1' if order_style=='bid': is_ask='2' order_dict={ 'account':self.account, 'stock_code':stock_code, 'how_many':how_many, 'order_price':order_price, 'is_ask':is_ask, 'is_market':is_market, 'org_no':org_no } stock_code="A"+stock_code#모투라 이렇게 해놈 the_path=os.environ.get('ROOT_FILE_PATH') self.ResFileName = the_path+"\\Res\\CSPAT00800.res" # self.ResFileName = "C:\\eBEST\\xingAPI\\Res\\CSPAT00800.res" self.SetFieldData("CSPAT00800InBlock1", "OrgOrdNo", 0, org_no) self.SetFieldData("CSPAT00800InBlock1", "AcntNo", 0, self.account) self.SetFieldData("CSPAT00800InBlock1", "InptPwd", 0, "0000") #모투는 0000임 self.SetFieldData("CSPAT00800InBlock1", "IsuNo", 0, stock_code) #모투는 앞에 A 더하래 self.SetFieldData("CSPAT00800InBlock1", "OrdQty", 0, how_many) #얘네 왜 스트링임? # self.SetFieldData("CSPAT00800InBlock1", "OrdPrc", 0, str(order_price))#얘네 왜 스트링임? # self.SetFieldData("CSPAT00700InBlock1", "BnsTpCode", 0, is_ask)#1이 매도 2가 매수 # 00@지정가 # 03@시장가 # 05@조건부지정가 # 06@최유리지정가 # 07@최우선지정가 # 61@장개시전시간외종가 # 81@시간외종가 # 82@시간외단일가 # self.SetFieldData("CSPAT00800InBlock1", "OrdprcPtnCode", 0, is_market) # 000:보통 # 003:유통/자기융자신규 # 005:유통대주신규 # 007:자기대주신규 # 101:유통융자상환 # 103:자기융자상환 # 105:유통대주상환 # 107:자기대주상환 # 180:예탁담보대출상환(신용) # self.SetFieldData("CSPAT00600InBlock1", "MgntrnCode", 0, '000') # self.SetFieldData("CSPAT00600InBlock1", "LoanDt", 0, '')#대출일이라는데 일단 비워둠 # self.SetFieldData("CSPAT00800InBlock1", "OrdCndiTpCode", 0, '0') #0:없음,1:IOC,2:FOK 주문조건구분 #print('ORDER!!!!!') err_code = self.Request(False) if err_code < 0: pass #print("error... {0}".format(err_code))