/// <summary> /// 获取历史数据 /// </summary> /// <param name="dataInfo"></param> /// <param name="datas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetHistoryDatas(ref HistoryDataInfo dataInfo, List <SecurityData> datas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); dataInfo.m_securityCode = binary.ReadString(); dataInfo.m_type = binary.ReadChar(); dataInfo.m_size = binary.ReadInt(); dataInfo.m_cycle = binary.ReadInt(); dataInfo.m_subscription = binary.ReadInt(); dataInfo.m_startDate = binary.ReadDouble(); dataInfo.m_endDate = binary.ReadDouble(); dataInfo.m_pushData = binary.ReadBool(); int size = dataInfo.m_size; for (int i = 0; i < size; i++) { SecurityData item = new SecurityData(); item.m_date = binary.ReadDouble(); item.m_close = binary.ReadFloat(); item.m_high = binary.ReadFloat(); item.m_low = binary.ReadFloat(); item.m_open = binary.ReadFloat(); item.m_volume = binary.ReadDouble(); item.m_amount = binary.ReadDouble(); if (dataInfo.m_cycle == 0) { item.m_avgPrice = binary.ReadFloat(); } datas.Add(item); } binary.Close(); return(1); }
/// <summary> /// 获取交易数据 /// </summary> /// <param name="securityCode"></param> /// <param name="transactionDatas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetTransactionDatas(ref string securityCode, List <TransactionData> transactionDatas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); securityCode = binary.ReadString(); int num = binary.ReadInt(); for (int i = 0; i < num; i++) { TransactionData item = new TransactionData(); item.m_date = binary.ReadDouble(); item.m_price = binary.ReadFloat(); item.m_volume = binary.ReadDouble(); item.m_type = binary.ReadChar(); transactionDatas.Add(item); } binary.Close(); return(1); }
/// <summary> /// 获取实时数据 /// </summary> /// <param name="dataInfo"></param> /// <param name="datas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetLatestDatas(ref LatestDataInfo dataInfo, List <SecurityLatestData> datas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); dataInfo.m_formatType = binary.ReadChar(); dataInfo.m_lv2 = binary.ReadChar(); dataInfo.m_size = binary.ReadInt(); for (int i = 0; i < dataInfo.m_size; i++) { SecurityLatestData item = new SecurityLatestData(); item.m_securityCode = binary.ReadString(); item.m_open = binary.ReadFloat(); item.m_lastClose = binary.ReadFloat(); item.m_close = binary.ReadFloat(); item.m_high = binary.ReadFloat(); item.m_low = binary.ReadFloat(); item.m_volume = binary.ReadDouble(); item.m_amount = binary.ReadDouble(); if (dataInfo.m_formatType == 0) { item.m_buyVolume1 = binary.ReadInt(); item.m_buyPrice1 = binary.ReadFloat(); item.m_buyVolume2 = binary.ReadInt(); item.m_buyPrice2 = binary.ReadFloat(); item.m_buyVolume3 = binary.ReadInt(); item.m_buyPrice3 = binary.ReadFloat(); item.m_buyVolume4 = binary.ReadInt(); item.m_buyPrice4 = binary.ReadFloat(); item.m_buyVolume5 = binary.ReadInt(); item.m_buyPrice5 = binary.ReadFloat(); item.m_sellVolume1 = binary.ReadInt(); item.m_sellPrice1 = binary.ReadFloat(); item.m_sellVolume2 = binary.ReadInt(); item.m_sellPrice2 = binary.ReadFloat(); item.m_sellVolume3 = binary.ReadInt(); item.m_sellPrice3 = binary.ReadFloat(); item.m_sellVolume4 = binary.ReadInt(); item.m_sellPrice4 = binary.ReadFloat(); item.m_sellVolume5 = binary.ReadInt(); item.m_sellPrice5 = binary.ReadFloat(); item.m_innerVol = binary.ReadInt(); item.m_outerVol = binary.ReadInt(); item.m_turnoverRate = binary.ReadFloat(); item.m_openInterest = binary.ReadDouble(); item.m_settlePrice = binary.ReadFloat(); } item.m_date = binary.ReadDouble(); datas.Add(item); } binary.Close(); return(1); }
/// <summary> /// 获取实时数据L2 /// </summary> /// <param name="dataInfo"></param> /// <param name="datas"></param> /// <param name="body"></param> /// <param name="bodyLength"></param> /// <returns></returns> public static int GetLatestDatasLV2(ref LatestDataInfoLV2 dataInfo, List <SecurityLatestDataLV2> datas, byte[] body, int bodyLength) { Binary binary = new Binary(); binary.Write(body, bodyLength); dataInfo.m_size = binary.ReadInt(); for (int i = 0; i < dataInfo.m_size; i++) { SecurityLatestDataLV2 item = new SecurityLatestDataLV2(); item.m_securityCode = binary.ReadString(); item.m_allBuyVol = binary.ReadDouble(); item.m_avgBuyPrice = binary.ReadFloat(); item.m_allSellVol = binary.ReadDouble(); item.m_avgSellPrice = binary.ReadFloat(); item.m_buyVolume6 = binary.ReadInt(); item.m_buyPrice6 = binary.ReadFloat(); item.m_buyVolume7 = binary.ReadInt(); item.m_buyPrice7 = binary.ReadFloat(); item.m_buyVolume8 = binary.ReadInt(); item.m_buyPrice8 = binary.ReadFloat(); item.m_buyVolume9 = binary.ReadInt(); item.m_buyPrice9 = binary.ReadFloat(); item.m_buyVolume10 = binary.ReadInt(); item.m_buyPrice10 = binary.ReadFloat(); item.m_sellVolume6 = binary.ReadInt(); item.m_sellPrice6 = binary.ReadFloat(); item.m_sellVolume7 = binary.ReadInt(); item.m_sellPrice7 = binary.ReadFloat(); item.m_sellVolume8 = binary.ReadInt(); item.m_sellPrice8 = binary.ReadFloat(); item.m_sellVolume9 = binary.ReadInt(); item.m_sellPrice9 = binary.ReadFloat(); item.m_sellVolume10 = binary.ReadInt(); item.m_sellPrice10 = binary.ReadFloat(); datas.Add(item); } binary.Close(); return(1); }
/// <summary> /// 获取表格 /// </summary> /// <param name="bytes">流</param> /// <param name="native">方法库</param> /// <returns>表格</returns> public GridA GetGrid(byte[] bytes, INativeBase native) { Binary br = new Binary(); br.Write(bytes, bytes.Length); GridA grid = new GridA(); grid.Native = native; grid.Name = br.ReadString(); int columnsSize = br.ReadInt(); for (int i = 0; i < columnsSize; i++) { GridColumn column = new GridColumn(); column.Name = br.ReadString(); column.ColumnType = br.ReadString(); grid.AddColumn(column); } grid.Update(); List <GridColumn> columns = grid.GetColumns(); int rowsCount = br.ReadInt(); for (int i = 0; i < rowsCount; i++) { GridRow row = new GridRow(); grid.AddRow(row); for (int j = 0; j < columnsSize; j++) { GridColumn column = columns[j]; string columnType = column.ColumnType.ToLower(); GridCell cell = null; if (columnType == "bool") { cell = new GridBoolCell(); row.AddCell(j, cell); cell.SetBool(br.ReadBool()); } else if (columnType == "double") { cell = new GridDoubleCell(); row.AddCell(j, cell); cell.SetDouble(br.ReadDouble()); } else if (columnType == "float") { cell = new GridFloatCell(); row.AddCell(j, cell); cell.SetFloat(br.ReadFloat()); } else if (columnType == "int") { cell = new GridIntCell(); row.AddCell(j, cell); cell.SetInt(br.ReadInt()); } else if (columnType == "long") { cell = new GridLongCell(); row.AddCell(j, cell); cell.SetLong((long)br.ReadDouble()); } else if (columnType == "string") { cell = new GridStringCell(); row.AddCell(j, cell); cell.SetString(br.ReadString()); } else { cell = new GridStringCell(); row.AddCell(j, cell); cell.SetString(br.ReadString()); } } } br.Close(); return(grid); }