Пример #1
0
        public void Deserialize_CheckCorrectBidCountAskCountWithPriceLevel()
        {
            var book = new Book();

            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 9, OpenQuantity = 10
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 8, OpenQuantity = 9
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 10, OpenQuantity = 10
            });
            var bytes         = BookSerializer.Serialize(book, 9, 11000, DateTime.UtcNow.Ticks);
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(131, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(11000, bookDepth.LTP);
            Assert.Equal(2, bookDepth.Bid.Count);
            Assert.Single(bookDepth.Ask);
            Assert.Equal(9, bookDepth.Bid[0].Key);
            Assert.Equal(10, bookDepth.Bid[0].Value);
            Assert.Equal(8, bookDepth.Bid[1].Key);
            Assert.Equal(9, bookDepth.Bid[1].Value);
            Assert.Equal(10, bookDepth.Ask[0].Key);
            Assert.Equal(10, bookDepth.Ask[0].Value);
        }
Пример #2
0
        public void Serialize_ThrowsExecption_IfNullPassed()
        {
            var bytes = new byte[31];
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => BookSerializer.Serialize(null, bytes));

            Assert.Equal("book", ex.ParamName);
        }
Пример #3
0
        public void Serialize_ThrowsExecption_IfLevelNegativePassed()
        {
            var book             = new Book();
            ArgumentException ex = Assert.Throws <ArgumentException>(() => BookSerializer.Serialize(book, -1, null, 10));

            Assert.Equal("levels should be non negative", ex.Message);
        }
Пример #4
0
        public void Deserialize_CheckCorrectOnlyBuy()
        {
            var bid = new List <KeyValuePair <Price, Quantity> >()
            {
                new KeyValuePair <Price, Quantity>(9, 10), new KeyValuePair <Price, Quantity>(8, 9)
            };
            var ask = new List <KeyValuePair <Price, Quantity> >()
            {
            };
            var         book  = new BookDepth(3, 11000, bid, ask);
            Span <byte> bytes = stackalloc byte[95];

            BookSerializer.Serialize(book, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(95, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(11000, bookDepth.LTP);
            Assert.Equal(2, bookDepth.Bid.Count);
            Assert.Empty(bookDepth.Ask);
            Assert.Equal(9, bookDepth.Bid[0].Key);
            Assert.Equal(10, bookDepth.Bid[0].Value);
            Assert.Equal(8, bookDepth.Bid[1].Key);
            Assert.Equal(9, bookDepth.Bid[1].Value);
        }
Пример #5
0
        public void Serialize_Doesnotthrowexception_OnlyAskOrder()
        {
            var book = new Book();

            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 10
            });
            var bytes = BookSerializer.Serialize(book, 10, 10, DateTime.UtcNow.Ticks);
        }
        public void Deserialize()
        {
            serializer.Serialize("DeserialitionResult.xml", res);
            Catalog deserializationCatalog = serializer.Deserialize("DeserialitionResult.xml");

            Assert.Equal(deserializationCatalog.Date, res.Date);
            Assert.Equal(res.Books.Exists(book => book.Author == "Vanya)"),
                         deserializationCatalog.Books.Exists(book => book.Author == "Vanya)"));
        }
