コード例 #1
0
        public static string GetQuoteDataVal(QuoteData data)
        {
            var sb = new StringBuilder();

            sb.Append(data.LastPx);
            sb.Append(Sperator);
            sb.Append(data.OpenPx);
            sb.Append(Sperator);
            sb.Append(data.HighPx);
            sb.Append(Sperator);
            sb.Append(data.LowPx);
            sb.Append(Sperator);
            sb.Append(data.PreClosePx);
            sb.Append(Sperator);
            sb.Append(data.HqDate);
            sb.Append(Sperator);
            sb.Append(data.HqTime);
            sb.Append(Sperator);
            sb.Append(data.PreSettlementPx);
            sb.Append(Sperator);
            sb.Append(data.PreOpenInterest);
            sb.Append(Sperator);
            sb.Append(data.UpLimitPx);
            sb.Append(Sperator);
            sb.Append(data.DownLimitPx);
            sb.Append(Sperator);
            sb.Append(data.AvgPx);
            sb.Append(Sperator);
            sb.Append(data.OpenInterest);
            sb.Append(Sperator);
            sb.Append(data.AddPos);
            sb.Append(Sperator);
            sb.Append(data.CurrHands);
            sb.Append(Sperator);
            sb.Append(data.BidPx1);
            sb.Append(Sperator);
            sb.Append(data.BidSize1);
            sb.Append(Sperator);
            sb.Append(data.AskPx1);
            sb.Append(Sperator);
            sb.Append(data.AskSize1);
            sb.Append(Sperator);
            sb.Append(data.TotalVolumeTrade);
            sb.Append(Sperator);
            sb.Append(data.TotalValueTrade);
            sb.Append(Sperator);
            sb.Append(data.SettlementPx);
            return(sb.ToString());
        }
コード例 #2
0
        /// <summary>
        /// 设置最新价
        /// </summary>
        /// <param name="contractId"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool SetInnerCodeNowPx(Int64 contractId, QuoteData data)
        {
            try
            {
                string key = GetQuoteDataKey(contractId);
                var    val = GetQuoteDataVal(data);

                RedisManager.QuoteRedis.Set(key, val);
                return(true);
            }
            catch (Exception exp)
            {
                LogRecord.writeLogsingle("error", "SetInnerCodeNowPx:" + exp.ToString());
                return(false);
            }
        }
コード例 #3
0
        public static QuoteData ToQuoteData(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return(null);
            }
            var arr = value.Split(Sperator);

            if (arr.Length < 22)
            {
                return(null);
            }

            var data = new QuoteData();

            data.LastPx           = arr[0].ToFloat();
            data.OpenPx           = arr[1].ToFloat();
            data.HighPx           = arr[2].ToFloat();
            data.LowPx            = arr[3].ToFloat();
            data.PreClosePx       = arr[4].ToFloat();
            data.HqDate           = arr[5].ToInt();
            data.HqTime           = arr[6].ToInt();
            data.PreSettlementPx  = arr[7].ToFloat();
            data.PreOpenInterest  = arr[8].ToLong();
            data.UpLimitPx        = arr[9].ToFloat();
            data.DownLimitPx      = arr[10].ToFloat();
            data.AvgPx            = arr[11].ToFloat();
            data.OpenInterest     = arr[12].ToLong();
            data.AddPos           = arr[13].ToLong();
            data.CurrHands        = arr[14].ToLong();
            data.BidPx1           = arr[15].ToFloat();
            data.BidSize1         = arr[16].ToInt();
            data.AskPx1           = arr[17].ToFloat();
            data.AskSize1         = arr[18].ToInt();
            data.TotalVolumeTrade = arr[19].ToLong();
            data.TotalValueTrade  = arr[20].ToFloat();
            data.SettlementPx     = arr[21].ToFloat();

            return(data);
        }
コード例 #4
0
 /// <summary>
 /// 获取最新行情
 /// </summary>
 /// <param name="contractId"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static bool GetQuoteData(long contractId, out QuoteData data)
 {
     data = GetQuoteData(contractId);
     return(data != null);
 }