Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <summary>
        /// 发送请求
        /// </summary>
        /// <param name="functionID"></param>
        /// <param name="requestID"></param>
        /// <param name="socketID"></param>
        /// <param name="dataInfo"></param>
        /// <returns></returns>
        public int Send(int functionID, int requestID, int socketID, HistoryDataInfo dataInfo)
        {
            Binary binary = new Binary();

            binary.WriteString(dataInfo.m_securityCode);
            binary.WriteChar((char)dataInfo.m_type);
            binary.WriteInt(dataInfo.m_size);
            binary.WriteInt(dataInfo.m_cycle);
            binary.WriteInt(dataInfo.m_subscription);
            binary.WriteDouble(dataInfo.m_startDate);
            binary.WriteDouble(dataInfo.m_endDate);
            binary.WriteBool(dataInfo.m_pushData);
            byte[] bytes = binary.GetBytes();
            int    num   = this.Send(new CMessage(base.GroupID, base.ServiceID, functionID, base.SessionID, requestID, socketID, 0, base.CompressType, bytes.Length, bytes));

            binary.Close();
            return(num);
        }
Пример #3
0
 /// <summary>
 /// 获取历史数据
 /// </summary>
 /// <param name="requestID"></param>
 /// <param name="dataInfo"></param>
 /// <returns></returns>
 public int GetHistoryDatas(int requestID, HistoryDataInfo dataInfo)
 {
     return((this.Send(FUNCTIONID_QUOTE_GETHISTORYDATA, requestID, this.m_socketID, dataInfo) > 0) ? 1 : 0);
 }