Esempio n. 1
0
        private void axKHOpenAPI_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            if (e.strCodeList == "")
            {
                return;
            }

            var codeNameList = e.strCodeList.Split(';').Where(x => x != "").ToList();

            if (e.strConditionName == ConditionName.최근결산PER30)
            {
                var longTermBuySetInfoList = new Dictionary <string, BuyStockInfo>();
                foreach (var codeName in codeNameList)
                {
                    var longTermBuySetInfo = new BuyStockInfo();
                    longTermBuySetInfo.code = codeName;
                    longTermBuySetInfoList.Add(codeName, longTermBuySetInfo);
                }
                var serializeCodeList = JsonConvert.SerializeObject(longTermBuySetInfoList);
                // LongTermBuyListKey 에 코드 리스트 저장.
                RedisConnector.SetString(LongTermBuyListKey, serializeCodeList, IsRealServer);

                foreach (var codeName in codeNameList)
                {
                    KHConnector.Instance.GetStockBasicInfo(codeName);
                    System.Threading.Thread.Sleep(400);
                }
            }
        }
Esempio n. 2
0
        public void onReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            if (e.strCodeList.Length > 0)
            {
                string stockCodeList = e.strCodeList.Remove(e.strCodeList.Length - 1);
                int    stockCount    = stockCodeList.Split(';').Length;
                if (stockCount <= 100)
                {
                    axKHOpenAPI1.CommKwRqData(stockCodeList, 0, stockCount, 0, "조건검색종목", "5100");
                }
                if (e.nNext != 0)
                {
                    axKHOpenAPI1.SendCondition("5101", e.strConditionName, e.nIndex, 1);
                }
                string[] jongCodeList = stockCodeList.Split(';');
                // List<KeyValuePair<string, string>> jongMok = new List<KeyValuePair<string, string>>() ;

                for (int i = 0; i < jongCodeList.Length; i++)
                {
                    string jongMokName = axKHOpenAPI1.GetMasterCodeName(jongCodeList[i]);
                    jongMok.Add(new KeyValuePair <string, string>(jongCodeList[i], jongMokName));
                }

                StrategyStocksDataGridView.DataSource = jongMok;
            }
            else if (e.strCodeList.Length == 0)
            {
                MessageBox.Show("검색된 종목이 없습니다.");
            }
        }
Esempio n. 3
0
 private void axKHOpenAPI_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
 {
     Logger(Log.조회, "[화면번호] : " + e.sScrNo);
     Logger(Log.조회, "[종목리스트] : " + e.strCodeList);
     Logger(Log.조회, "[조건명] : " + e.strConditionName);
     Logger(Log.조회, "[조건명 인덱스 ] : " + e.nIndex.ToString());
     Logger(Log.조회, "[연속조회] : " + e.nNext.ToString());
 }
Esempio n. 4
0
        /// <summary>
        /// 조건검색 요청에대한 서버 응답 수신시 발생하는 이벤트입니다.   종목코드 리스트는 각 종목코드가 ';'로 구분되서 전달됩니다.
        /// BSTR sScrNo,    // 화면번호
        /// BSTR strCodeList,   // 종목코드 리스트
        /// BSTR strConditionName,    // 조건식 이름
        /// int nIndex,   // 조건 고유번호
        /// int nNext   // 연속조회 여부
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void AxKH_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            object Handler;

            Handler = AxKH_RaisedOnReceiveTrCondition;
            if (e.strCodeList == "")
            {
                AxKH_RaisedOnReceiveTrCondition("", "", "", 0, 0);
            }

            AxKH_RaisedOnReceiveTrCondition(e.sScrNo, e.strCodeList, e.strConditionName, e.nIndex, e.nNext);
        }
Esempio n. 5
0
        private void kiwoomApi_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            // 조건검색 요청으로 검색된 종목코드 리스트를 전달하는 이벤트. ';'로 구분
            Console.WriteLine("[DEBUG] OnReceiveTrCondition " + e.sScrNo + " " + e.strCodeList);
            int cnt = e.strCodeList.Trim().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Length;

            if (cnt > 0)
            {
                // 한번에 100 종목을 조회할 수 있는 코드
                //axKHOpenAPI1.CommKwRqData(e.strCodeList.Remove(e.strCodeList.Length - 1), 0, cnt, 0, "조건검색종목", 화면번호_조건검색);
            }
        }
