コード例 #1
0
        public void Serialize_Doesnotthrowexception_Max()
        {
            Span <byte> bytes = stackalloc byte[FillSerializer.MessageSize];

            FillSerializer.Serialize(new Fill {
                MakerOrderId = OrderId.MaxValue, TakerOrderId = OrderId.MaxValue, Timestamp = int.MaxValue, MatchQuantity = int.MaxValue, MatchRate = int.MaxValue, BidCost = Quantity.MaxValue, BidFee = Quantity.MaxValue, AskRemainingQuantity = Quantity.MaxValue, AskFee = Quantity.MaxValue, MessageSequence = long.MaxValue
            }, bytes);
        }
コード例 #2
0
        public void Deserialize_Doesnotthrowexception()
        {
            var bytes = FillSerializer.Serialize(new Fill {
                MakerOrderId = 12345678, TakerOrderId = 56789, Timestamp = 404, MatchQuantity = 2356, MatchRate = 9534, IncomingOrderFilled = true
            });
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(60, messageLength);
            var fill = FillSerializer.Deserialize(bytes);

            Assert.Equal((OrderId)12345678, fill.MakerOrderId);
            Assert.Equal((OrderId)56789, fill.TakerOrderId);
            Assert.Equal((Price)9534, fill.MatchRate);
            Assert.Equal((Quantity)2356, fill.MatchQuantity);
            Assert.Equal(404, fill.Timestamp);
            Assert.True(fill.IncomingOrderFilled);
        }
コード例 #3
0
        public void Deserialize_Doesnotthrowexception_Max()
        {
            var bytes = FillSerializer.Serialize(new Fill {
                MakerOrderId = OrderId.MaxValue, TakerOrderId = OrderId.MaxValue, Timestamp = int.MaxValue, MatchQuantity = int.MaxValue, MatchRate = int.MaxValue, IncomingOrderFilled = true
            });
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(60, messageLength);
            var fill = FillSerializer.Deserialize(bytes);

            Assert.Equal(OrderId.MaxValue, fill.MakerOrderId);
            Assert.Equal(OrderId.MaxValue, fill.TakerOrderId);
            Assert.Equal((Price)int.MaxValue, fill.MatchRate);
            Assert.Equal((Quantity)int.MaxValue, fill.MatchQuantity);
            Assert.Equal(int.MaxValue, fill.Timestamp);
            Assert.True(fill.IncomingOrderFilled);
        }
コード例 #4
0
        public void Deserialize_Doesnotthrowexception_Max()
        {
            var bytes = FillSerializer.Serialize(new Fill {
                MakerOrderId = OrderId.MaxValue, TakerOrderId = OrderId.MaxValue, Timestamp = int.MaxValue, MatchQuantity = int.MaxValue, MatchRate = int.MaxValue, BidCost = Quantity.MaxValue, AskRemainingQuantity = Quantity.MaxValue
            });
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(93, messageLength);
            var fill = FillSerializer.Deserialize(bytes);

            Assert.Equal(OrderId.MaxValue, fill.MakerOrderId);
            Assert.Equal(OrderId.MaxValue, fill.TakerOrderId);
            Assert.Equal(int.MaxValue, fill.MatchRate);
            Assert.Equal(int.MaxValue, fill.MatchQuantity);
            Assert.Equal(int.MaxValue, fill.Timestamp);
            Assert.Equal(Quantity.MaxValue, fill.AskRemainingQuantity);
            Assert.Equal(Quantity.MaxValue, fill.BidCost);
        }
コード例 #5
0
        public void Deserialize_Doesnotthrowexception_AskRemainingQuantityNull()
        {
            var bytes = FillSerializer.Serialize(new Fill {
                MakerOrderId = 12345678, TakerOrderId = 56789, Timestamp = 404, MatchQuantity = 2356, MatchRate = 9534, BidCost = 4347, AskRemainingQuantity = null
            });
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(93, messageLength);
            var fill = FillSerializer.Deserialize(bytes);

            Assert.Equal((OrderId)12345678, fill.MakerOrderId);
            Assert.Equal((OrderId)56789, fill.TakerOrderId);
            Assert.Equal(9534, fill.MatchRate);
            Assert.Equal(2356, fill.MatchQuantity);
            Assert.Equal(404, fill.Timestamp);
            Assert.Equal(4347, fill.BidCost);
            Assert.Null(fill.AskRemainingQuantity);
        }
