Exemplo n.º 1
0
        public override void ReceivedData(AxKHOpenAPILib.AxKHOpenAPI axKHOpenAPI, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
        {
            /*
             *
             *  [27] = (최우선)매도호가         //(0)
             *  [28] = (최우선)매수호가         //(1)
             */
            FileLog.PrintF(String.Format("최우선_매도호가 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim()));   //[0]
            FileLog.PrintF(String.Format("최우선_매수호가 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim()));   //[1]
            FileLog.PrintF(String.Format("종목코드 : {0} ==>", e.sRealKey.ToString().Trim()));
            FileLog.PrintF(String.Format("RealName : {0} ==>", e.sRealType.ToString().Trim()));
            FileLog.PrintF(String.Format("sRealData : {0} ==>", e.sRealData.ToString().Trim()));

            String         현재시간           = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            REAL10003_Data real10003_data = new REAL10003_Data();

            real10003_data.현재시간     = 현재시간;
            real10003_data.최우선_매도호가 = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim()); //[0]
            real10003_data.최우선_매수호가 = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim()); //[1]
            real10003_data.종목코드     = e.sRealKey.ToString().Trim();                                     //[2]
            real10003_data.RealName = e.sRealType.ToString().Trim();                                    //[3]

            SendDirectFile(real10003_data);
            SendDirectDb(real10003_data);
        }
Exemplo n.º 2
0
        private void OnReceiveRealDataEventHandler(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
        {
            //Console.WriteLine("[DEBUG] OnReceiveRealData - e.sRealKey : " + e.sRealKey + ", e.sRealType : " + e.sRealType + ", e.sRealData : " + e.sRealData);
            // 보유 종목에 있을 경우 값 업데이트
            string market = openApi.GetCommRealData(e.sRealKey, 290).Trim();

            if (market.Equals("2")) // 장 중
            {
                Holding holding = holdings.SingleOrDefault(item => item.StockNo.Contains(e.sRealKey));
                if (holding != null)
                {
                    long currentPrice = long.Parse(Regex.Replace(openApi.GetCommRealData(e.sRealKey, 10).Trim(), @"[^0-9]", ""));
                    holding.CurrentPrice = String.Format("{0:#,###0}", currentPrice);
                }

                ConditionStock conditionStock = conditionStocks.SingleOrDefault(item => item.StockNo.Contains(e.sRealKey));
                if (conditionStock != null)
                {
                    long currentPrice = long.Parse(Regex.Replace(openApi.GetCommRealData(e.sRealKey, 10).Trim(), @"[^0-9]", ""));
                    conditionStock.CurrentPrice = String.Format("{0:#,###0}", currentPrice);

                    float fluctuationRate = float.Parse(openApi.GetCommRealData(e.sRealKey, 12).Trim());
                    conditionStock.FluctuationRate = String.Format("{0:f2}", fluctuationRate);

                    // 주문 목록에 없고, 보유종목에 없으면 매수
                    // 주문이 들어가기 전에 한번 더 요청이 오면? 안되겠군..
                    // 조건 검색에 편입되는 순간 확인하고..큐에 넣고 큐를 뒤져야하나?
                    // 편입, 이탈이 반복되는 경우는 어떻게 하지?
                    if (holding != null)
                    {
                    }
                }
            }
        }
Exemplo n.º 3
0
    private void API_OnReceiveRealData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
    {
        string itemCode = e.sRealKey.Trim();


        if (e.sRealType == ConstName.RECEIVE_REAL_DATA_CONCLUSION)         //주식이 체결될 때 마다 실시간 데이터를 받음
        {
            string price     = axKHOpenAPI1.GetCommRealData(itemCode, 10); //현재가
            string lowPrice  = axKHOpenAPI1.GetCommRealData(itemCode, 18); //저가
            string openPrice = axKHOpenAPI1.GetCommRealData(itemCode, 16); //시가

            long c_lPrice = Math.Abs(long.Parse(price));
        }
    }
Exemplo n.º 4
0
        public void axKHOpenAPI_OnReceiveRealData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
        {
            string itemCode = e.sRealKey.Trim();

            if (e.sRealType.Contains(ConstName.RECEIVE_REAL_DATA_HOGA) || e.sRealType.Contains(ConstName.RECEIVE_REAL_DATA_USUN_HOGA))
            {
                StockWithBiddingEntity newObj = new StockWithBiddingEntity();
                newObj.Code = itemCode;

                int maxAmount = 0;
                for (int i = 0; i < 10; i++)
                {
                    string sellhoga = axKHOpenAPI.GetCommRealData(e.sRealType, 50 - i).Trim().Replace("+", "");
                    string sellqnt  = axKHOpenAPI.GetCommRealData(e.sRealType, 70 - i).Trim();
                    //잔량대비 = axKHOpenAPI1.GetCommRealData(e.sRealType, 90 - i).Trim(),
                    if (!string.IsNullOrEmpty(sellhoga))
                    {
                        newObj.SetSellHoga(i, long.Parse(sellhoga));
                    }
                    if (!string.IsNullOrEmpty(sellqnt))
                    {
                        newObj.SetSellQnt(i, long.Parse(sellqnt));
                    }


                    string buyhoga = axKHOpenAPI.GetCommRealData(e.sRealType, 51 + i).Trim().Replace("+", "");
                    string buyqnt  = axKHOpenAPI.GetCommRealData(e.sRealType, 71 + i).Trim();
                    if (!string.IsNullOrEmpty(buyhoga))
                    {
                        newObj.SetBuyHoga(i, long.Parse(buyhoga));
                    }
                    if (!string.IsNullOrEmpty(buyqnt))
                    {
                        newObj.SetBuyQnt(i, long.Parse(buyqnt));
                    }
                    //    잔량대비 = axKHOpenAPI1.GetCommRealData(e.sRealType, 91 + i).Trim(),

                    //int sellAmount = int.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 70 - i).Trim());
                    //int buyAmount = int.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 71 + i).Trim());

                    //if (maxAmount < sellAmount)
                    //    maxAmount = sellAmount;
                    //if (maxAmount < buyAmount)
                    //    maxAmount = buyAmount;
                }

                StockWithBiddingManager.GetInstance().SetItem(newObj);
            }
        }
Exemplo n.º 5
0
        private void AxKHOpenAPI_OnReceiveRealData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
        {
            if (e.sRealType == "주식체결")
            {
                double conclusionVolume = double.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 15));

                if (exceptList.Contains(conclusionVolume))
                {
                    return;
                }

                int    conclusionTime = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 20));
                double curPrice       = double.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 10));
                if (curPrice < 0)
                {
                    curPrice *= -1;
                }
                int    gapPrice            = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 11));
                double gapPercentage       = double.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 12));
                double allConclusionVolume = double.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 13));

                int hour    = conclusionTime / 10000;
                int minutes = conclusionTime / 100 % 100;
                int second  = conclusionTime % 100;

                int realTime = hour * 3600 + minutes * 60 + second;

                if (allConclusionVolume >= VOLUME_UP_BUY || allConclusionVolume <= VOLUME_UP_SELL)
                {
                    ThreadPool.QueueUserWorkItem(StockItemElementMgr.GetInstance().ThreadPoolCallBack, new TradeData(e.sRealKey, curPrice, realTime, conclusionVolume));
                }

                if (myStockItem.myStockItemDic.ContainsKey(e.sRealKey))
                {
                    myStockItem.myStockItemDic[e.sRealKey].curPrice      = curPrice;
                    myStockItem.myStockItemDic[e.sRealKey].curVolume     = conclusionVolume;
                    myStockItem.myStockItemDic[e.sRealKey].gapPercentage = gapPercentage;
                    myStockItem.myStockItemDic[e.sRealKey].gapPrice      = gapPrice;
                }
                else
                {
                    SavedStockItem savedStockItme = new SavedStockItem(e.sRealKey.Trim().Replace("A", ""), axKHOpenAPI.GetMasterCodeName(e.sRealKey), gapPercentage, gapPrice, curPrice, conclusionVolume);
                    myStockItem.myStockItemDic.Add(e.sRealKey, savedStockItme);
                }

                OnReceiveRealDataHandler?.Invoke(this, new StockEventArgs(myStockItem));
            }
        }
