Exemplo n.º 1
0
        private void OpenApi_ReceivedRealData(_DKHOpenAPIEvents_OnReceiveRealDataEvent real)
        {
            DateTime now = DateTime.Now;

            //DateTime time;
            //var strTime = OpenApi.GetRealData(real.sRealKey, 21);
            //if (DateTime.TryParseExact(strTime,
            //    "HHmmss", CultureInfo.CurrentCulture, DateTimeStyles.None, out time))
            //{
            //    now = new DateTime(now.Year, now.Month, now.Day, time.Hour, time.Minute, time.Second);
            //}

            var askingPrice = new AskingPrice(now);

            for (int i = 0; i < OpenApi.RealPriceCount; ++i)
            {
                askingPrice.Sell.Add(new Asking
                {
                    Price    = Math.Abs(OpenApi.GetRealData(real.sRealKey, i + 41).ToInt()),
                    Quantity = OpenApi.GetRealData(real.sRealKey, i + 61).ToInt(),
                });

                askingPrice.Buy.Add(new Asking
                {
                    Price    = Math.Abs(OpenApi.GetRealData(real.sRealKey, i + 51).ToInt()),
                    Quantity = OpenApi.GetRealData(real.sRealKey, i + 71).ToInt(),
                });
            }

            if (_trader != null)
            {
                _trader.SetAskingPrice(real.sRealKey, askingPrice);
            }
        }
Exemplo n.º 2
0
        public void SetAskingPrice(string code, AskingPrice price)
        {
            foreach (var balance in _stockInfos)
            {
                if (balance.Stock.Code == code)
                {
                    balance.AskingPrice = price;
                }
            }

            if (Phase == EPhase.Price)
            {
                ProcessPhase();
            }
        }