Exemple #1
0
 public BitfinexSocketQuery(string?id, BitfinexEventType type, object request)
 {
     Id        = id;
     QueryType = type;
     Request   = request;
     Event     = BitfinexEvents.EventMapping.Single(k => k.Value == type).Key;
 }
 public BitfinexEvent(string id, BitfinexEventType type, string category, bool single)
 {
     Id        = id;
     EventType = type;
     Category  = category;
     Single    = single;
 }
        public void Handle(BitfinexEventType type, JArray obj)
        {
            var data = obj[2];

            if (!data.HasValues)
            {
                return;
            }


            if (data[0] is JArray)
            {
                var typed = data.ToObject(EventType.MakeArrayType());
                Handle(type, typed);
            }
            else
            {
                var array = Array.CreateInstance(EventType, 1);
                array.SetValue(data.ToObject(EventType), 0);
                Handle(type, array);
            }
        }
 public BitfinexSocketEvent(BitfinexEventType type, T data)
 {
     EventType = type;
     Data      = data;
 }
Exemple #5
0
        public void SubscribingToFundingOfferUpdates_Should_TriggerWithFundingOfferUpdate(string updateType, BitfinexEventType eventType, bool single = true)
        {
            // arrange
            var socket = new TestSocket();

            socket.CanConnect = true;
            var client = TestHelpers.CreateAuthenticatedSocketClient(socket);

            var rstEvent = new ManualResetEvent(false);
            BitfinexSocketEvent <BitfinexFundingOffer[]> result = null;
            var expected = new BitfinexSocketEvent <BitfinexFundingOffer[]>(eventType, new[] { new BitfinexFundingOffer()
                                                                                               {
                                                                                                   StatusString = "ACTIVE"
                                                                                               } });

            client.SubscribeToFundingUpdatesAsync(data =>
            {
                result = data;
                rstEvent.Set();
            }, null, null);

            // act
            socket.InvokeMessage(new BitfinexAuthenticationResponse()
            {
                Event = "auth", Status = "OK"
            });
            socket.InvokeMessage(single ? new object[] { 0, updateType, new BitfinexFundingOffer()
                                                         {
                                                             StatusString = "ACTIVE"
                                                         } } : new object[] { 0, updateType, new[] { new BitfinexFundingOffer()
                                                                                                     {
                                                                                                         StatusString = "ACTIVE"
                                                                                                     } } });
            rstEvent.WaitOne(1000);

            // assert
            Assert.IsTrue(TestHelpers.AreEqual(result.Data[0], expected.Data[0]));
        }
 protected override void Handle(BitfinexEventType type, object obj)
 {
     handler(new BitfinexSocketEvent <BitfinexTradeDetails[]>(type, (BitfinexTradeDetails[])obj));
 }
 protected abstract void Handle(BitfinexEventType type, object obj);
 protected override void Handle(BitfinexEventType type, object obj)
 {
     handler(new BitfinexSocketEvent <BitfinexPosition[]>(type, (BitfinexPosition[])obj));
 }
Exemple #9
0
        public void SubscribingToPositionUpdates_Should_TriggerWithPositionUpdate(string updateType, BitfinexEventType eventType, bool single = true)
        {
            // arrange
            var socket = new TestSocket();

            socket.CanConnect = true;
            var client = TestHelpers.CreateAuthenticatedSocketClient(socket);

            var rstEvent = new ManualResetEvent(false);
            BitfinexSocketEvent <IEnumerable <BitfinexPosition> > result = null;
            var expected = new BitfinexSocketEvent <IEnumerable <BitfinexPosition> >(eventType, new[] { new BitfinexPosition()
                                                                                                        {
                                                                                                        } });

            client.SubscribeToTradingUpdatesAsync(null, null, data =>
            {
                result = data;
                rstEvent.Set();
            });

            // act
            socket.InvokeMessage(new BitfinexAuthenticationResponse()
            {
                Event = "auth", Status = "OK"
            });
            socket.InvokeMessage(single ? new object[] { 0, updateType, new BitfinexPosition() } : new object[] { 0, updateType, new[] { new BitfinexPosition() } });
            rstEvent.WaitOne(1000);

            // assert
            Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data.First()));
        }
 protected override void Handle(BitfinexEventType type, object obj)
 {
     handler(new BitfinexSocketEvent <BitfinexFundingOffer[]>(type, (BitfinexFundingOffer[])obj));
 }