public async Task Start(string pricepairname = "NEBLBTC", KlineInterval kli = KlineInterval.OneMinute)
        {
            var subResult = await _socketClient.Spot.SubscribeToKlineUpdatesAsync(pricepairname, kli, data =>
            {
                LastKline = data;
                OnKlineData?.Invoke(data);
            });

            if (subResult.Success)
            {
                _subscription = subResult.Data;
            }
        }
Exemplo n.º 2
0
        public async Task Start()
        {
            var subResult = await _socketClient.SubscribeToKlineUpdatesAsync("BTCUSDT", KlineInterval.FifteenMinutes, data =>
            {
                LastKline = data;
                OnKlineData?.Invoke(data);
            });

            if (subResult.Success)
            {
                _subscription = subResult.Data;
            }
        }
        public void Arrange()
        {
            _fixture = new Fixture();
            _fixture.Register <Uri>(() => new Uri($"https://{_fixture.Create<string>()}.com/{_fixture.Create<string>()}"));

            _subscriptionManagerMock = new Mock <ISubscriptionManager>();

            _loggerMock = new Mock <ILoggerWrapper>();

            _function = new UpdateSubscription(
                _subscriptionManagerMock.Object,
                _loggerMock.Object);

            _cancellationToken = new CancellationToken();
        }
        public void should_call_UpdateSubscription()
        {
            //arrange
            var request = new UpdateSubscription
            {
                Nickname = "My new nickname",
            };
            //act
            var actual = Sut.UpdateSubscription(AddSubscription(), request);

            //assert
            Assert.AreEqual(202, actual.Code);
            Assert.IsEmpty(actual.Message);
            Assert.AreEqual("OK", actual.Status);
        }
        public async Task <IHttpActionResult> UpdateSubscription([FromUri] Guid id, [FromBody] UpdateSubscription request)
        {
            try
            {
                await CommandService.UpdateSubscription(id, request);

                return(Ok());
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                // Can be fine tuned to throw a general exception instead of sending the server exception
                return(InternalServerError(ex));
            }
        }
 public async Task SubscribeAllTickerUpdates()
 {
     Console.WriteLine($"  --- Starting {ExchName} SymbolTickerUpdates thread ---");
     var crSubSymbolTicker = sock.SubscribeToSymbolSummariesUpdate((ticks) =>
     {
         Task.Factory.StartNew(() => ProduceToKafka(ticks));
         /*//Console.WriteLine($"[{ExchName}]   {ticks.Count()} symbol ticker updates received");
         var tick = ticks.First();
         //Console.WriteLine($"[{ExchName} {tick.Symbol}]   {tick.BidQuantity}x{tick.BidPrice}  {tick.AskPrice}x{tick.AskQuantity}   (example 1st update)");
         int bidQty = 0, askQty = 0; // Bittrex Tick does not have BidQty/AskQty
         //Console.WriteLine($"{tick.TimeStamp:G} [{ExchName} {tick.Symbol}]  {tick.Last} ({tick.BaseVolume}/{tick.Volume})   B  {bidQty} : {tick.Bid}  x  {tick.Ask} x {askQty}  A");
         string msg = string.Format($"{tick.TimeStamp:G},{ExchName},{tick.Symbol},{tick.Last},{tick.BaseVolume},{tick.Volume},{bidQty},{tick.Bid},{tick.Ask},{askQty}");
         //Console.WriteLine(msg);
         _p.Produce(msg);*/
     });
     
     this.subscription = crSubSymbolTicker.Data;
 }
        public async Task SubscribeSymbolTickerUpdates(string rawSymbol, int i = -1, int count = -1)
        {
            string symbol = "t" + rawSymbol.ToUpper();
            //Console.WriteLine($"  --- Subscribing to [{ExchName} {symbol}]    ( {i} / {count} ) ---");
            var crSubSymbolTicker = await sock.SubscribeToTickerUpdatesAsync(symbol, (tick) =>
            {
                Task.Factory.StartNew(() => ProduceToKafka(tick, symbol));
                /*//Console.WriteLine($"[{ExchName}]   1 symbol ticker updates received");
                int quoteVolume = 0;
                DateTime dt = DateTime.Now.ToUniversalTime();
                //Console.WriteLine($"{dt:G} [{ExchName} {symbol}]  {tick.LastPrice} ({tick.Volume}/{quoteVolume})    B {tick.BidSize} : {tick.Bid}  x  {tick.Ask} : {tick.AskSize} A");
                string msg = string.Format($"{dt:G},{ExchName},{symbol},{tick.LastPrice},{tick.Volume},{quoteVolume},{tick.BidSize},{tick.Bid},{tick.Ask},{tick.AskSize}");
                //Console.WriteLine(msg);
                _p.Produce(msg);*/
            });

            this.subscription = crSubSymbolTicker.Data;
        }
