Beispiel #1
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);
            }
        }
Beispiel #2
0
        public void axKHOpenAPI_OnReceiveTrData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrDataEvent e)
        {
            if (e.sRQName.Contains(ConstName.RECEIVE_TR_DATA_HOGA))
            {
                StockWithBiddingEntity newObj = new StockWithBiddingEntity();

                string[] rqNameArray = e.sRQName.Split(':');
                if (rqNameArray.Length == 3)
                {
                    string itemCode = rqNameArray[1];
                    newObj.Code = itemCode;
                }
                for (int i = 0; i < 10; i++)
                {
                    if (i == 9)
                    {
                        Console.WriteLine("매도 최우선호가 / 잔량 ");
                        string firstSellHoga = axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매도최우선호가").Trim().Replace("+", "");
                        string firstSellQnt  = axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매도최우선잔량").Trim();
                        if (!string.IsNullOrEmpty(firstSellHoga))
                        {
                            newObj.SetSellHoga(i, long.Parse(firstSellHoga));
                        }
                        if (!string.IsNullOrEmpty(firstSellQnt))
                        {
                            newObj.SetSellQnt(i, long.Parse(firstSellQnt));
                        }
                    }
                    else
                    {
                        Console.WriteLine("매도" + (10 - i) + "차선호가 /잔량");
                        string hoga = (axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매도" + (10 - i) + "차선호가").Trim().Replace("+", ""));
                        string qnt  = (axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매도" + (10 - i) + "차선잔량").Trim());

                        if (!string.IsNullOrEmpty(hoga))
                        {
                            newObj.SetSellHoga(i, long.Parse(hoga));
                        }
                        if (!string.IsNullOrEmpty(qnt))
                        {
                            newObj.SetSellQnt(i, long.Parse(qnt));
                        }
                    }
                }
                for (int i = 0; i < 10; i++)
                {
                    if (i == 0)
                    {
                        Console.WriteLine("매수 최우선호가 / 잔량 ");
                        string firstBuyHoga = (axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매수최우선호가").Trim().Replace("+", ""));
                        string firstBuyQnt  = (axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매수최우선잔량").Trim());
                        if (!string.IsNullOrEmpty(firstBuyHoga))
                        {
                            newObj.SetBuyHoga(i, long.Parse(firstBuyHoga));
                        }
                        if (!string.IsNullOrEmpty(firstBuyQnt))
                        {
                            newObj.SetBuyQnt(i, long.Parse(firstBuyQnt));
                        }
                    }
                    else
                    {
                        Console.WriteLine("매수" + (i + 1) + "차선호가 / 잔량");
                        string hoga = (axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매수" + (i + 1) + "차선호가").Trim().Replace("+", ""));
                        string qnt  = (axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "매수" + (i + 1) + "차선잔량").Trim());
                        if (!string.IsNullOrEmpty(hoga))
                        {
                            newObj.SetBuyHoga(i, long.Parse(hoga));
                        }
                        if (!string.IsNullOrEmpty(qnt))
                        {
                            newObj.SetBuyQnt(i, long.Parse(qnt));
                        }
                    }
                }
                StockWithBiddingManager.GetInstance().SetItem(newObj);
            }
        }