예제 #1
0
        public static CancelOrderRequest ReadFromBuffer(ByteBuffer buf, int offset = 0)
        {
            if (buf.length - offset < StructSize)
            {
                return(null);
            }

            var req = new CancelOrderRequest();

            req.RequestId = encoding.GetString(buf.data, offset, 16).Trim((char)0);
            offset       += 16;

            req.ClearingAccountId = encoding.GetString(buf.data, offset, 16).Trim((char)0);
            offset += 16;

            req.TraderAccountId = encoding.GetString(buf.data, offset, 16).Trim((char)0);
            offset += 16;

            req.InstrumentId = BitConverter.ToInt32(buf.data, offset);
            offset          += PropInfo.GetSize(req, r => r.InstrumentId);

            req.ExchangeOrderId = BitConverter.ToInt64(buf.data, offset);
            offset += PropInfo.GetSize(req, r => r.ExchangeOrderId);

            req.OriginRequestId = encoding.GetString(buf.data, offset, 16).Trim((char)0);
            offset += 16;

            req.OrderSide = (OrderSide)buf.data[offset++];
            req.TrimZeroSymbols();
            return(req);
        }
예제 #2
0
        public static CancelOrderResponse ReadFromBuffer(MessageHeader frame, ByteBuffer buf, int offset = 0)
        {
            if (buf.length - offset < StructSize)
            {
                return(null);
            }

            var resp = new CancelOrderResponse();

            resp.OriginRequest = CancelOrderRequest.ReadFromBuffer(buf, offset);
            if (resp.OriginRequest == null)
            {
                return(null);
            }
            offset += CancelOrderRequest.StructSize;

            resp.InputTime = BitConverter.ToUInt64(buf.data, offset);
            offset        += PropInfo.GetSize(resp, o => o.InputTime);

            resp.OutputTime = BitConverter.ToUInt64(buf.data, offset);
            offset         += PropInfo.GetSize(resp, o => o.OutputTime);

            resp.SystemTime = BitConverter.ToUInt64(buf.data, offset);
            offset         += PropInfo.GetSize(resp, o => o.SystemTime);

            resp.AmountCancelled = BitConverter.ToInt32(buf.data, offset);
            offset += PropInfo.GetSize(resp, o => o.AmountCancelled);

            resp.AmountRest = BitConverter.ToInt32(buf.data, offset);
            offset         += PropInfo.GetSize(resp, o => o.AmountRest);

            resp.CancelReason = (CancelReason)buf.data[offset++];
            return(resp);
        }
예제 #3
0
        public static OrderResponse ReadFromBuffer(MessageHeader frame, ByteBuffer buf, int offset = 0)
        {
            if (buf.length - offset < StructSize)
            {
                return(null);
            }
            var resp = new OrderResponse();

            resp.InputTime = BitConverter.ToUInt64(buf.data, offset);
            offset        += PropInfo.GetSize(resp, o => o.InputTime);

            resp.OutputTime = BitConverter.ToUInt64(buf.data, offset);
            offset         += PropInfo.GetSize(resp, o => o.OutputTime);

            resp.OriginRequest = OrderRequest.ReadFromBuffer(buf, offset);
            if (resp.OriginRequest == null)
            {
                return(null);
            }
            offset += OrderRequest.StructSize;

            resp.SystemTime = BitConverter.ToUInt64(buf.data, offset);
            offset         += PropInfo.GetSize(resp, o => o.SystemTime);

            resp.ExchangeOrderId = BitConverter.ToInt64(buf.data, offset);
            offset += PropInfo.GetSize(resp, o => o.ExchangeOrderId);

            resp.LiquidityPoolId = BitConverter.ToInt16(buf.data, offset);
            offset += PropInfo.GetSize(resp, o => o.LiquidityPoolId);

            resp.OrderRoutingRule = BitConverter.ToInt16(buf.data, offset);

            return(resp);
        }
예제 #4
0
        public static ExecReportBody ReadFromBuffer(ByteBuffer buf, int offset = 0)
        {
            var d = new ExecReportBody();

            d.SystemTime = BitConverter.ToUInt64(buf.data, offset);
            offset      += PropInfo.GetSize(d, r => r.SystemTime);

            d.ExchangeOrderId = BitConverter.ToInt64(buf.data, offset);
            offset           += PropInfo.GetSize(d, r => r.ExchangeOrderId);

            d.AmountRest = BitConverter.ToInt64(buf.data, offset);
            offset      += PropInfo.GetSize(d, r => r.AmountRest);

            d.DealsCount = buf.data[offset++];

            if (d.DealsCount > d.Deals.Length)
            {
                d.Deals = new Deal[d.DealsCount];
            }

            for (var i = 0; i < d.DealsCount; i++)
            {
                var deal = Deal.ReadFromBuffer(buf, offset);
                if (deal == null)
                {
                    break;
                }
                d.Deals[i] = deal;
                offset    += Deal.StructSize;
            }
            return(d);
        }