Exemplo n.º 8
0
        public async Task SubscribeAllTickerUpdates()
        {
            Console.WriteLine($"  --- Starting {ExchName} SymbolTickerUpdates thread ---");
            var crSubSymbolTicker = sock.Spot.SubscribeToAllSymbolTickerUpdates((ticks) =>
            {
                Task.Factory.StartNew(() => ProduceToKafka(ticks));

                /*//Console.WriteLine($"[{ExchName}]   {ticks.Count()} symbol ticker updates received");
                 * var tick = ticks.First();
                 * //tick.LastQuantity
                 * //Console.WriteLine($"{tick.CloseTime:G} [{ExchName} {tick.Symbol}]  {tick.LastPrice} ({tick.BaseVolume}/{tick.QuoteVolume})    B {tick.LastPrice}{tick.BidQuantity} : {tick.BidPrice}  x  {tick.AskPrice} : {tick.AskQuantity} A");
                 * string msg = string.Format($"{tick.CloseTime:G},{ExchName},{tick.Symbol},{tick.LastPrice},{tick.BaseVolume},{tick.QuoteVolume},{tick.LastPrice}{tick.BidQuantity},{tick.BidPrice},{tick.AskPrice},{tick.AskQuantity}");
                 * //Console.WriteLine(msg);
                 * _p.Produce(msg);*/
            });

            this.subscription = crSubSymbolTicker.Data;
        }
        public UpdateSubscriptionResponse Put(UpdateSubscription request)
        {
            var now          = SystemTime.UtcNow.ToNearestSecond();
            var subscription = Store.Get(request.Id);

            if (subscription == null)
            {
                throw HttpError.NotFound(null);
            }

            if (request.Url.HasValue() &&
                request.Url.NotEqualsIgnoreCase(subscription.Config.Url))
            {
                subscription.Config.Url = request.Url;
            }
            if (request.Secret.HasValue() &&
                request.Secret.NotEqualsIgnoreCase(subscription.Config.Secret))
            {
                subscription.Config.Secret = request.Secret;
            }
            if (request.ContentType.HasValue() &&
                request.ContentType.NotEqualsIgnoreCase(subscription.Config.ContentType))
            {
                subscription.Config.ContentType = request.ContentType;
            }
            if (request.IsActive.HasValue &&
                request.IsActive.Value != subscription.IsActive)
            {
                subscription.IsActive = request.IsActive.Value;
            }
            subscription.LastModifiedDateUtc = now;

            Store.Update(request.Id, subscription);

            logger.InfoFormat(@"[ServiceStack.Webhooks.ServiceInterface.SubscriptionService] Updated subscription {0} by user {1}", subscription.Id, Caller.UserId);

            return(new UpdateSubscriptionResponse
            {
                Subscription = subscription
            });
        }
Exemplo n.º 10
0
        public void UnsubscribingStream_Should_CloseTheSocket()
        {
            // arrange
            var client = new TestSocketClient(new SocketClientOptions("")
            {
                ReconnectInterval = TimeSpan.Zero, LogVerbosity = LogVerbosity.Debug
            });
            var socket = client.CreateSocket();

            socket.CanConnect = true;
            var sub = new SocketConnection(client, socket);

            client.ConnectSocketSub(sub);
            var ups = new UpdateSubscription(sub, SocketSubscription.CreateForIdentifier("Test", true, (d, a) => {}));

            // act
            client.Unsubscribe(ups).Wait();

            // assert
            Assert.IsTrue(socket.Connected == false);
        }
Exemplo n.º 11
0
 public async Task Unsubscribe(UpdateSubscription subscription)
 {
     await _socketClient.UnsubscribeAsync(subscription);
 }
Exemplo n.º 12
0
 static async Task BitfinexUnsubscribe(BitfinexSocketClient sock, UpdateSubscription subscription)
 {
     await sock.Unsubscribe(subscription);
 }