Пример #7
0
        public void Deserialize_CheckCorrectBidCountAskFullBook()
        {
            var bid = new List <KeyValuePair <Price, Quantity> >()
            {
                new KeyValuePair <Price, Quantity>(10, 1),
                new KeyValuePair <Price, Quantity>(9, 2),
                new KeyValuePair <Price, Quantity>(8, 3),
                new KeyValuePair <Price, Quantity>(7, 4),
                new KeyValuePair <Price, Quantity>(6, 5)
            };
            var ask = new List <KeyValuePair <Price, Quantity> >()
            {
                new KeyValuePair <Price, Quantity>(11, 11),
                new KeyValuePair <Price, Quantity>(12, 12),
                new KeyValuePair <Price, Quantity>(13, 13),
                new KeyValuePair <Price, Quantity>(14, 14),
                new KeyValuePair <Price, Quantity>(15, 15)
            };
            var         book  = new BookDepth(3, 10, bid, ask);
            Span <byte> bytes = stackalloc byte[351];

            BookSerializer.Serialize(book, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(351, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(10, bookDepth.LTP);
            Assert.Equal(5, bookDepth.Bid.Count);

            Assert.Equal(10, bookDepth.Bid[0].Key);
            Assert.Equal(1, bookDepth.Bid[0].Value);
            Assert.Equal(9, bookDepth.Bid[1].Key);
            Assert.Equal(2, bookDepth.Bid[1].Value);
            Assert.Equal(8, bookDepth.Bid[2].Key);
            Assert.Equal(3, bookDepth.Bid[2].Value);
            Assert.Equal(7, bookDepth.Bid[3].Key);
            Assert.Equal(4, bookDepth.Bid[3].Value);
            Assert.Equal(6, bookDepth.Bid[4].Key);
            Assert.Equal(5, bookDepth.Bid[4].Value);


            Assert.Equal(11, bookDepth.Ask[0].Key);
            Assert.Equal(11, bookDepth.Ask[0].Value);
            Assert.Equal(12, bookDepth.Ask[1].Key);
            Assert.Equal(12, bookDepth.Ask[1].Value);
            Assert.Equal(13, bookDepth.Ask[2].Key);
            Assert.Equal(13, bookDepth.Ask[2].Value);
            Assert.Equal(14, bookDepth.Ask[3].Key);
            Assert.Equal(14, bookDepth.Ask[3].Value);
            Assert.Equal(15, bookDepth.Ask[4].Key);
            Assert.Equal(15, bookDepth.Ask[4].Value);
        }
Пример #8
0
        public void Serialize_Doesnotthrowexception_EmptyBook()
        {
            var bid = new List <KeyValuePair <Price, Quantity> >()
            {
            };
            var ask = new List <KeyValuePair <Price, Quantity> >()
            {
            };
            var         book  = new BookDepth(3, 10, bid, ask);
            Span <byte> bytes = stackalloc byte[31];

            BookSerializer.Serialize(book, bytes);
        }
Пример #9
0
        public void Deserialize_CheckCorrectBidCountAskCountForEmpty()
        {
            var book          = new Book();
            var bytes         = BookSerializer.Serialize(book, 10, 1010, DateTime.UtcNow.Ticks);
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(35, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(1010, bookDepth.LTP);
            Assert.NotEqual(0, bookDepth.TimeStamp);
            Assert.Empty(bookDepth.Bid);
            Assert.Empty(bookDepth.Ask);
        }
Пример #10
0
        public void Serialize_Doesnotthrowexception_OnlyAskOrder()
        {
            var ask = new List <KeyValuePair <Price, Quantity> >()
            {
                new KeyValuePair <Price, Quantity>(10, 20)
            };
            var bid = new List <KeyValuePair <Price, Quantity> >()
            {
            };
            var         book  = new BookDepth(10, 10, bid, ask);
            Span <byte> bytes = stackalloc byte[63];

            BookSerializer.Serialize(book, bytes);
        }
Пример #11
0
        private async Task InboundMessageProcessor()
        {
            try
            {
                while (await _inboundChannelReader.WaitToReadAsync())
                {
                    while (_inboundChannelReader.TryRead(out Message message))
                    {
                        try
                        {
                            switch (message.MessageType)
                            {
                            case MessageType.NewOrderRequest:
                                _matchingEngine.AddOrder((OrderWrapper)message.Object);
                                break;

                            case MessageType.CancelRequest:
                                _matchingEngine.CancelOrder(((CancelRequest)message.Object).OrderId);
                                break;

                            case MessageType.BookRequest:
                                var bytes = BookSerializer.Serialize(_matchingEngine.Book, ((BookRequest)message.Object).LevelCount, _matchingEngine.MarketPrice, _timeProvider.GetSecondsFromEpoch());
                                _outboundChannelWritter.TryWrite(bytes);
                                //TODO
                                break;

                            default:
                                //TODO
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                            //TODO
                            throw;
                        }
                    }
                }
                _outboundChannelWritter.Complete();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                //TODO
                throw;
            }
        }
Пример #12
0
        public void Deserialize_CheckCorrectOnlyAsk()
        {
            var book = new Book();

            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 10, OpenQuantity = 10
            });
            var bytes         = BookSerializer.Serialize(book, 9, 11000, DateTime.UtcNow.Ticks);
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(67, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(11000, bookDepth.LTP);
            Assert.Empty(bookDepth.Bid);
            Assert.Single(bookDepth.Ask);
            Assert.Equal(10, bookDepth.Ask[0].Key);
            Assert.Equal(10, bookDepth.Ask[0].Value);
        }
Пример #13
0
        public void Deserialize_CheckCorrectBidCountAskCountForEmpty()
        {
            var bid = new List <KeyValuePair <Price, Quantity> >()
            {
            };
            var ask = new List <KeyValuePair <Price, Quantity> >()
            {
            };
            var         book  = new BookDepth(3, 1010, bid, ask);;
            Span <byte> bytes = stackalloc byte[31];

            BookSerializer.Serialize(book, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(31, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(1010, bookDepth.LTP);
            Assert.Equal(3, bookDepth.TimeStamp);
            Assert.Empty(bookDepth.Bid);
            Assert.Empty(bookDepth.Ask);
        }
Пример #14
0
        public void Deserialize_CheckCorrectOnlyBuy()
        {
            var book = new Book();

            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 9, Quantity = 10, OpenQuantity = 10
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 8, Quantity = 9, OpenQuantity = 9
            });
            var bytes         = BookSerializer.Serialize(book, 9, 11000, DateTime.UtcNow.Ticks);
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(99, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(11000, bookDepth.LTP);
            Assert.Equal(2, bookDepth.Bid.Count);
            Assert.Empty(bookDepth.Ask);
            Assert.Equal((Price)9, bookDepth.Bid[0].Key);
            Assert.Equal((Quantity)10, bookDepth.Bid[0].Value);
            Assert.Equal((Price)8, bookDepth.Bid[1].Key);
            Assert.Equal((Quantity)9, bookDepth.Bid[1].Value);
        }
Пример #15
0
        public void Deserialize_CheckCorrectOnlyAsk()
        {
            var bid = new List <KeyValuePair <Price, Quantity> >()
            {
            };
            var ask = new List <KeyValuePair <Price, Quantity> >()
            {
                new KeyValuePair <Price, Quantity>(10, 10)
            };
            var         book  = new BookDepth(3, 11000, bid, ask);
            Span <byte> bytes = stackalloc byte[63];

            BookSerializer.Serialize(book, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(63, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(11000, bookDepth.LTP);
            Assert.Empty(bookDepth.Bid);
            Assert.Single(bookDepth.Ask);
            Assert.Equal(10, bookDepth.Ask[0].Key);
            Assert.Equal(10, bookDepth.Ask[0].Value);
        }
Пример #16
0
        public void BookSerializeBinarySerialize()
        {
            Span <byte> bytes = stackalloc byte[10];

            BookSerializer.Serialize(bookDepth, bytes);
        }
        public SerializeBenchmark()
        {
            book = new Book();
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderId = 3434, Price = 234
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderId = 3434, Price = 235
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderId = 3435, Price = 236
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderId = 3436, Price = 237
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderId = 3437, Price = 238
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderId = 3438, Price = 239
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderId = 3439, Price = 240
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderId = 3440, Price = 241
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderId = 3441, Price = 242
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderId = 3442, Price = 243
            });
            bid = book.BidSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();
            ask = book.AskSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();

            var order = new Order {
                CancelOn = 12345678, IsBuy = true, OrderId = 56789, Price = 404, OpenQuantity = 1000
            };
            var orderWrapper = new OrderWrapper()
            {
                Order = order, OrderCondition = OrderCondition.ImmediateOrCancel, StopPrice = 9534, TotalQuantity = 7878234
            };

            orderJsonString       = JsonConvert.SerializeObject(orderWrapper);
            orderBinarySerialized = OrderSerializer.Serialize(orderWrapper);
            orderMsgPck           = MessagePackSerializer.Serialize(new Order2 {
                IsBuy = true, IsTip = false, OpenQuantity = 100, OrderId = 1001, Price = 400, Quantity = 100, Sequnce = 0, StopPrice = 0
            });

            fillJsonString = JsonConvert.SerializeObject(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            });
            fillBinary = FillSerializer.Serialize(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            });

            cancelJsonString = JsonConvert.SerializeObject(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            });
            cancelBinary = CancelledOrderSerializer.Serialize(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            });

            cancelRequestJsonString = JsonConvert.SerializeObject(new CancelRequest {
                OrderId = 1023
            });
            cancelRequestBinary = CancelRequestSerializer.Serialize(new CancelRequest {
                OrderId = 1023
            });

            orderTriggerBinary = OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            });
            orderTriggerJsonString = JsonConvert.SerializeObject(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            });

            bookRequestBinary     = BookRequestSerializer.Serialize(new BookRequest {
            });
            bookRequestJsonString = JsonConvert.SerializeObject(new BookRequest {
            });
            bookRequest2          = MessagePackSerializer.Serialize(new BookRequest2 {
            });

            bookJsonString = JsonConvert.SerializeObject(new BookDepth {
                Bid = bid, Ask = ask, LTP = 100, TimeStamp = 1234
            });
            bookBinary = BookSerializer.Serialize(book, 5, 100, 1234);
        }
