Esempio n. 1
0
        public static QotCommon.KLType IntToKLType(int interval)
        {
            QotCommon.KLType result = QotCommon.KLType.KLType_Unknown;
            switch (interval)
            {
            case 1:
                result = QotCommon.KLType.KLType_1Min;
                break;

            case 5:
                result = QotCommon.KLType.KLType_5Min;
                break;

            case 15:
                result = QotCommon.KLType.KLType_15Min;
                break;

            case 30:
                result = QotCommon.KLType.KLType_30Min;
                break;

            case 60:
                result = QotCommon.KLType.KLType_60Min;
                break;
            }
            return(result);
        }
Esempio n. 2
0
        public static QotCommon.SubType KLTypeToSubType(QotCommon.KLType klType)
        {
            QotCommon.SubType result = QotCommon.SubType.SubType_None;
            switch (klType)
            {
            case QotCommon.KLType.KLType_1Min:
                result = QotCommon.SubType.SubType_KL_1Min;
                break;

            case QotCommon.KLType.KLType_5Min:
                result = QotCommon.SubType.SubType_KL_5Min;
                break;

            case QotCommon.KLType.KLType_15Min:
                result = QotCommon.SubType.SubType_KL_15Min;
                break;

            case QotCommon.KLType.KLType_30Min:
                result = QotCommon.SubType.SubType_KL_30Min;
                break;

            case QotCommon.KLType.KLType_60Min:
                result = QotCommon.SubType.SubType_KL_60Min;
                break;
            }
            return(result);
        }
Esempio n. 3
0
        public static QotCommon.KLType SubTypeToKLType(QotCommon.SubType subType)
        {
            QotCommon.KLType result = QotCommon.KLType.KLType_Unknown;
            switch (subType)
            {
            case QotCommon.SubType.SubType_KL_1Min:
                result = QotCommon.KLType.KLType_1Min;
                break;

            case QotCommon.SubType.SubType_KL_5Min:
                result = QotCommon.KLType.KLType_5Min;
                break;

            case QotCommon.SubType.SubType_KL_15Min:
                result = QotCommon.KLType.KLType_15Min;
                break;

            case QotCommon.SubType.SubType_KL_30Min:
                result = QotCommon.KLType.KLType_30Min;
                break;

            case QotCommon.SubType.SubType_KL_60Min:
                result = QotCommon.KLType.KLType_60Min;
                break;
            }
            return(result);
        }
Esempio n. 4
0
        public QotRequestHistoryKL.Response RequestHistoryKLSync(QotCommon.Security sec,
                                                                 QotCommon.KLType klType,
                                                                 QotCommon.RehabType rehabType,
                                                                 String beginTime,
                                                                 String endTime,
                                                                 int?count,
                                                                 long?klFields,
                                                                 byte[] nextReqKey,
                                                                 bool extendedTime)
        {
            ReqInfo reqInfo   = null;
            Object  syncEvent = new Object();

            lock (syncEvent)
            {
                lock (qotLock)
                {
                    if (qotConnStatus != ConnStatus.READY)
                    {
                        return(null);
                    }
                    QotRequestHistoryKL.C2S.Builder c2s = QotRequestHistoryKL.C2S.CreateBuilder()
                                                          .SetSecurity(sec)
                                                          .SetKlType((int)klType)
                                                          .SetRehabType((int)rehabType)
                                                          .SetBeginTime(beginTime)
                                                          .SetEndTime(endTime)
                                                          .SetExtendedTime(extendedTime);
                    if (count.HasValue)
                    {
                        c2s.SetMaxAckKLNum(count.Value);
                    }
                    if (klFields.HasValue)
                    {
                        c2s.SetNeedKLFieldsFlag(klFields.Value);
                    }
                    if (nextReqKey.Length > 0)
                    {
                        c2s.SetNextReqKey(ByteString.CopyFrom(nextReqKey));
                    }
                    QotRequestHistoryKL.Request req = QotRequestHistoryKL.Request.CreateBuilder().SetC2S(c2s).Build();
                    uint sn = qot.RequestHistoryKL(req);
                    if (sn == 0)
                    {
                        return(null);
                    }
                    reqInfo = new ReqInfo(ProtoID.QotRequestHistoryKL, syncEvent);
                    qotReqInfoMap.Add(sn, reqInfo);
                }
                Monitor.Wait(syncEvent);
                return((QotRequestHistoryKL.Response)reqInfo.Rsp);
            }
        }
Esempio n. 5
0
 internal void RequestHistoricalData(QotCommon.QotMarket market, string code, DateTime beginTime, DateTime endTime, QotCommon.KLType kLType)
 {
     QotRequestHistoryKL.Request.Builder reqBuilder   = QotRequestHistoryKL.Request.CreateBuilder();
     QotRequestHistoryKL.C2S.Builder     csReqBuilder = QotRequestHistoryKL.C2S.CreateBuilder();
     QotCommon.Security.Builder          stock        = QotCommon.Security.CreateBuilder();
     stock.SetCode(code);
     stock.SetMarket((int)market);
     csReqBuilder.Security  = stock.Build();
     csReqBuilder.KlType    = (int)kLType;
     csReqBuilder.BeginTime = beginTime.ToString("yyyy-MM-dd");
     csReqBuilder.EndTime   = endTime.ToString("yyyy-MM-dd");
     reqBuilder.SetC2S(csReqBuilder);
     qot.RequestHistoryKL(reqBuilder.Build());
 }