Esempio n. 6
0
 public void axKHOpenAPI_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent apiEvent)
 {
     try {
         Logger.getInstance.print(Log.StockAPI콜백, "[화면번호] : " + apiEvent.sScrNo);
         Logger.getInstance.print(Log.StockAPI콜백, "[종목리스트] : " + apiEvent.strCodeList);
         Logger.getInstance.print(Log.StockAPI콜백, "[조건명] : " + apiEvent.strConditionName);
         Logger.getInstance.print(Log.StockAPI콜백, "[조건명 인덱스 ] : " + apiEvent.nIndex.ToString());
         Logger.getInstance.print(Log.StockAPI콜백, "[연속조회] : " + apiEvent.nNext.ToString());
     }
     catch (AccessViolationException execption) {
         Logger.getInstance.print(Log.에러, "[컨디션 체크 콜백 에러] {0}\n{1}\n{2}", execption.Message, execption.StackTrace, execption.InnerException);
     }
     this.runNextOrderFlag();
 }
Esempio n. 7
0
        // =====================================================<< 조건식 TR 메세지 수신부 >> ================================================//
        // 수신된 종목코드 문자열 분리
        // 최초 조건검색후 종목코드 수신하는곳으로 이후에는 OnReceiveRealCondition 에서 실시간 수신됨 
        // ===================================================================================================================================//

        private void axKHOpenAPI_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            string[] stCode = e.strCodeList.Split(';');

            axKHOpenAPI.CommKwRqData(e.strCodeList, 0, stCode.Length - 1, 0, "관심종목정보요청", GetScrNum());
            logger.Write(LOGTYPE.C, string.Format("[{0}][{1}][{2}", e.sScrNo, e.strConditionName, e.strCodeList));
            for (int i = 0; i < stCode.Length - 1; i++) {
                string strCodeName = axKHOpenAPI.GetMasterCodeName(stCode[i]); // 종목명을 가져온다.

                UpdateDataGridViewData(실시간검색뷰, "종목코드", stCode[i], "종목코드", stCode[i], DATATYPE.STR);
                UpdateDataGridViewData(실시간검색뷰, "종목코드", stCode[i], "상태", "", DATATYPE.STR);
                UpdateDataGridViewData(실시간검색뷰, "종목코드", stCode[i], "종목명", strCodeName, DATATYPE.STR);
                UpdateDataGridViewData(실시간검색뷰, "종목코드", stCode[i], "매수조건식", e.nIndex + "^" + e.strConditionName, DATATYPE.STR);                
            }
        }
Esempio n. 8
0
        private void axKHOpenAPI_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            String codeList = e.strCodeList.Trim();

            if (codeList.Length > 0)
            {
                codeList = codeList.Remove(codeList.Length - 1);
            }
            int nCodeCount = codeList.Trim().Split(';').Length;

            if (e.nNext == 2)    //추가 종목 정보
            {
                axKHOpenAPI1.SendCondition(e.sScrNo, e.strConditionName, e.nIndex, 2);
            }
            axKHOpenAPI1.CommKwRqData(codeList, 0, nCodeCount, 0, "관심종목정보", GetScrNum());
        }
Esempio n. 9
0
        public void onReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            // 분당 1회 제한
            if (e.strCodeList.Length > 0)
            {
                string stockCodeList = e.strCodeList.Remove(e.strCodeList.Length - 1);
                int    stockCount    = stockCodeList.Split(';').Length;

                if (stockCount <= 100)
                {
                    axKHOpenAPI1.CommKwRqData(stockCodeList, 0, stockCount, 0, "조건검색종목", "5100");
                }
            }
            else if (e.strCodeList.Length == 0)
            {
                MessageBox.Show("검색된 종목이 없습니다.");
            }
        }
Esempio n. 10
0
        private void API_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            int    conditionIndex = e.nIndex;
            string codeList       = e.strCodeList;

            string[] codeArray     = codeList.Split(';');
            string   conditionName = e.strConditionName;

            conditionSearchListBox.Items.Add("조건식 인덱스 : " + conditionIndex + " 조건식 이름" + conditionName);
            conditionSearchListBox.Items.Add(codeList);

            foreach (string code in codeArray)
            {
                if (code.Length > 0)
                {
                    string itemName = axKHOpenAPI1.GetMasterCodeName(code);
                    conditionSearchListBox.Items.Add(itemName);
                }
            }
        }