Exemplo n.º 6
0
        public override void ReceivedData(AxKHOpenAPILib.AxKHOpenAPI axKHOpenAPI, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
        {
            /*
             *
             *  [10] = 현재가              //(0)
             *      [11] = 전일대비            //(1)
             *      [12] = 등락율              //(2)
             *      [27] = (최우선)매도호가    //(3)
             *      [28] = (최우선)매수호가    //(4)
             *      [13] = 누적거래량          //(5)
             *      [14] = 누적거래대금        //(6)
             *      [16] = 시가                //(7)
             *      [17] = 고가                //(8)
             *      [18] = 저가                //(9)
             *      [25] = 전일대비기호        //(10)
             *      [26] = 전일거래량대비(계약,주)   //(11)
             *      [29] = 거래대금증감              //(12)
             *      [30] = 전일거래량대비(비율)      //(13)
             *      [31] = 거래회전율                //(14)
             *      [32] = 거래비용                  //(15)
             *      [311] = 시가총액(억)             //(16)
             *      [567] = 상한가발생시간           //(17)
             *      [568] = 하한가발생시간           //(18)
             *
             */
            /*
             * FileLog.PrintF(String.Format("현재가 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 10).Trim()));
             * FileLog.PrintF(String.Format("전일대비 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 11).Trim()));
             * FileLog.PrintF(String.Format("등락율 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 12).Trim()));
             * FileLog.PrintF(String.Format("매도호가 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim()));
             * FileLog.PrintF(String.Format("매수호가 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim()));
             * FileLog.PrintF(String.Format("누적거래량 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 13).Trim()));
             * FileLog.PrintF(String.Format("누적거래대금 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 14).Trim()));
             * FileLog.PrintF(String.Format("시가 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 16).Trim()));
             * FileLog.PrintF(String.Format("고가 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 17).Trim()));
             * FileLog.PrintF(String.Format("저가 : {0}  ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 18).Trim()));
             * FileLog.PrintF(String.Format("전일대비기호 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 25).Trim()));
             * FileLog.PrintF(String.Format("전일거래량대비_계약_주 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 26).Trim()));
             * FileLog.PrintF(String.Format("거래대금증감 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 29).Trim()));
             * FileLog.PrintF(String.Format("전일거래량대비_비율 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 30).Trim()));
             * FileLog.PrintF(String.Format("거래회전율 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 31).Trim()));
             * FileLog.PrintF(String.Format("거래비용 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 32).Trim()));
             * FileLog.PrintF(String.Format("시가총액_억 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 311).Trim()));
             * FileLog.PrintF(String.Format("상한가발생시간 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 567).Trim()));
             * FileLog.PrintF(String.Format("하한가발생시간 : {0} ==>", axKHOpenAPI.GetCommRealData(e.sRealType, 568).Trim()));
             * FileLog.PrintF(String.Format("종목코드 : {0} ==>", e.sRealKey.ToString().Trim()));
             * FileLog.PrintF(String.Format("RealName : {0} ==>", e.sRealType.ToString().Trim()));
             * FileLog.PrintF(String.Format("sRealData : {0} ==>", e.sRealData.ToString().Trim()));
             */
            REAL10001_Data real10001_data = new REAL10001_Data();

            //String 현재시간 = DateTime.Now.ToString("yyyyMMdd HH:mm:ss:fff");
            real10001_data.현재시간 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            real10001_data.현재가          = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 10).Trim());
            real10001_data.전일대비         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 11).Trim());
            real10001_data.등락율          = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 12).Trim());
            real10001_data.매도호가         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim());
            real10001_data.매수호가         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim());
            real10001_data.누적거래량        = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 13).Trim());
            real10001_data.누적거래대금       = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 14).Trim());
            real10001_data.시가           = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 16).Trim());
            real10001_data.고가           = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 17).Trim());
            real10001_data.저가           = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 18).Trim());
            real10001_data.전일대비기호       = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 25).Trim());
            real10001_data.전일거래량대비_계약_주 = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 26).Trim());
            real10001_data.거래대금증감       = decimal.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 29).Trim());
            real10001_data.전일거래량대비_비율   = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 30).Trim());
            real10001_data.거래회전율        = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 31).Trim());
            real10001_data.거래비용         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 32).Trim());
            real10001_data.시가총액_억       = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 311).Trim());
            real10001_data.상한가발생시간      = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 567).Trim());
            real10001_data.하한가발생시간      = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 568).Trim());
            real10001_data.종목코드         = e.sRealKey.ToString().Trim();
            real10001_data.RealName     = e.sRealType.ToString().Trim();

            //        SendDirectFile(real10001_data);
            SendDirectDb(real10001_data);
        }