Пример #18
0
        public void Serialize_ThrowsExecption_IfNullPassed()
        {
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => BookSerializer.Serialize(null, 10, null, 10));

            Assert.Equal("book", ex.ParamName);
        }
Пример #19
0
 public void Serialize_Doesnotthrowexception_EmptyBook()
 {
     var book  = new Book();
     var bytes = BookSerializer.Serialize(book, 10, 10, DateTime.UtcNow.Ticks);
 }
Пример #20
0
        public void Deserialize_CheckCorrectBidCountAskFullBook()
        {
            var book = new Book();

            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 10, OpenQuantity = 1
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 9, OpenQuantity = 2
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 8, OpenQuantity = 3
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 7, OpenQuantity = 4
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 6, OpenQuantity = 5
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 5, OpenQuantity = 6
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 4, OpenQuantity = 7
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 3, OpenQuantity = 8
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 2, OpenQuantity = 9
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = true, Price = 1, OpenQuantity = 10
            });

            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 11, OpenQuantity = 11
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 12, OpenQuantity = 12
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 13, OpenQuantity = 13
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 14, OpenQuantity = 14
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 15, OpenQuantity = 15
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 16, OpenQuantity = 16
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 17, OpenQuantity = 17
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 18, OpenQuantity = 18
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 19, OpenQuantity = 19
            });
            book.AddOrderOpenBook(new Order {
                IsBuy = false, Price = 20, OpenQuantity = 20
            });

            var bytes         = BookSerializer.Serialize(book, 5, 10, DateTime.UtcNow.Ticks);
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(355, messageLength);
            var bookDepth = BookSerializer.Deserialize(bytes);

            Assert.Equal(10, bookDepth.LTP);
            Assert.Equal(5, bookDepth.Bid.Count);

            Assert.Equal(10, bookDepth.Bid[0].Key);
            Assert.Equal(1, bookDepth.Bid[0].Value);
            Assert.Equal(9, bookDepth.Bid[1].Key);
            Assert.Equal(2, bookDepth.Bid[1].Value);
            Assert.Equal(8, bookDepth.Bid[2].Key);
            Assert.Equal(3, bookDepth.Bid[2].Value);
            Assert.Equal(7, bookDepth.Bid[3].Key);
            Assert.Equal(4, bookDepth.Bid[3].Value);
            Assert.Equal(6, bookDepth.Bid[4].Key);
            Assert.Equal(5, bookDepth.Bid[4].Value);


            Assert.Equal(11, bookDepth.Ask[0].Key);
            Assert.Equal(11, bookDepth.Ask[0].Value);
            Assert.Equal(12, bookDepth.Ask[1].Key);
            Assert.Equal(12, bookDepth.Ask[1].Value);
            Assert.Equal(13, bookDepth.Ask[2].Key);
            Assert.Equal(13, bookDepth.Ask[2].Value);
            Assert.Equal(14, bookDepth.Ask[3].Key);
            Assert.Equal(14, bookDepth.Ask[3].Value);
            Assert.Equal(15, bookDepth.Ask[4].Key);
            Assert.Equal(15, bookDepth.Ask[4].Value);
        }
 public void bookSerializeBinarySerialize()
 {
     var msg = BookSerializer.Serialize(book, 50, 100, 1234);
 }