コード例 #6
0
        public void Deserialize_Doesnotthrowexception_Min()
        {
            Span <byte> bytes = stackalloc byte[FillSerializer.MessageSize];

            FillSerializer.Serialize(new Fill {
                MakerOrderId = OrderId.MinValue, TakerOrderId = OrderId.MinValue, Timestamp = int.MinValue, MatchQuantity = int.MinValue, MatchRate = int.MinValue, BidCost = Quantity.MinValue, BidFee = Quantity.MinValue, AskRemainingQuantity = Quantity.MinValue, AskFee = Quantity.MinValue
            }, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(127, messageLength);
            var fill = FillSerializer.Deserialize(bytes);

            Assert.Equal(OrderId.MinValue, fill.MakerOrderId);
            Assert.Equal(OrderId.MinValue, fill.TakerOrderId);
            Assert.Equal(int.MinValue, fill.MatchRate);
            Assert.Equal(int.MinValue, fill.MatchQuantity);
            Assert.Equal(int.MinValue, fill.Timestamp);
            Assert.Equal(Quantity.MinValue, fill.BidCost);
            Assert.Equal(Quantity.MinValue, fill.BidFee);
            Assert.Equal(Quantity.MinValue, fill.AskRemainingQuantity);
            Assert.Equal(Quantity.MinValue, fill.AskFee);
        }
コード例 #7
0
        public void Deserialize_Doesnotthrowexception_AskRemainingQuantityNull()
        {
            Span <byte> bytes = stackalloc byte[FillSerializer.MessageSize];

            FillSerializer.Serialize(new Fill {
                MakerOrderId = 12345678, TakerOrderId = 56789, Timestamp = 404, MatchQuantity = 2356, MatchRate = 9534, BidCost = 4347, BidFee = 891434, AskRemainingQuantity = null, AskFee = null
            }, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(127, messageLength);
            var fill = FillSerializer.Deserialize(bytes);

            Assert.Equal((OrderId)12345678, fill.MakerOrderId);
            Assert.Equal((OrderId)56789, fill.TakerOrderId);
            Assert.Equal(9534, fill.MatchRate);
            Assert.Equal(2356, fill.MatchQuantity);
            Assert.Equal(404, fill.Timestamp);
            Assert.Equal(4347, fill.BidCost);
            Assert.Equal(891434, fill.BidFee);
            Assert.Null(fill.AskRemainingQuantity);
            Assert.Null(fill.AskFee);
        }
コード例 #8
0
        public void Deserialize_Doesnotthrowexception()
        {
            Span <byte> bytes = stackalloc byte[FillSerializer.MessageSize];

            FillSerializer.Serialize(new Fill {
                MakerOrderId = 12345678, TakerOrderId = 56789, Timestamp = 404, MatchQuantity = 2356, MatchRate = 9534, BidCost = 4347, BidFee = 76157, AskRemainingQuantity = 87135, AskFee = 12103, MessageSequence = 6812379
            }, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(135, messageLength);
            var fill = FillSerializer.Deserialize(bytes);

            Assert.Equal((OrderId)12345678, fill.MakerOrderId);
            Assert.Equal((OrderId)56789, fill.TakerOrderId);
            Assert.Equal(9534, fill.MatchRate);
            Assert.Equal(2356, fill.MatchQuantity);
            Assert.Equal(404, fill.Timestamp);
            Assert.Equal(4347, fill.BidCost);
            Assert.Equal(76157, fill.BidFee);
            Assert.Equal(87135, fill.AskRemainingQuantity);
            Assert.Equal(12103, fill.AskFee);
            Assert.Equal(6812379, fill.MessageSequence);
        }
コード例 #9
0
        public void Serialize_ThrowsExecption_IfNullPassed()
        {
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => FillSerializer.Serialize(null, null));

            Assert.Equal("fill", ex.ParamName);
        }
コード例 #10
0
 public void Serialize_Doesnotthrowexception_Min()
 {
     var bytes = FillSerializer.Serialize(new Fill {
         MakerOrderId = OrderId.MinValue, TakerOrderId = OrderId.MinValue, Timestamp = int.MinValue, MatchQuantity = int.MinValue, MatchRate = int.MinValue, IncomingOrderFilled = true
     });
 }
コード例 #11
0
        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);
        }
コード例 #12
0
 public void fillBinarySerialize()
 {
     var bytes = FillSerializer.Serialize(new Fill {
         MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
     });
 }
コード例 #13
0
 public void Serialize_Doesnotthrowexception_Max()
 {
     var bytes = FillSerializer.Serialize(new Fill {
         MakerOrderId = ulong.MaxValue, TakerOrderId = ulong.MaxValue, Timestamp = long.MaxValue, MatchQuantity = int.MaxValue, MatchRate = int.MaxValue, IncomingOrderFilled = false
     });
 }
コード例 #14
0
 public void Serialize_Doesnotthrowexception_Min()
 {
     var bytes = FillSerializer.Serialize(new Fill {
         MakerOrderId = OrderId.MinValue, TakerOrderId = OrderId.MinValue, Timestamp = int.MinValue, MatchQuantity = int.MinValue, MatchRate = int.MinValue, BidCost = Quantity.MinValue, AskRemainingQuantity = Quantity.MinValue
     });
 }
コード例 #15
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
            };
        }
コード例 #16
0
        public void FillBinarySerialize()
        {
            Span <byte> bytes = stackalloc byte[FillSerializer.MessageSize];

            FillSerializer.Serialize(fill, bytes);
        }