private static SpotQuoteData ToQuoteData(string value) { if (string.IsNullOrWhiteSpace(value)) { return(null); } var arr = value.Split(Sperator); if (arr.Length < 12) { return(null); } var data = new SpotQuoteData(); 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.OpenInterest = arr[9].ToLong(); data.TotalVolumeTrade = arr[10].ToLong(); data.TotalValueTrade = arr[11].ToFloat(); return(data); }
public static bool GetQuoteData(long contractId, out SpotQuoteData quoteData) { try { quoteData = spotQuoteDataCache.Execute <SpotQuoteData>(null, contractId); } catch (Exception e) { LogRecord.writeLogsingle("error", "GetSpotQuoteDataInnerCodeNowPx:" + e.ToString()); quoteData = null; } return(quoteData != null); }
/// <summary> /// 设置最新价 /// </summary> /// <param name="contractId"></param> /// <param name="data"></param> /// <returns></returns> public static bool SetInnerCodeNowPx(Int64 contractId, SpotQuoteData data) { try { string key = GetSpotQuoteDataKey(contractId); 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.OpenInterest); sb.Append(Sperator); sb.Append(data.TotalVolumeTrade); sb.Append(Sperator); sb.Append(data.TotalValueTrade); RedisManager.QuoteRedis.Set(key, sb.ToString()); return(true); } catch (Exception exp) { LogRecord.writeLogsingle("error", "SetSpotQuoteDataInnerCodeNowPx:" + exp.ToString()); return(false); } }