Esempio n. 11
0
        private void kiwoomApi_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            // 조건검색 요청으로 검색된 종목코드 리스트를 전달하는 이벤트. ';'로 구분
            Console.WriteLine("[DEBUG] OnReceiveTrCondition " + e.sScrNo + " " + e.strCodeList);
            int cnt = e.strCodeList.Trim().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Length;

            if (cnt > 0 && cnt <= 100)
            {
                // 실시간 시세 요청

                /*foreach(string code in e.strCodeList.Trim().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                 * {
                 *  conditionStocks.Add(new DetectionStock(code, kiwoomApi.GetMasterCodeName(code)));
                 *  requestRealtimeQuote(SCREEN_NO_CONDITION, code, conditionStocks.Count > 0 ? REALTIME_ADD : REALTIME_NEW);
                 * }*/

                // 한번에 100 종목을 조회할 수 있는 코드
                //axKHOpenAPI1.CommKwRqData(e.strCodeList.Remove(e.strCodeList.Length - 1), 0, cnt, 0, "조건검색종목", 화면번호_조건검색);
            }
        }
Esempio n. 12
0
        private void M_axKHOpenAPI_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            /* OnReceiveTrCondition(LPCTSTR sScrNo, LPCTSTR strCodeList, LPCTSTR strConditionName, int nIndex, int nNext)
             *  이벤트 함수로 종목리스트가 들어옵니다.
             *  -파라메터 설명
             *  sScrNo : 화면번호
             *  strCodeList : 조회된 종목리스트(ex:039490;005930;036570;…;)
             *  strConditionName : 조회된 조건명
             *  nIndex : 조회된 조건명 인덱스
             *  nNext : 연속조회 여부(0:연속조회없음, 2:연속조회 있음) */
            if (e.sScrNo == SCR_NO_SEARCH_CONDITION && OnReceiveTrCondition != null)
            {
                string[] codeList = e.strCodeList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                OnReceiveTrCondition(this, codeList, new ConditionInfo(e.nIndex, e.strConditionName));

                if (e.nNext == 2)
                {
                    m_axKHOpenAPI.SendCondition(e.sScrNo, e.strConditionName, e.nIndex, (int)SearchConditionType.Realtime);
                }
            }
        }
Esempio n. 13
0
 private void axKHOpenAPI1_OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
 {
 }
Esempio n. 14
0
        void OnReceiveTrCondition(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrConditionEvent e)
        {
            try
            {
                string codeList = e.strCodeList.Trim();
                if (codeList[codeList.Length - 1] == ';')
                {
                    codeList = codeList.Remove(codeList.Length - 1);
                }

                int      codeCount     = codeList.Split(';').Length;
                string[] codeListArray = codeList.Split(';');

                int remainder = codeCount % 100;

                Console.WriteLine("종목코드:" + codeList);
                Console.WriteLine("codeCount:" + codeCount);
                Console.WriteLine("nNext:" + e.nNext);

                if (0 < codeCount && codeCount <= 100)
                {
                    axKHOpenAPI1.CommKwRqData(codeList, 0, codeCount, 0, "조건종목정보", "5002"); //OnReceiveTrData 전달
                }
                else if (100 < codeCount)
                {
                    string codeList100 = "";

                    for (int i = 0; i < codeCount; i++)
                    {
                        if ((i + 1) % 100 == 0 && (i + 1) != 1)
                        {
                            codeList100 += codeListArray[i];
                            axKHOpenAPI1.CommKwRqData(codeList100, 0, 100, 0, "조건종목정보_다음", (i + 1).ToString()); //OnReceiveTrData 전달
                            codeList100 = "";
                        }
                        else
                        {
                            if ((i + 1) == codeCount) // 마지막 종목코드 입력
                            {
                                codeList100 = codeList100 + codeListArray[i];
                                axKHOpenAPI1.CommKwRqData(codeList100, 0, remainder, 0, "조건종목정보_다음", (i + 1).ToString()); //OnReceiveTrData 전달
                                codeList100 = "";
                            }
                            else // 종목코드 입력 진행중
                            {
                                codeList100 = codeList100 + codeListArray[i] + ";";
                            }
                        }
                    }
                }

                if (e.nNext != 0)
                {
                    axKHOpenAPI1.SendCondition("5001", e.strConditionName, e.nIndex, 1); //OnReceiveTrCondition 전달
                }
            }
            catch (Exception error)
            {
                Console.WriteLine("OnReceiveTrCondition 메소드 Exception:");
                Console.WriteLine(error.ToString());
            }
        }