Exemplo n.º 13
0
 static async Task BinanceUnsubscribe(BinanceSocketClient sock, UpdateSubscription subscription)
 {
     await sock.Unsubscribe(subscription);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Unsubscribe from a stream
 /// * NOT SUPPORTED BY BITTREX' CURRENT SOCKET IMPLEMENTATION *
 /// </summary>
 /// <param name="subscription">The subscription to unsubscribe</param>
 /// <returns></returns>
 public override Task Unsubscribe(UpdateSubscription subscription)
 {
     throw new NotImplementedException("Bittrex sockets do not offer unsubscription functionality");
 }
Exemplo n.º 15
0
        private static void RunMethod(string methodName)
        {
            // These are default transaction keys.
            // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/
            string apiLoginId     = "5KP3u95bQpv";
            string transactionKey = "4Ktq966gC55GAX7S";

            string transactionAmount;
            string transactionId = string.Empty;

            switch (methodName)
            {
            case "ValidateCustomerPaymentProfile":
                ValidateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "UpdateCustomerShippingAddress":
                UpdateCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "UpdateCustomerProfile":
                UpdateCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "UpdateCustomerPaymentProfile":
                UpdateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerShippingAddress":
                GetCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerProfileIds":
                GetCustomerProfileIds.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerProfile":
                GetCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetCustomerPaymentProfile":
                GetCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerShippingAddress":
                DeleteCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerProfile":
                DeleteCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "DeleteCustomerPaymentProfile":
                DeleteCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerShippingAddress":
                CreateCustomerShippingAddress.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerProfileFromTransaction":
                CreateCustomerProfileFromTransaction.Run(apiLoginId, transactionKey);
                break;

            case "GetTransactionDetails":
                GetTransactionDetails.Run(apiLoginId, transactionKey);
                break;

            case "GetTransactionList":
                GetTransactionList.Run(apiLoginId, transactionKey);
                break;

            //case "CreateAnApplePayTransaction":
            //    CreateAnApplePayTransaction.Run(apiLoginId, transactionKey);
            //    break;
            case "DecryptVisaCheckoutData":
                DecryptVisaCheckoutData.Run(apiLoginId, transactionKey);
                break;

            case "CreateVisaCheckoutTransaction":
                CreateVisaCheckoutTransaction.Run(apiLoginId, transactionKey);
                break;

            case "ChargeCreditCard":
                ChargeCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "CaptureOnly":
                CaptureOnly.Run(apiLoginId, transactionKey);
                break;

            case "CapturePreviouslyAuthorizedAmount":
                Console.WriteLine("Enter An Transaction Amount");
                transactionAmount = Console.ReadLine();

                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                CapturePreviouslyAuthorizedAmount.Run(apiLoginId, transactionKey, Convert.ToDecimal(transactionAmount), transactionId);
                break;

            case "CaptureFundsAuthorizedThroughAnotherChannel":
                CaptureFundsAuthorizedThroughAnotherChannel.Run(apiLoginId, transactionKey);
                break;

            case "AuthorizeCreditCard":
                AuthorizeCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "Refund":
                Console.WriteLine("Enter An Transaction Amount");
                transactionAmount = Console.ReadLine();

                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                RefundTransaction.Run(apiLoginId, transactionKey, Convert.ToDecimal(transactionAmount), transactionId);
                break;

            case "Void":
                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                VoidTransaction.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "DebitBankAccount":
                DebitBankAccount.Run(apiLoginId, transactionKey);
                break;

            case "CreditBankAccount":
                Console.WriteLine("Enter An Transaction ID");
                transactionId = Console.ReadLine();

                CreditBankAccount.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "ChargeCustomerProfile":
                ChargeCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "ChargeTokenizedCard":
                ChargeTokenizedCreditCard.Run(apiLoginId, transactionKey);
                break;

            case "PayPalVoid":
                PayPalVoid.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalAuthorizeCapture":
                PayPalAuthorizeCapture.Run(apiLoginId, transactionKey);
                break;

            case "PayPalAuthorizeCaptureContinue":
                PayPalAuthorizeCaptureContinue.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalAuthorizeOnly":
                PayPalAuthorizeOnly.Run(apiLoginId, transactionKey);
                break;

            case "PayPalAuthorizeOnlyContinue":
                PayPalAuthorizeCaptureContinue.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalCredit":
                PayPalCredit.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalGetDetails":
                PayPalGetDetails.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "PayPalPriorAuthorizationCapture":
                PayPalPriorAuthorizationCapture.Run(apiLoginId, transactionKey, transactionId);
                break;

            case "CancelSubscription":
                CancelSubscription.Run(apiLoginId, transactionKey);
                break;

            case "CreateSubscription":
                CreateSubscription.Run(apiLoginId, transactionKey);
                break;

            case "GetSubscriptionList":
                GetListSubscriptions.Run(apiLoginId, transactionKey);
                break;

            case "GetSubscriptionStatus":
                GetSubscriptionStatus.Run(apiLoginId, transactionKey);
                break;

            case "UpdateSubscription":
                UpdateSubscription.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerProfile":
                CreateCustomerProfile.Run(apiLoginId, transactionKey);
                break;

            case "CreateCustomerPaymentProfile":
                CreateCustomerPaymentProfile.Run(apiLoginId, transactionKey);
                break;

            case "GetUnsettledTransactionList":
                GetUnsettledTransactionList.Run(apiLoginId, transactionKey);
                break;

            case "GetBatchStatistics":
                GetBatchStatistics.Run(apiLoginId, transactionKey);
                break;

            case "GetSettledBatchList":
                GetSettledBatchList.Run(apiLoginId, transactionKey);
                break;

            default:
                ShowUsage();
                break;
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Update a subscription
 /// details: https://developer.chargeover.com/apidocs/rest/#update-recurring-package
 /// </summary>
 public IIdentityResponse UpdateSubscription(int id, UpdateSubscription request)
 {
     return(new IdentityResponse(Request <UpdateSubscription, IdentityChargeOverResponse>(MethodType.PUT, "/package/" + id, request)));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Unsubscribe from a stream
 /// </summary>
 /// <param name="subscription">The subscription to unsubscribe</param>
 /// <returns></returns>
 public virtual async Task Unsubscribe(UpdateSubscription subscription)
 {
     log.Write(LogVerbosity.Info, $"Closing subscription {subscription.Id}");
     await subscription.Close().ConfigureAwait(false);
 }
Exemplo n.º 18
0
 public async Task UpdateSubscription(Guid subcriptionId, UpdateSubscription updateSubscription)
 {
     await SubscriptionDomainService.UpdateSubscription(subcriptionId, updateSubscription);
 }