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;
 }
        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);
        }
        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 + "}";
        }