Пример #22
0
        public SerializeBenchmark()
        {
            book = new Book();
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3434, Price = 234
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3434, Price = 235
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3435, Price = 236
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3436, Price = 237
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3437, Price = 238
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3438, Price = 239
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3439, Price = 240
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3440, Price = 241
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3441, Price = 242
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3442, Price = 243
            });
            bid = book.BidSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();
            ask = book.AskSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();

            var order = new Order()
            {
                CancelOn = 12345678, IsBuy = true, OrderId = 56789, Price = 404, OpenQuantity = 1000, OrderCondition = OrderCondition.ImmediateOrCancel, StopPrice = 9534, TotalQuantity = 7878234
            };

            orderJsonString = JsonConvert.SerializeObject(order);

            orderBinarySerialized = new byte[OrderSerializer.MessageSize];
            OrderSerializer.Serialize(order, orderBinarySerialized);

            orderMsgPck = MessagePackSerializer.Serialize(new Order2 {
                IsBuy = true, IsTip = false, OpenQuantity = 100, OrderId = 1001, Price = 400, Quantity = 100, Sequnce = 0, StopPrice = 0
            });

            fillJsonString = JsonConvert.SerializeObject(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            });
            fillBinary = new byte[FillSerializer.MessageSize];
            FillSerializer.Serialize(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            }, fillBinary);

            cancelJsonString = JsonConvert.SerializeObject(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            });
            cancelBinary = new byte[CancelledOrderSerializer.MessageSize];
            CancelledOrderSerializer.Serialize(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            }, cancelBinary);

            cancelRequestJsonString = JsonConvert.SerializeObject(new CancelRequest {
                OrderId = 1023
            });
            cancelRequestBinary = new byte[CancelRequestSerializer.MessageSize];
            CancelRequestSerializer.Serialize(new CancelRequest {
                OrderId = 1023
            }, cancelRequestBinary);

            orderTriggerBinary = new byte[OrderTriggerSerializer.MessageSize];
            OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            }, orderTriggerBinary);
            orderTriggerJsonString = JsonConvert.SerializeObject(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            });

            bookRequestBinary = new byte[BookRequestSerializer.MessageSize];
            BookRequestSerializer.Serialize(new BookRequest {
            }, bookRequestBinary);
            bookRequestJsonString = JsonConvert.SerializeObject(new BookRequest {
            });
            bookRequest2Bytes     = MessagePackSerializer.Serialize(new BookRequest2 {
            });

            bookDepth      = new BookDepth(1234, 100, bid, ask);
            bookJsonString = JsonConvert.SerializeObject(bookDepth);
            bookBinary     = new byte[OrderSerializer.MessageSize];
            BookSerializer.Serialize(bookDepth, bookBinary);

            fill = new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            };
            order2 = new Order2 {
                IsBuy = true, IsTip = false, OpenQuantity = 100, OrderId = 1001, Price = 400, Quantity = 100, Sequnce = 0, StopPrice = 0
            };
            this.order = new Order {
                IsBuy = true, OpenQuantity = 100, OrderId = 1001, Price = 400, Sequnce = 0, TotalQuantity = 100, OrderCondition = OrderCondition.None, StopPrice = 0
            };
            cancelledOrder = new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            };
            cancelRequest = new CancelRequest {
                OrderId = 1023
            };
            orderTrigger = new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            };
            bookRequest = new BookRequest {
                LevelCount = 50
            };
            bookRequest2 = new BookRequest2 {
                LevelCount = 50
            };
        }