Ejemplo n.º 1
0
        public async Task <CallResult <UpdateSubscription> > SubscribeToKlinesAsync(string symbol, BtcTurkPeriod period, Action <BtcTurkStreamKline> onData)
        {
            var request         = new BtcTurkSocketRequest(151, "tradeview", $"{symbol}_{JsonConvert.SerializeObject(period, new PeriodEnumConverter(false))}", true);
            var internalHandler = new Action <BtcTurkSocketResponse>(data => onData(JsonConvert.DeserializeObject <BtcTurkStreamKline>(data.Data)));

            return(await Subscribe(request.RequestObject(), null, false, internalHandler).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public async Task <CallResult <UpdateSubscription> > SubscribeToTickersAsync(Action <BtcTurkStreamTickerAll> onData)
        {
            var request         = new BtcTurkSocketRequest(151, "ticker", "all", true);
            var internalHandler = new Action <BtcTurkSocketResponse>(data => onData(JsonConvert.DeserializeObject <BtcTurkStreamTickerAll>(data.Data)));

            return(await Subscribe(request.RequestObject(), null, false, internalHandler).ConfigureAwait(false));
        }
Ejemplo n.º 3
0
        public async Task <CallResult <UpdateSubscription> > SubscribeToOrderBookFullAsync(string symbol, Action <BtcTurkStreamOrderBookFull> onData)
        {
            var request         = new BtcTurkSocketRequest(151, "orderbook", symbol, true);
            var internalHandler = new Action <BtcTurkSocketResponse>(data => onData(JsonConvert.DeserializeObject <BtcTurkStreamOrderBookFull>(data.Data)));

            return(await Subscribe(request.RequestObject(), null, false, internalHandler).ConfigureAwait(false));
        }
Ejemplo n.º 4
0
        public virtual async Task <CallResult <UpdateSubscription> > SubscribeToTickerAsync(string symbol, Action <BtcTurkStreamTickerSingle> onData)
        {
            var request         = new BtcTurkSocketRequest(151, "ticker", symbol, true);
            var internalHandler = new Action <DataEvent <BtcTurkSocketResponse> >(data => onData(JsonConvert.DeserializeObject <BtcTurkStreamTickerSingle>(data.Data.Data)));

            return(await SubscribeAsync(request.RequestObject(), null, false, internalHandler).ConfigureAwait(false));
        }
Ejemplo n.º 5
0
        public async Task <CallResult <UpdateSubscription> > SubscribeToTradesAsync(string symbol, Action <BtcTurkStreamTradeList> onListData, Action <BtcTurkStreamTradeSingle> onRowData)
        {
            var request         = new BtcTurkSocketRequest(151, "trade", symbol, true);
            var internalHandler = new Action <BtcTurkSocketResponse>(data =>
            {
                if (data.Model == 421)
                {
                    onListData(JsonConvert.DeserializeObject <BtcTurkStreamTradeList>(data.Data));
                }
                if (data.Model == 422)
                {
                    onRowData(JsonConvert.DeserializeObject <BtcTurkStreamTradeSingle>(data.Data));
                }
            }
                                                                     );

            return(await Subscribe(request.RequestObject(), null, false, internalHandler).ConfigureAwait(false));
        }
Ejemplo n.º 6
0
        public async Task <CallResult <UpdateSubscription> > SubscribeToOrderBookDiffAsync(string symbol, Action <BtcTurkStreamOrderBookFull> onFullData, Action <BtcTurkStreamOrderBookDifference> onDiffData)
        {
            var request         = new BtcTurkSocketRequest(151, "obdiff", symbol, true);
            var internalHandler = new Action <BtcTurkSocketResponse>(data =>
            {
                if (data.Model == 431)
                {
                    onFullData(JsonConvert.DeserializeObject <BtcTurkStreamOrderBookFull>(data.Data));
                }
                if (data.Model == 432)
                {
                    onDiffData(JsonConvert.DeserializeObject <BtcTurkStreamOrderBookDifference>(data.Data));
                }
            }
                                                                     );

            return(await Subscribe(request.RequestObject(), null, false, internalHandler).ConfigureAwait(false));
        }