public ProtoMessage CreateMarketOrderRequest(long accountId, string accessToken, string symbolName, ProtoTradeSide tradeSide, long volume, int?stopLossInPips = null, int?takeProfitInPips = null, string comment = null, long?positionId = null, string clientMsgId = null) { var _msg = ProtoOACreateOrderReq.CreateBuilder(); _msg.SetAccountId(accountId); _msg.SetAccessToken(accessToken); _msg.SetSymbolName(symbolName); _msg.SetOrderType(ProtoOAOrderType.OA_MARKET); _msg.SetTradeSide(tradeSide); _msg.SetVolume(volume); if (stopLossInPips != null) { _msg.SetRelativeStopLossInPips((int)stopLossInPips); } if (takeProfitInPips != null) { _msg.SetRelativeTakeProfitInPips((int)takeProfitInPips); } if (!string.IsNullOrEmpty(comment)) { _msg.SetComment(comment); } if (positionId != null) { _msg.SetPositionId((long)positionId); } return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId)); }
public ProtoMessage CreateStopOrderRequest(long accountId, string accessToken, string symbolName, ProtoTradeSide tradeSide, long volume, double stopPrice, string clientMsgId = null) { var _msg = ProtoOACreateOrderReq.CreateBuilder(); _msg.SetAccountId(accountId); _msg.SetAccessToken(accessToken); _msg.SetSymbolName(symbolName); _msg.SetOrderType(ProtoOAOrderType.OA_STOP); _msg.SetTradeSide(tradeSide); _msg.SetVolume(volume); _msg.SetStopPrice(stopPrice); _msg.SetComment("TradingApiTest.CreateStopOrderRequest"); return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId)); }
public ProtoMessage CreateMarketRangeOrderRequest(long accountId, string accessToken, string symbolName, ProtoTradeSide tradeSide, long volume, double baseSlippagePrice, long slippageInPips, string clientMsgId = null) { var _msg = ProtoOACreateOrderReq.CreateBuilder(); _msg.SetAccountId(accountId); _msg.SetAccessToken(accessToken); _msg.SetSymbolName(symbolName); _msg.SetOrderType(ProtoOAOrderType.OA_MARKET_RANGE); _msg.SetTradeSide(tradeSide); _msg.SetVolume(volume); _msg.SetBaseSlippagePrice(baseSlippagePrice); _msg.SetSlippageInPips(slippageInPips); _msg.SetComment("TradingApiTest.CreateMarketRangeOrderRequest"); return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId)); }
public ProtoMessage CreateLimitOrderRequest(long accountId, string accessToken, string symbolName, ProtoTradeSide tradeSide, long volume, double limitPrice, string clientMsgId = null) { var _msg = ProtoOACreateOrderReq.CreateBuilder(); _msg.SetAccountId(accountId); _msg.SetAccessToken(accessToken); _msg.SetSymbolName(symbolName); _msg.SetOrderType(ProtoOAOrderType.OA_LIMIT); _msg.SetTradeSide(tradeSide); _msg.SetVolume(volume); _msg.SetLimitPrice(limitPrice); _msg.SetComment("TradingApiTest.CreateLimitOrderRequest"); DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); _msg.SetExpirationTimestamp((long)(DateTime.UtcNow.AddHours(1) - epoch).TotalMilliseconds); return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId)); }
public ProtoMessage CreateMarketOrderRequest(long accountId, string accessToken, string symbolName, ProtoTradeSide tradeSide, long volume, string clientMsgId = null) { var _msg = ProtoOACreateOrderReq.CreateBuilder(); _msg.SetAccountId(accountId); _msg.SetAccessToken(accessToken); _msg.SetSymbolName(symbolName); _msg.SetOrderType(ProtoOAOrderType.OA_MARKET); _msg.SetTradeSide(tradeSide); _msg.SetVolume(volume); //_msg.SetRelativeStopLossInPips(27); //_msg.SetRelativeTakeProfitInPips(1); _msg.SetComment("TradingApiTest.CreateMarketOrderRequest"); return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId)); }
public ProtoOACreateOrderReq GetCreateOrderRequest(byte[] msg = null) { return(ProtoOACreateOrderReq.CreateBuilder().MergeFrom(GetPayload(msg)).Build()); }