public ProtoOAPosition.Builder CreatePositionBuilder(long positionId, ProtoOAPositionStatus positionStatus, long accountId, ProtoTradeSide tradeSide, string symbolName, long volume, double entryPrice, long swap,
                                                             long commission, long openTimestamp, string channel = null, string comment = null)
        {
            var _obj = ProtoOAPosition.CreateBuilder();

            _obj.SetPositionId(positionId);
            _obj.SetPositionStatus(positionStatus);
            _obj.SetAccountId(accountId);
            _obj.SetTradeSide(tradeSide);
            _obj.SetSymbolName(symbolName);
            _obj.SetVolume(volume);
            _obj.SetEntryPrice(entryPrice);
            _obj.SetSwap(swap);
            _obj.SetCommission(commission);
            _obj.SetOpenTimestamp(openTimestamp);
            if (channel != null)
            {
                _obj.SetChannel(channel);
            }
            if (comment != null)
            {
                _obj.SetComment(comment);
            }
            return(_obj);
        }
        public ProtoOAPosition CreatePosition(long positionId, ProtoOAPositionStatus positionStatus, long accountId,
                                              ProtoTradeSide tradeSide, string symbolName, long volume, double entryPrice, long swap,
                                              long commission, long openTimestamp, string channel = null, string comment = null)
        {
            var _obj = new ProtoOAPosition();

            _obj.positionId     = positionId;
            _obj.positionStatus = positionStatus;
            _obj.accountId      = accountId;
            _obj.tradeSide      = tradeSide;
            _obj.symbolName     = symbolName;
            _obj.volume         = volume;
            _obj.entryPrice     = entryPrice;
            _obj.swap           = swap;
            _obj.commission     = commission;
            _obj.openTimestamp  = openTimestamp;
            if (channel != null)
            {
                _obj.channel = channel;
            }
            if (comment != null)
            {
                _obj.comment = comment;
            }
            return(_obj);
        }
        static public string GetPositionText(ProtoOAPosition position)
        {
            var _str = "Position{positionId:" + position.PositionId.ToString() + ", positionStatus:" + position.PositionStatus;

            _str += ", tradeSide:" + position.TradeData.TradeSide;
            _str += ", symbolId:" + position.TradeData.SymbolId + ", volume:" + position.TradeData.Volume.ToString() + ", Price:" + position.Price.ToString() + ", swap:" + position.Swap.ToString() +
                    ", commission:" + position.Commission.ToString() + ", openTimestamp:" + position.TradeData.OpenTimestamp.ToString() +
                    (position.HasStopLoss ? ", stopLossPrice:" + position.StopLoss.ToString() : "") +
                    (position.HasTakeProfit ? ", takeProfitPrice:" + position.TakeProfit.ToString() : "");

            return(_str + "}");
        }
        static public string OpenApiPositionToString(ProtoOAPosition position)
        {
            var _str = "Position{positionId:" + position.PositionId.ToString() + ", positionStatus:" + OpenApiPositionStatusToString(position.PositionStatus) +
                       ", accountId:" + position.AccountId.ToString();

            _str += ", tradeSide:" + TradeSideToString(position.TradeSide);
            _str += ", symbolName:" + position.SymbolName + ", volume:" + position.Volume.ToString() + ", entryPrice:" + position.EntryPrice.ToString() + ", swap:" + position.Swap.ToString() +
                    ", commission:" + position.Commission.ToString() + ", openTimestamp:" + position.OpenTimestamp.ToString() +
                    (position.HasCloseTimestamp ? ", closeTimestamp:" + position.CloseTimestamp.ToString() : "") +
                    (position.HasStopLossPrice ? ", stopLossPrice:" + position.StopLossPrice.ToString() : "") +
                    (position.HasTakeProfitPrice ? ", takeProfitPrice:" + position.TakeProfitPrice.ToString() : "") +
                    (position.HasChannel ? ", channel:" + position.Channel : "") +
                    (position.HasComment ? ", comment:" + position.Comment : "");

            return(_str + "}");
        }
        static public string OpenApiPositionToString(ProtoOAPosition position)
        {
            var _str = "Position{positionId:" + position.positionId.ToString() + ", positionStatus:" + OpenApiPositionStatusToString(position.positionStatus) +
                       ", accountId:" + position.accountId.ToString();

            _str += ", tradeSide:" + TradeSideToString(position.tradeSide);
            _str += ", symbolName:" + position.symbolName + ", volume:" + position.volume.ToString() + ", entryPrice:" + position.entryPrice.ToString() + ", swap:" + position.swap.ToString() +
                    ", commission:" + position.commission.ToString() + ", openTimestamp:" + position.openTimestamp.ToString() +
                    (position.closeTimestampSpecified ? ", closeTimestamp:" + position.closeTimestamp.ToString() : "") +
                    (position.stopLossPriceSpecified ? ", stopLossPrice:" + position.stopLossPrice.ToString() : "") +
                    (position.takeProfitPriceSpecified ? ", takeProfitPrice:" + position.takeProfitPrice.ToString() : "") +
                    (position.channelSpecified ? ", channel:" + position.channel : "") +
                    (position.commentSpecified ? ", comment:" + position.comment : "");

            return(_str + "}");
        }
예제 #6
0
        public ProtoOAPosition.Builder CreatePositionBuilder(long positionId, ProtoOAPositionStatus positionStatus, long accountId, ProtoOATradeSide tradeSide, int symbolId, long volume, double entryPrice, long swap,
                                                             long commission, long openTimestamp, string channel = null, string comment = null)
        {
            var _obj          = ProtoOAPosition.CreateBuilder();
            var _objTradeData = ProtoOATradeData.CreateBuilder();

            _obj.SetPositionId(positionId);
            _obj.SetPositionStatus(positionStatus);
            _objTradeData.SetTradeSide(tradeSide);
            _objTradeData.SetSymbolId(symbolId);
            _objTradeData.SetVolume(volume);
            _obj.SetSwap(swap);
            _obj.SetCommission(commission);
            _obj.SetTradeData(_objTradeData);
            // _obj.SetOpenTimestamp(openTimestamp);
            //if (channel != null)
            //    _obj.SetChannel(channel);
            //if (comment != null)
            //    _obj.SetComment(comment);
            return(_obj);
        }
        public ProtoMessage CreateExecutionEvent(ProtoOAExecutionType executionType, ProtoOAOrder order, ProtoOAPosition position = null, string reasonCode = null, string clientMsgId = null)
        {
            var _msg = ProtoOAExecutionEvent.CreateBuilder();

            _msg.SetExecutionType(executionType);
            _msg.SetOrder(order);
            if (position != null)
            {
                _msg.SetPosition(position);
            }
            return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId));
        }
예제 #8
0
 public MarketOrderModel(ProtoOAPosition position, SymbolModel symbol) => Update(position, symbol);
 public ProtoOAPosition GetPosition(byte[] obj = null)
 {
     return(ProtoOAPosition.CreateBuilder().MergeFrom(obj).Build());
 }
        public ProtoMessage CreateExecutionEvent(ProtoOAExecutionType executionType, ProtoOAOrder order, ProtoOAPosition position = null, string reasonCode = null, string clientMsgId = null)
        {
            var _msg = new ProtoOAExecutionEvent();

            _msg.executionType = executionType;
            _msg.order         = order;
            if (position != null)
            {
                _msg.position = position;
            }
            if (reasonCode != null)
            {
                _msg.reasonCode = reasonCode;
            }
            return(CreateMessage((uint)_msg.payloadType, Utils.Serialize <ProtoOAExecutionEvent>(_msg), clientMsgId));
        }