예제 #5
0
        static Deal()
        {
            Deal d = null;

            StructSize = PropInfo.GetSize(d, o => o.DealId) +
                         PropInfo.GetSize(d, o => o.Price) +
                         PropInfo.GetSize(d, o => o.Amount);
        }
예제 #6
0
        static MessageHeader()
        {
            MessageHeader f = null;

            StructSize =
                PropInfo.GetSize(f, r => r.msgId) +
                PropInfo.GetSize(f, r => r.msgSize) +
                PropInfo.GetSize(f, r => r.msgSeq);
        }
예제 #7
0
        static RejectResponse()
        {
            RejectResponse r = null;

            StructSize = PropInfo.GetSize(r, o => o.InputTime) +
                         PropInfo.GetSize(r, o => o.OutputTime) +
                         PropInfo.GetSize(r, o => o.Time) +
                         16 + // RequestId
                         PropInfo.GetSize(r, o => o.ErrorCodeInternal);
        }
예제 #8
0
        static MassCancelRequest()
        {
            MassCancelRequest o = null;

            StructSize = 16 + // RequestId
                         16 + // ClearingAccountId
                         16 + // TraderAccountId
                         PropInfo.GetSize(o, r => r.InstrumentId) +
                         1;   // CancelMode
        }
예제 #9
0
        static CancelOrderResponse()
        {
            CancelOrderResponse r = null;

            StructSize = CancelOrderRequest.StructSize +
                         PropInfo.GetSize(r, o => o.InputTime) +
                         PropInfo.GetSize(r, o => o.OutputTime) +
                         PropInfo.GetSize(r, o => o.SystemTime) +
                         PropInfo.GetSize(r, o => o.AmountCancelled) +
                         PropInfo.GetSize(r, o => o.AmountRest) +
                         1; // CancelReason
        }
예제 #10
0
        static OrderResponse()
        {
            OrderResponse r = null;

            StructSize = OrderRequest.StructSize +
                         PropInfo.GetSize(r, o => o.InputTime) +
                         PropInfo.GetSize(r, o => o.OutputTime) +
                         PropInfo.GetSize(r, o => o.SystemTime) +
                         PropInfo.GetSize(r, o => o.ExchangeOrderId) +
                         PropInfo.GetSize(r, o => o.LiquidityPoolId) +
                         PropInfo.GetSize(r, o => o.OrderRoutingRule);
        }
예제 #11
0
        static CancelOrderRequest()
        {
            CancelOrderRequest o = null;

            StructSize = 16 + // RequestId
                         16 + // ClearingAccountId
                         16 + // TraderAccountId
                         PropInfo.GetSize(o, r => r.InstrumentId) +
                         PropInfo.GetSize(o, r => r.ExchangeOrderId) +
                         16 + // OriginRequestId
                         1;   // OrderSide
        }
예제 #12
0
        static MassCancelResponse()
        {
            MassCancelResponse o = null;

            StructSize = PropInfo.GetSize(o, r => r.InputTime) +
                         PropInfo.GetSize(o, r => r.OutputTime) +
                         PropInfo.GetSize(o, r => r.Time) +
                         16 + // OriginRequestId
                         16 + // ClearingAccountId
                         16 + // TraderAccountId
                         PropInfo.GetSize(o, r => r.InstrumentId) +
                         1 +  // CancelMode
                         1 +  // CancelStatus
                         PropInfo.GetSize(o, r => r.CancelledOrders);
        }
예제 #13
0
        public static MessageHeader ReadFromBuffer(ByteBuffer buf, int offset = 0)
        {
            if (buf.length - offset < StructSize)
            {
                return(null);
            }
            MessageHeader f     = null;
            var           frame = new MessageHeader
            {
                msgId   = BitConverter.ToInt16(buf.data, offset),
                msgSize = BitConverter.ToUInt16(buf.data, offset + PropInfo.GetSize(f, r => r.msgId)),
                msgSeq  = BitConverter.ToInt64(buf.data, offset + PropInfo.GetSize(f, r => r.msgId) +
                                               PropInfo.GetSize(f, r => r.msgSize))
            };

            return(frame);
        }
예제 #14
0
        static OrderRequest()
        {
            OrderRequest r = null;

            StructSize =
                16             // RequestId
                + 16           // ClearingAccountId
                + 16           // TraderAccountId
                + PropInfo.GetSize(r, o => o.InstrumentId)
                + sizeof(byte) // OrderType
                + sizeof(byte) // TimeInForce
                + sizeof(byte) // OrderSide
                + sizeof(byte) // AutoCancel
                + PropInfo.GetSize(r, o => o.Amount)
                + PropInfo.GetSize(r, o => o.Price)
                + PropInfo.GetSize(r, o => o.Flags)
                + 16; // comment
        }
