Esempio n. 1
0
        /// <summary>
        ///[16]설명 종목코드의 한글명을 반환한다.
        ///입력값 strCode – 종목코드
        ///반환값 종목한글명
        /// 비고 장내외, 지수선옵, 주식선옵 검색 가능.
        /// </summary>
        public String GetMasterCodeName(String strCode)
        {
            String ret = axKHOpenAPI.GetMasterCodeName(strCode);

            FileLog.PrintF("GetMasterCodeName(" + strCode + "):" + ret);
            return(ret);
        }
Esempio n. 2
0
        public void SaveItemLogMessage(string itemCode, string logMessage)
        {
            StackFrame callStack = new StackFrame(1, true);

            logMessage = DateTime.Now.ToString("[HH:mm:ss] ") + logMessage + " (" + Path.GetFileName(callStack.GetFileName()) + ") line : " + callStack.GetFileLineNumber();
            string itemName = axKHOpenAPI.GetMasterCodeName(itemCode);

            if (logMessageItem.ContainsKey(itemName))
            {
                logMessageItem[itemName] += Environment.NewLine;
                logMessageItem[itemName] += logMessage;
            }
            else
            {
                logMessageItem.Add(itemName, logMessage);
            }

            string filePath = DateTime.Now.ToString("yyyyMMdd_") + itemName + "_log.txt";

            FileInfo fi = new FileInfo(filePath);

            try
            {
                if (fi.Exists)
                {
                    using (StreamWriter sw = File.AppendText(filePath))
                    {
                        sw.WriteLine(logMessage);
                    }
                }
                else
                {
                    using (StreamWriter sw = new StreamWriter(filePath))
                    {
                        sw.WriteLine(logMessage);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                //SendLogMessage(e.Message);
            }
        }
Esempio n. 3
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));
            }
        }