Exemplo n.º 7
0
        public override void ReceivedData(AxKHOpenAPILib.AxKHOpenAPI axKHOpenAPI, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
        {
            /*
             *
             *  [20] = 체결시간            //(0)
             *  [10] = 현재가              //(1)
             *      [11] = 전일대비            //(2)
             *      [12] = 등락율              //(3)
             *      [27] = (최우선)매도호가    //(4)
             *      [28] = (최우선)매수호가    //(5)
             *  [15] = 거래량              //(6)
             *      [13] = 누적거래량          //(7)
             *      [14] = 누적거래대금        //(8)
             *      [16] = 시가                //(9)
             *      [17] = 고가                //(10)
             *      [18] = 저가                //(11)
             *      [25] = 전일대비기호        //(12)
             *      [26] = 전일거래량대비(계약,주)   //(13)
             *      [29] = 거래대금증감              //(14)
             *      [30] = 전일거래량대비(비율)      //(15)
             *      [31] = 거래회전율                //(16)
             *      [32] = 거래비용                  //(17)
             *  [228] = 체결강도                 //(18)
             *      [311] = 시가총액(억)             //(19)
             *  [290] = 장구분                   //(20)
             *  [691] = KO접근도                 //(21)
             *      [567] = 상한가발생시간           //(22)
             *      [568] = 하한가발생시간           //(23)
             *
             */
            /*
             * FileLog.PrintF(String.Format("체결시간=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 20).Trim()));   //[0]
             * FileLog.PrintF(String.Format("현재가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 10).Trim()));     //[1]
             * FileLog.PrintF(String.Format("전일대비=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 11).Trim()));   //[2]
             * FileLog.PrintF(String.Format("등락율=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 12).Trim()));     //[3]
             * FileLog.PrintF(String.Format("(최우선)매도호가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim()));   //[4]
             * FileLog.PrintF(String.Format("(최우선)매수호가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim()));   //[5]
             * FileLog.PrintF(String.Format("거래량=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 15).Trim()));      //[6]
             * FileLog.PrintF(String.Format("누적거래량=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 13).Trim()));   //[7]
             * FileLog.PrintF(String.Format("누적거래대금=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 14).Trim())); //[8]
             * FileLog.PrintF(String.Format("시가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 16).Trim()));          //[9]
             * FileLog.PrintF(String.Format("고가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 17).Trim()));          //[10]
             * FileLog.PrintF(String.Format("저가=>{0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 18).Trim()));         //[11]
             * FileLog.PrintF(String.Format("전일대비기호=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 25).Trim()));  //[12]
             * FileLog.PrintF(String.Format("전일거래량대비_계약_주=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 26).Trim()));  //[13]
             * FileLog.PrintF(String.Format("거래대금증감=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 29).Trim()));             //[14]
             * FileLog.PrintF(String.Format("전일거래량대비_비율=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 30).Trim()));      //[15]
             * FileLog.PrintF(String.Format("거래회전율=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 31).Trim()));               //[16]
             * FileLog.PrintF(String.Format("거래비용=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 32).Trim()));               //[17]
             * FileLog.PrintF(String.Format("체결강도=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 228).Trim()));               //[18]
             * FileLog.PrintF(String.Format("시가총액_억=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 311).Trim()));               //[19]
             * FileLog.PrintF(String.Format("장구분=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 290).Trim()));               //[20]
             * FileLog.PrintF(String.Format("KO접근도=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 691).Trim()));               //[21]
             * FileLog.PrintF(String.Format("상한가발생시간=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 567).Trim()));         //[22]
             * FileLog.PrintF(String.Format("하한가발생시간=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 568).Trim()));         //[23]
             * FileLog.PrintF(String.Format("종목코드=> {0} ", e.sRealKey.ToString().Trim()));
             * FileLog.PrintF(String.Format("RealName=> {0} ", e.sRealType.ToString().Trim()));
             * FileLog.PrintF(String.Format("sRealData=> {0} ", e.sRealData.ToString().Trim()));
             */
            String 현재일자    = DateTime.Now.ToString("yyyy-MM-dd");
            String 체결시간TMP = axKHOpenAPI.GetCommRealData(e.sRealType, 20).Trim();           //[0]
            //체결시간이 6자리이므로 HHMMSS ==> HH:MM:SS로 바꿔야한다.
            String 체결시간 = 체결시간TMP.Substring(0, 2) + ":" + 체결시간TMP.Substring(2, 2) + ":" + 체결시간TMP.Substring(4, 2);

            체결시간 = 현재일자 + " " + 체결시간;

            REAL10002_Data real10002_data = new REAL10002_Data();

            //String 현재시간 = DateTime.Now.ToString("yyyyMMdd HH:mm:ss:fff");
            real10002_data.체결시간         = 체결시간;
            real10002_data.현재가          = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 10).Trim());   //[1]
            real10002_data.전일대비         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 11).Trim());   //[2]
            real10002_data.등락율          = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 12).Trim());   //[3]
            real10002_data.매도호가         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim());   //[4]
            real10002_data.매수호가         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim());   //[5]
            real10002_data.거래량          = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 15).Trim());   //[6]
            real10002_data.누적거래량        = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 13).Trim());   //[7]
            real10002_data.누적거래대금       = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 14).Trim());   //[8]
            real10002_data.시가           = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 16).Trim());   //[9]
            real10002_data.고가           = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 17).Trim());   //[10]
            real10002_data.저가           = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 18).Trim());   //[11]
            real10002_data.전일대비기호       = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 25).Trim());   //[12]
            real10002_data.전일거래량대비_계약_주 = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 26).Trim());   //[13]
            real10002_data.거래대금증감       = decimal.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 29).Trim()); //[14]
            real10002_data.전일거래량대비_비율   = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 30).Trim());   //[15]
            real10002_data.거래회전율        = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 31).Trim());   //[16]
            real10002_data.거래비용         = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 32).Trim());   //[17]
            real10002_data.체결강도         = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 228).Trim());  //[18]
            real10002_data.시가총액_억       = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 311).Trim());  //[19]
            real10002_data.장구분          = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 290).Trim());  //[20]
            real10002_data.KO접근도        = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 691).Trim());  //[21]
            real10002_data.상한가발생시간      = axKHOpenAPI.GetCommRealData(e.sRealType, 567).Trim();               //[22]
            real10002_data.하한가발생시간      = axKHOpenAPI.GetCommRealData(e.sRealType, 568).Trim();               //[23]
            real10002_data.종목코드         = e.sRealKey.ToString().Trim();                                       //[24]
            real10002_data.RealName     = e.sRealType.ToString().Trim();

            MyStock.getClass1Instance().UpdateStockList(real10002_data);

            //   SendDirectFile(real10002_data);
            SendDirectDb(real10002_data);
        }
