Example #1
0
 public DataController()
 {
     myStockItem         = new MyStockItem();
     stockItemElementMgr = StockItemElementMgr.GetInstance();
     exceptList          = new List <double>();
     codeNameHashTable   = new Hashtable();
 }
Example #2
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));
            }
        }