public TrdGetHistoryOrderFillList.Response GetHistoryOrderFillListSync(ulong accID, TrdCommon.TrdMarket trdMarket, TrdCommon.TrdEnv trdEnv, TrdCommon.TrdFilterConditions filterConditions) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdCommon.TrdHeader trdHeader = MakeTrdHeader(trdEnv, accID, trdMarket); TrdGetHistoryOrderFillList.C2S.Builder c2s = TrdGetHistoryOrderFillList.C2S.CreateBuilder() .SetHeader(trdHeader); if (filterConditions != null) { c2s.SetFilterConditions(filterConditions); } TrdGetHistoryOrderFillList.Request req = TrdGetHistoryOrderFillList.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.GetHistoryOrderFillList(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdGetHistoryOrderFillList, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdGetHistoryOrderFillList.Response)reqInfo.Rsp); } }
public TrdGetFunds.Response GetFundsSync(ulong accID, TrdCommon.TrdMarket trdMarket, TrdCommon.TrdEnv trdEnv, bool isRefreshCache, TrdCommon.Currency currency) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdCommon.TrdHeader trdHeader = MakeTrdHeader(trdEnv, accID, trdMarket); TrdGetFunds.C2S c2s = TrdGetFunds.C2S.CreateBuilder() .SetHeader(trdHeader) .SetCurrency((int)currency) .SetRefreshCache(isRefreshCache) .Build(); TrdGetFunds.Request req = TrdGetFunds.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.GetFunds(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdGetFunds, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdGetFunds.Response)reqInfo.Rsp); } }
public TrdSubAccPush.Response subTrdAccPushSync(List <ulong> accList) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdSubAccPush.C2S c2s = TrdSubAccPush.C2S.CreateBuilder().AddRangeAccIDList(accList).Build(); TrdSubAccPush.Request req = TrdSubAccPush.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.SubAccPush(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdSubAccPush, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdSubAccPush.Response)reqInfo.Rsp); } }
public TrdGetAccList.Response GetAccListSync(ulong userID) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdGetAccList.C2S c2s = TrdGetAccList.C2S.CreateBuilder().SetUserID(userID).Build(); TrdGetAccList.Request req = TrdGetAccList.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.GetAccList(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdGetAccList, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdGetAccList.Response)reqInfo.Rsp); } }
public TrdPlaceOrder.Response PlaceOrderSync(TrdPlaceOrder.C2S c2s) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdPlaceOrder.Request req = TrdPlaceOrder.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.PlaceOrder(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdPlaceOrder, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdPlaceOrder.Response)reqInfo.Rsp); } }
public TrdUnlockTrade.Response UnlockTradeSync(String pwdMD5, bool isUnlock) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdUnlockTrade.C2S c2s = TrdUnlockTrade.C2S.CreateBuilder() .SetPwdMD5(pwdMD5) .SetUnlock(isUnlock) .Build(); TrdUnlockTrade.Request req = TrdUnlockTrade.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.UnlockTrade(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdUnlockTrade, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdUnlockTrade.Response)reqInfo.Rsp); } }
public QotGetOrderBook.Response GetOrderBookSync(QotCommon.Security sec, int num) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (qotLock) { if (qotConnStatus != ConnStatus.READY) { return(null); } QotGetOrderBook.C2S c2s = QotGetOrderBook.C2S.CreateBuilder() .SetSecurity(sec) .SetNum(num) .Build(); QotGetOrderBook.Request req = QotGetOrderBook.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = qot.GetOrderBook(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.QotGetOrderBook, syncEvent); qotReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((QotGetOrderBook.Response)reqInfo.Rsp); } }
public QotSub.Response SubSync(List <QotCommon.Security> secList, List <QotCommon.SubType> subTypeList, bool isSub, bool isRegPush) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (qotLock) { if (qotConnStatus != ConnStatus.READY) { return(null); } QotSub.C2S c2s = QotSub.C2S.CreateBuilder() .AddRangeSecurityList(secList) .AddRangeSubTypeList(subTypeList.Select(t => (int)t).ToList()) .SetIsSubOrUnSub(isSub) .SetIsRegOrUnRegPush(isRegPush) .Build(); QotSub.Request req = QotSub.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = qot.Sub(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.QotSub, syncEvent); qotReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((QotSub.Response)reqInfo.Rsp); } }
public QotGetStaticInfo.Response GetStaticInfoSync(QotGetStaticInfo.C2S c2s) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (qotLock) { if (qotConnStatus != ConnStatus.READY) { return(null); } QotGetStaticInfo.Request req = QotGetStaticInfo.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = qot.GetStaticInfo(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.QotGetStaticInfo, syncEvent); qotReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((QotGetStaticInfo.Response)reqInfo.Rsp); } }
public QotGetSecuritySnapshot.Response GetSecuritySnapshotSync(ICollection <QotCommon.Security> secList) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (qotLock) { if (qotConnStatus != ConnStatus.READY) { return(null); } QotGetSecuritySnapshot.C2S c2s = QotGetSecuritySnapshot.C2S.CreateBuilder() .AddRangeSecurityList(secList) .Build(); QotGetSecuritySnapshot.Request req = QotGetSecuritySnapshot.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = qot.GetSecuritySnapshot(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.QotGetSecuritySnapshot, syncEvent); qotReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((QotGetSecuritySnapshot.Response)reqInfo.Rsp); } }
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); } }
void handleTrdOnReply(uint serialNo, ProtoID protoID, object rsp) { ReqInfo reqInfo = getTrdReqInfo(serialNo, protoID); if (reqInfo != null) { lock (reqInfo.SyncEvent) { reqInfo.Rsp = rsp; Monitor.PulseAll(reqInfo.SyncEvent); } } }
public TrdGetPositionList.Response GetPositionListSync(ulong accID, TrdCommon.TrdMarket trdMarket, TrdCommon.TrdEnv trdEnv, TrdCommon.TrdFilterConditions filterConditions, double?filterPLRatioMin, double?filterPLRatioMax, bool isRefreshCache) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdCommon.TrdHeader trdHeader = MakeTrdHeader(trdEnv, accID, trdMarket); TrdGetPositionList.C2S.Builder c2s = TrdGetPositionList.C2S.CreateBuilder() .SetHeader(trdHeader); if (filterConditions != null) { c2s.SetFilterConditions(filterConditions); } if (filterPLRatioMin.HasValue) { c2s.SetFilterPLRatioMin(filterPLRatioMin.Value); } if (filterPLRatioMax.HasValue) { c2s.SetFilterPLRatioMax(filterPLRatioMax.Value); } c2s.SetRefreshCache(isRefreshCache); TrdGetPositionList.Request req = TrdGetPositionList.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.GetPositionList(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdGetPositionList, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdGetPositionList.Response)reqInfo.Rsp); } }
public TrdGetOrderList.Response GetOrderListSync(ulong accID, TrdCommon.TrdMarket trdMarket, TrdCommon.TrdEnv trdEnv, bool isRefreshCache, TrdCommon.TrdFilterConditions filterConditions, List <TrdCommon.OrderStatus> filterStatusList) { ReqInfo reqInfo = null; Object syncEvent = new Object(); lock (syncEvent) { lock (trdLock) { if (trdConnStatus != ConnStatus.READY) { return(null); } TrdCommon.TrdHeader trdHeader = MakeTrdHeader(trdEnv, accID, trdMarket); TrdGetOrderList.C2S.Builder c2s = TrdGetOrderList.C2S.CreateBuilder() .SetHeader(trdHeader) .SetRefreshCache(isRefreshCache); if (filterConditions != null) { c2s.SetFilterConditions(filterConditions); } if (filterStatusList.Count > 0) { foreach (TrdCommon.OrderStatus status in filterStatusList) { c2s.AddFilterStatusList((int)status); } } TrdGetOrderList.Request req = TrdGetOrderList.Request.CreateBuilder().SetC2S(c2s).Build(); uint sn = trd.GetOrderList(req); if (sn == 0) { return(null); } reqInfo = new ReqInfo(ProtoID.TrdGetOrderList, syncEvent); trdReqInfoMap.Add(sn, reqInfo); } Monitor.Wait(syncEvent); return((TrdGetOrderList.Response)reqInfo.Rsp); } }