def __init__(self): super().__init__() self.objStockChart = win32com.client.Dispatch("CpSysDib.StockChart") ##################################################################### # logger self.logger = logging.getLogger("my_setting") self.logger = LoggerAdapter(CpStockChart.__name__, self.logger) self.logger.debug(f'CpStockChart Start') #6:전일대비(long or float) - 주) 대비부호(37)과반드시같이요청해야함 self.rqField = [0, 2, 3, 4, 5, 6, 8, 37] # 요청 필드
def __init__(self): super().__init__() self.ts = time.time() self.ymd = datetime.datetime.fromtimestamp(self.ts).strftime('%Y%m%d') self.timestamp = datetime.datetime.fromtimestamp( self.ts).strftime('%Y-%m-%d %H:%M:%S.%f') self.logger = logging.getLogger("my_setting") self.logger = LoggerAdapter(CpDB.__name__, self.logger) # db 정보 초기화 config = ConfigParser() config.read('setting/init.ini') db = config['db'] self.logger.debug( f'db: {db["USR"]} {db["URL"]} {int(db["PORT"])} {db["DB"]}') self.db_info = { DataBase.USR: db["USR"], DataBase.PWD: db["PW"], DataBase.URL: db["URL"], DataBase.PORT: int(db["PORT"]), DataBase.DB: db["DB"] } ############################################################################### # Connect os.environ["NLS_LANG"] = ".AL32UTF8" hostname = os.environ['COMPUTERNAME'] self.logger.debug(f'db: {self.db_info[DataBase.USR]}') # Open database connection self.con = pymysql.connect(host=self.db_info[DataBase.URL], port=self.db_info[DataBase.PORT], user=self.db_info[DataBase.USR], passwd=self.db_info[DataBase.PWD], db=self.db_info[DataBase.DB], charset='utf8', autocommit=False) # Connection 으로부터 Dictoionary Cursor 생성 self.cur = self.con.cursor(pymysql.cursors.DictCursor)
def __init__(self): super().__init__() # plus 상태 체크 if com.InitPlusCheck() == False: exit() if com.InitTradeInit() == False: exit() ##################################################################### # account info self.acc_no = com.g_objCpTrade.AccountNumber[0] # 계좌번호 self.acc_tp = com.g_objCpTrade.GoodsList(self.acc_no, 1) # 주식상품 구분 ##################################################################### # stock object self.stkCurData = CpData.StkCurData() self.stkTickData = CpData.StkTickData() # 주문 현재가/10차 호가 저장 self.objSBCur = CpData.CpSBStockCur() self.objSBid = CpData.CpSBStockBid() ##################################################################### # 시세종목 #self.codelist = ['A05930', 'A151860'] self.codelist = ['A151860'] ##################################################################### # logger self.logger = logging.getLogger("my_setting") self.logger = LoggerAdapter(CpDataWindow.__name__, self.logger) self.logger.debug(f'CpDataWindow Start') ##################################################################### # db object self.objDB = CpDB.CpDB() ##################################################################### # 이동평균 self.cntTick = 0 self.stkCur = [] self.futCur = [] self.stkShortOdrTP = 'N' self.stkLongOdrTP = 'N' self.setWindowTitle(sys.argv[0]) self.setGeometry(300, 300, 300, 700) nH = 20 btnBuy = QPushButton("종목 분 데이터 조회", self) btnBuy.move(20, nH) # btnBuy.resize(200,30) btnBuy.clicked.connect(self.btnBuy_clicked) nH += 50 btnExit = QPushButton("종료", self) btnExit.move(20, nH) # btnExit.resize(200,30) btnExit.clicked.connect(self.btnExit_clicked) nH += 50 btnMst = QPushButton("기본정보", self) btnMst.move(20, nH) # btnExit.resize(200,30) btnMst.clicked.connect(self.btnMst_clicked) nH += 50 btnInv = QPushButton("투자자종합", self) btnInv.move(20, nH) btnInv.clicked.connect(self.btnInv_clicked)
def __init__(self): super().__init__() pythoncom.CoInitialize() self.odrExec0 = CpOdr.CpOrderExec() self.odrExec1 = CpOdr.CpOrderExec() self.odrExec2 = CpOdr.CpOrderExec() self.odrExec3 = CpOdr.CpOrderExec() # plus 상태 체크 if com.InitPlusCheck() == False: exit() if com.InitTradeInit() == False: exit() self.acc_no = com.g_objCpTrade.AccountNumber[0] # 계좌번호 self.acc_tp = com.g_objCpTrade.GoodsList(self.acc_no, 1) # 주식상품 구분 ##################################################################### # logger self.logger = logging.getLogger("my_setting") self.logger = LoggerAdapter(CpOdrWindow.__name__, self.logger) self.logger.debug(f'CpOdrWindow Start {self.acc_no} {self.acc_tp}') ##################################################################### # 전략, 체결 self.strtgyData = CpOdr.StrtgyData() ##################################################################### # 체결 data class self.stkConData = CpOdr.StkConData() self.objSBCon = CpOdr.CpSBConclusion() ##################################################################### # 체겷 Subscribe # def monitorCon(self): 실시간 업데이트 self.objSBCon.Subscribe(self.stkConData, self) ##################################################################### # 잔고 self.objBlnc = CpOdr.Cp6033() ##################################################################### # stock object self.stkCurData = CpData.StkCurData() self.stkTickData = CpData.StkTickData() # 주문 현재가/10차 호가 저장 self.objSBCur = CpData.CpSBStockCur() self.objSBbid = CpData.CpSBStockBid() ##################################################################### # db object self.objDB = CpDB.CpDB() self.setWindowTitle("PLUS API TEST") self.setGeometry(300, 300, 300, 700) nH = 20 btnBuy = QPushButton("매수/매도 주문", self) btnBuy.move(20, nH) # btnBuy.resize(200,30) btnBuy.clicked.connect(self.btnBuy_clicked) nH += 50 btnExit = QPushButton("종료", self) btnExit.move(20, nH) # btnExit.resize(200,30) btnExit.clicked.connect(self.btnExit_clicked) nH += 50 btnMst = QPushButton("기본정보", self) btnMst.move(20, nH) # btnExit.resize(200,30) btnMst.clicked.connect(self.btnMst_clicked) nH += 50 btnInv = QPushButton("투자자종합", self) btnInv.move(20, nH) btnInv.clicked.connect(self.btnInv_clicked)
def __init__(self): super().__init__() # 기본 변수들 self.dates = [] self.opens = [] self.highs = [] self.lows = [] self.closes = [] self.vols = [] self.times = [] self.diff = [] self.sign = [] self.item = [] self.objChart = CpStockChart() from_day = dt.today() - timedelta(days=7) from_day = from_day.strftime("%Y%m%d") today = dt.today().strftime("%Y%m%d") # 윈도우 버튼 배치 self.setWindowTitle("PLUS API TEST") nH = 20 self.codeEdit = QLineEdit("", self) self.codeEdit.move(20, nH) self.codeEdit.setText('005930') self.codeEdit.textChanged.connect(self.codeEditChanged) self.label = QLabel('종목코드', self) self.label.move(140, nH) nH += 50 btchart1= QPushButton("기간(일간) 요청", self) btchart1.move(20, nH) btchart1.clicked.connect(self.btchart1_clicked) self.fromdtEdit = QLineEdit("", self) self.fromdtEdit.setText(from_day) self.fromdtEdit.move(140, nH) self.todtEdit = QLineEdit("", self) self.todtEdit.setText(today) self.todtEdit.move(250, nH) self.tickEdit = QLineEdit("", self) self.tickEdit.setText("D") self.tickEdit.move(350, nH) self.fromdtEdit.textChanged.connect(self.fromdtEditChanged) self.todtEdit.textChanged.connect(self.todtEditChanged) self.tickEdit.textChanged.connect(self.tickEditChanged) nH += 50 btchart2 = QPushButton("개수(일간) 요청", self) btchart2.move(20, nH) btchart2.clicked.connect(self.btchart2_clicked) nH += 50 btchart3 = QPushButton("분차트 요청", self) btchart3.move(20, nH) btchart3.clicked.connect(self.btchart3_clicked) nH += 50 btchart4 = QPushButton("틱차트 요청", self) btchart4.move(20, nH) btchart4.clicked.connect(self.btchart4_clicked) nH += 50 btchart5 = QPushButton("주간차트 요청", self) btchart5.move(20, nH) btchart5.clicked.connect(self.btchart5_clicked) nH += 50 btchart6 = QPushButton("월간차트 요청", self) btchart6.move(20, nH) btchart6.clicked.connect(self.btchart6_clicked) nH += 50 btchart7 = QPushButton("엑셀로 저장", self) btchart7.move(20, nH) btchart7.clicked.connect(self.btchart7_clicked) nH += 50 btnExit = QPushButton("종료", self) btnExit.move(20, nH) btnExit.clicked.connect(self.btnExit_clicked) nH += 50 ##################################################################### # UI size self.setGeometry(200, 400, 400, nH) ##################################################################### # 초기값 설정 self.setCode('005930') self.fromdt=self.fromdtEdit.text() self.todt=self.todtEdit.text() self.ticktp = self.tickEdit.text() ##################################################################### # Tcp 통신 """ self.config = ConfigParser() self.config.read('config.ini') order = self.config['ORDER'] print('order["IP"]', order["IP"], int(order["PORT"])) ord_form = (order["IP"], int(order["PORT"])) self.ord_sock = TcpClient.OrderPort(ord_form) """ ##################################################################### # Order # plus 상태 체크 pythoncom.CoInitialize() if com.InitPlusCheck() == False: exit() if com.InitTradeInit() == False: exit() self.objOdr = CpOdr.CpOrder() self.acc_no = com.g_objCpTrade.AccountNumber[0] # 계좌번호 ##################################################################### # 체결 self.stkConData = CpOdr.StkConData() self.objSBCon = CpOdr.CpSBConclusion() self.objSBCon.Subscribe(self.stkConData, self) ##################################################################### # logger self.logger = logging.getLogger("my_setting") self.logger = LoggerAdapter(CpChartWindow.__name__, self.logger) self.logger.debug(f'CpChartWindow Start') print("CpChartWindow Start")