Ejemplo n.º 1
0
        //to need to do subscribe stuff
        private Task SendRandomTicker(TickerDto tickerInfo)
        {
            if (contextHolder.TickerHubClients == null)
            {
                return(Task.FromResult(false));
            }

            Log.InfoFormat("Broadcast new trade to blotters: {0}", tickerInfo);
            return(contextHolder.TickerHubClients.Group(TickerHub.TickerGroupName).SendTickers(new[] { tickerInfo }));
        }
Ejemplo n.º 2
0
        public void StoreTicker(TickerDto tickerInfo)
        {
            lock (syncLock)
            {
                tickers.Enqueue(tickerInfo);

                if (tickers.Count > MaxTrades)
                {
                    tickers.Dequeue();
                }
            }
        }
        public void PublishTrade(TickerDto ticker)
        {
            if (actor == null)
            {
                return;
            }

            actor.
            SendMore(PublishTicker).
            SendMore(StreamingProtocol.TradesTopic).
            Send(JsonConvert.SerializeObject(ticker));
        }
Ejemplo n.º 4
0
        public async Task <Ticker> Ticker(string symbol)
        {
            try
            {
                TickerDto orderBookDto = await _publicApi.Ticker(symbol);

                var res = new Ticker()
                {
                    Code = orderBookDto.Code,
                    Data = new List <Tick>()
                };

                foreach (var order in orderBookDto.Data)
                {
                    res.Data.Add(new Tick
                    {
                        Ask        = ParseDecimal(order.Ask),
                        Bid        = ParseDecimal(order.Bid),
                        ChangeRate = order.ChangeRate,
                        High       = ParseDecimal(order.High),
                        Last       = ParseDecimal(order.Last),
                        Low        = ParseDecimal(order.Low),
                        Open       = ParseDecimal(order.Open),
                        Symbol     = order.Symbol,
                        Time       = order.Time,
                        Volume     = ParseDecimal(order.Volume),
                    });
                }

                return(res);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 5
0
 public Ticker Create(TickerDto ticker)
 {
     return(new Ticker(
                ticker.Name,
                ticker.Price));
 }
Ejemplo n.º 6
0
 internal static Ticker FromTickerDto(TickerDto tickerDto)
 {
     throw new NotImplementedException();
 }
            private void PublishTicker(string json)
            {
                TickerDto tickerDto = JsonConvert.DeserializeObject <TickerDto>(json);

                subject.OnNext(tickerDto);
            }