Exemplo n.º 8
0
        public override void ReceivedData(AxKHOpenAPILib.AxKHOpenAPI axKHOpenAPI, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e)
        {
            /*
             *
             *  [20] = 체결시간            //(0)
             *  [10] = 현재가              //(1)
             *      [11] = 전일대비            //(2)
             *      [12] = 등락율              //(3)
             *      [27] = (최우선)매도호가    //(4)
             *      [28] = (최우선)매수호가    //(5)
             *  [15] = 거래량              //(6)
             *      [13] = 누적거래량          //(7)
             *      [14] = 누적거래대금        //(8)
             *      [16] = 시가                //(9)
             *      [17] = 고가                //(10)
             *      [18] = 저가                //(11)
             *      [25] = 전일대비기호        //(12)
             *      [26] = 전일거래량대비(계약,주)   //(13)
             *      [29] = 거래대금증감              //(14)
             *      [30] = 전일거래량대비(비율)      //(15)
             *      [31] = 거래회전율                //(16)
             *      [32] = 거래비용                  //(17)
             *  [228] = 체결강도                 //(18)
             *      [311] = 시가총액(억)             //(19)
             *  [290] = 장구분                   //(20)
             *  [691] = KO접근도                 //(21)
             *      [567] = 상한가발생시간           //(22)
             *      [568] = 하한가발생시간           //(23)
             * //[2020-04-02 10:18:30]종목코드 : 005930 | RealType : 주식체결 |
             * RealData : 101829	-45600	-200	-0.44	-45600	-45550	+240	7648579	351335	+46200	+46250	-45350	5	-19610953	-931147601650	-28.06	0.13	129	78.06	2722221	2	0	-27.39	000000	000000	10825	090018	090526	090159	4001191	3123474	-43.84	10171	23587	+10944	 0	+240	+240	4560	3648	45935	252
             * [2020-04-02 10:40:28]체결시간=> 104027
             * [2020-04-02 10:40:28]현재가=> 45800
             * [2020-04-02 10:40:28]전일대비=> 0
             * [2020-04-02 10:40:28]등락율=> 0.00
             * [2020-04-02 10:40:28](최우선)매도호가=> 45800
             * [2020-04-02 10:40:28](최우선)매수호가=> -45750
             * [2020-04-02 10:40:28]거래량=> +1
             * [2020-04-02 10:40:28]누적거래량=> 8718082
             * [2020-04-02 10:40:28]누적거래대금=> 400224
             * [2020-04-02 10:40:28]시가=> +46200
             * [2020-04-02 10:40:28]고가=> +46250
             * [2020-04-02 10:40:28]저가=>-45350
             * [2020-04-02 10:40:28]전일대비기호=> 3
             * [2020-04-02 10:40:28]전일거래량대비_계약_주=> -18541450
             * [2020-04-02 10:40:28]거래대금증감=> -882258926600
             * [2020-04-02 10:40:28]전일거래량대비_비율=> -31.98
             * [2020-04-02 10:40:28]거래회전율=> 0.15
             * [2020-04-02 10:40:28]거래비용=> 129
             * [2020-04-02 10:40:28]체결강도=> 82.85
             * [2020-04-02 10:40:28]시가총액_억=> 2734160
             * [2020-04-02 10:40:28]장구분=> 2
             * [2020-04-02 10:40:28]KO접근도=> 0
             * [2020-04-02 10:40:28]상한가발생시간=> 000000
             * [2020-04-02 10:40:28]하한가발생시간=> 000000
             * [2020-04-02 10:40:28]종목코드=> 005930
             * [2020-04-02 10:40:28]RealName=> 주식체결
             */
            /*
             * FileLog.PrintF(String.Format("체결시간=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 20).Trim()));   //[0]
             * FileLog.PrintF(String.Format("현재가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 10).Trim()));     //[1]
             * FileLog.PrintF(String.Format("전일대비=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 11).Trim()));   //[2]
             * FileLog.PrintF(String.Format("등락율=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 12).Trim()));     //[3]
             * FileLog.PrintF(String.Format("(최우선)매도호가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim()));   //[4]
             * FileLog.PrintF(String.Format("(최우선)매수호가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim()));   //[5]
             * FileLog.PrintF(String.Format("거래량=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 15).Trim()));      //[6]
             * FileLog.PrintF(String.Format("누적거래량=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 13).Trim()));   //[7]
             * FileLog.PrintF(String.Format("누적거래대금=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 14).Trim())); //[8]
             * FileLog.PrintF(String.Format("시가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 16).Trim()));          //[9]
             * FileLog.PrintF(String.Format("고가=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 17).Trim()));          //[10]
             * FileLog.PrintF(String.Format("저가=>{0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 18).Trim()));         //[11]
             * FileLog.PrintF(String.Format("전일대비기호=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 25).Trim()));  //[12]
             * FileLog.PrintF(String.Format("전일거래량대비_계약_주=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 26).Trim()));  //[13]
             * FileLog.PrintF(String.Format("거래대금증감=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 29).Trim()));             //[14]
             * FileLog.PrintF(String.Format("전일거래량대비_비율=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 30).Trim()));      //[15]
             * FileLog.PrintF(String.Format("거래회전율=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 31).Trim()));               //[16]
             * FileLog.PrintF(String.Format("거래비용=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 32).Trim()));               //[17]
             * FileLog.PrintF(String.Format("체결강도=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 228).Trim()));               //[18]
             * FileLog.PrintF(String.Format("시가총액_억=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 311).Trim()));               //[19]
             * FileLog.PrintF(String.Format("장구분=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 290).Trim()));               //[20]
             * FileLog.PrintF(String.Format("KO접근도=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 691).Trim()));               //[21]
             * FileLog.PrintF(String.Format("상한가발생시간=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 567).Trim()));         //[22]
             * FileLog.PrintF(String.Format("하한가발생시간=> {0} ", axKHOpenAPI.GetCommRealData(e.sRealType, 568).Trim()));         //[23]
             * FileLog.PrintF(String.Format("종목코드=> {0} ", e.sRealKey.ToString().Trim()));
             * FileLog.PrintF(String.Format("RealName=> {0} ", e.sRealType.ToString().Trim()));
             * FileLog.PrintF(String.Format("sRealData=> {0} ", e.sRealData.ToString().Trim()));
             */
            try
            {
                String 현재일자    = DateTime.Now.ToString("yyyyMMdd");
                String 체결시간TMP = axKHOpenAPI.GetCommRealData(e.sRealType, 20).Trim();           //[0]
                                                                                                //체결시간이 6자리이므로 HHMMSS ==> HH:MM:SS로 바꿔야한다.
                TB_REALTIME_CONTRACT real10002_data = new TB_REALTIME_CONTRACT();
                //String 현재시간 = DateTime.Now.ToString("yyyyMMdd HH:mm:ss:fff");
                real10002_data.real_name                    = e.sRealType.ToString().Trim();
                real10002_data.stock_cd                     = e.sRealKey.ToString().Trim();
                real10002_data.stock_dt                     = 현재일자;
                real10002_data.contract_time                = 체결시간TMP;
                real10002_data.curr_amt                     = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 10).Trim());  //[1]
                real10002_data.contrast_yesterday           = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 11).Trim());  //[2]
                real10002_data.fluctuation_rt               = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 12).Trim());  //[3]
                real10002_data.offered_amt                  = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 27).Trim());  //[4]
                real10002_data.bid_amt                      = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 28).Trim());  //[5]
                real10002_data.trade_qty                    = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 15).Trim());  //[6]
                real10002_data.accumulated_trade_qty        = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 13).Trim());  //[7]
                real10002_data.accumulated_trade_amt        = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 14).Trim());  //[8]
                real10002_data.start_amt                    = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 16).Trim());  //[9]
                real10002_data.high_amt                     = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 17).Trim());  //[10]
                real10002_data.low_amt                      = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 18).Trim());  //[11]
                real10002_data.contrast_yesterday_symbol    = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 25).Trim());  //[12]
                real10002_data.yesterday_contrast_trade_qty = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 26).Trim());  //[13]
                real10002_data.trade_amount_variation       = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 29).Trim());  //[14]
                real10002_data.yesterday_contrast_trade_rt  = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 30).Trim());  //[15]
                real10002_data.trade_turnover_ratio         = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 31).Trim());  //[16]
                real10002_data.trade_cost                   = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 32).Trim());  //[17]
                real10002_data.contract_strength            = float.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 228).Trim()); //[18]
                real10002_data.total_market_amt             = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 311).Trim()); //[19]
                real10002_data.market_gubun                 = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 290).Trim()); //[20]
                real10002_data.ko_accessibility_rt          = Int32.Parse(axKHOpenAPI.GetCommRealData(e.sRealType, 691).Trim()); //[21]
                real10002_data.upper_amt_limit_time         = axKHOpenAPI.GetCommRealData(e.sRealType, 567).Trim();              //[22]
                real10002_data.lower_amt_limit_time         = axKHOpenAPI.GetCommRealData(e.sRealType, 568).Trim();              //[23]


                //MyStock.getClass1Instance().UpdateStockList(real10002_data);

                RealTimeData realTimeData = new RealTimeData();
                realTimeData.insertRealtimeContract(real10002_data);
            } catch (Exception ex)
            {
                FileLog.PrintF("[REAL10002]Exception ex=" + ex.Message);
                //{ "42883: insert_tb_stock(p_market_cd => text, p_stock_cd => text, p_stock_nm => text, p_stock_dt => text, p_cnt => integer, p_last_price => text, p_stock_state => text, p_construction => text) 이름의 함수가 없음"}
                //		Message	"42601: 구문 오류, 입력 끝부분"	string
            }
        }