예제 #15
0
        public static Deal ReadFromBuffer(ByteBuffer buf, int offset = 0)
        {
            var d = new Deal();

            if (buf.length - offset < StructSize)
            {
                return(d);
            }
            d.DealId = BitConverter.ToInt64(buf.data, offset);
            offset  += PropInfo.GetSize(d, r => r.DealId);

            d.Price = BitConverter.ToInt64(buf.data, offset);
            offset += PropInfo.GetSize(d, r => r.Price);

            d.Amount = BitConverter.ToInt64(buf.data, offset);
            offset  += PropInfo.GetSize(d, r => r.Amount);

            return(d);
        }
예제 #16
0
        public static MassCancelResponse ReadFromBuffer(MessageHeader frame, ByteBuffer buf, int offset = 0)
        {
            if (buf.length - offset < StructSize)
            {
                return(null);
            }
            var resp = new MassCancelResponse();

            resp.InputTime = BitConverter.ToUInt64(buf.data, offset);
            offset        += PropInfo.GetSize(resp, o => o.InputTime);

            resp.OutputTime = BitConverter.ToUInt64(buf.data, offset);
            offset         += PropInfo.GetSize(resp, o => o.OutputTime);

            resp.Time = BitConverter.ToUInt64(buf.data, offset);
            offset   += PropInfo.GetSize(resp, o => o.Time);

            resp.OriginRequestId = encoding.GetString(buf.data, offset, 16).Trim((char)0);;
            offset += 16;

            resp.ClearingAccountId = encoding.GetString(buf.data, offset, 16).Trim((char)0);;
            offset += 16;

            resp.TraderAccountId = encoding.GetString(buf.data, offset, 16).Trim((char)0);;
            offset += 16;

            resp.InstrumentId = BitConverter.ToInt32(buf.data, offset);
            offset           += PropInfo.GetSize(resp, o => o.InstrumentId);

            resp.CancelMode = (MassCancelMode)buf.data[offset++];

            resp.CancelStatus = (MassCancelStatus)buf.data[offset++];

            resp.CancelledOrders = BitConverter.ToInt32(buf.data, offset);
            offset += PropInfo.GetSize(resp, o => o.CancelledOrders);

            return(resp);
        }
예제 #17
0
        public static OrderRequest ReadFromBuffer(ByteBuffer buf, int offset = 0)
        {
            if (buf.length - offset < StructSize)
            {
                return(null);
            }

            var req = new OrderRequest();

            req.RequestId = encoding.GetString(buf.data, offset, 16).TrimEnd((char)0);
            offset       += 16;

            req.ClearingAccountId = encoding.GetString(buf.data, offset, 16).TrimEnd((char)0);
            offset += 16;

            req.TraderAccountId = encoding.GetString(buf.data, offset, 16).TrimEnd((char)0);
            offset += 16;

            req.InstrumentId = BitConverter.ToInt32(buf.data, offset);
            offset          += PropInfo.GetSize(req, r => r.InstrumentId);

            req.OrderType   = (OrderType)buf.data[offset++];
            req.TimeInForce = (TimeInForce)buf.data[offset++];
            req.OrderSide   = (OrderSide)buf.data[offset++];
            req.AutoCancel  = (AutoCancel)buf.data[offset++];

            req.Amount = BitConverter.ToInt64(buf.data, offset);
            offset    += PropInfo.GetSize(req, r => r.Amount);

            req.Price = BitConverter.ToInt64(buf.data, offset);
            offset   += PropInfo.GetSize(req, r => r.Price);

            req.Flags = BitConverter.ToUInt64(buf.data, offset);

            return(req);
        }
예제 #18
0
        public static RejectResponse ReadFromBuffer(MessageHeader frame, ByteBuffer buf, int offset = 0)
        {
            if (buf.length - offset < StructSize)
            {
                return(null);
            }
            var resp = new RejectResponse();

            resp.InputTime = BitConverter.ToUInt64(buf.data, offset);
            offset        += PropInfo.GetSize(resp, o => o.InputTime);

            resp.OutputTime = BitConverter.ToUInt64(buf.data, offset);
            offset         += PropInfo.GetSize(resp, o => o.OutputTime);

            resp.Time = BitConverter.ToUInt64(buf.data, offset);
            offset   += PropInfo.GetSize(resp, o => o.Time);

            resp.RequestId = encoding.GetString(buf.data, offset, 16).Trim((char)0);
            offset        += 16;

            resp.ErrorCodeInternal = BitConverter.ToInt16(buf.data, offset);

            return(resp);
        }