示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BinanceTradingProvider"/> class.
        /// </summary>
        /// <param name="loggerFactory">Used to create output stream.</param>
        /// <param name="communications">For communication with Binance.</param>
        /// <param name="timer">Timer for subscribing to periodic updates.</param>
        public BinanceTradingProvider(ILoggerFactory loggerFactory, BinanceCommunicationsService communications, TimerProvider timer)
            : base(loggerFactory, timer)
        {
            _communications      = communications;
            _orderCache          = new ConcurrentQueue <OrderUpdate>();
            _transformMiddleWare = new Dictionary <long, Action <OrderUpdate> >();

            // Push order updates from the websocket in a concurrent queue
            communications.OrderUpdateDispenser.Subscribe(new ConfigurableObserver <OrderUpdate>(
                                                              () => { },
                                                              _ => { },
                                                              order =>
            {
                lock (_orderCache)
                {
                    if (_transformMiddleWare.TryGetValue(order.OrderId, out var transform))
                    {
                        transform(order);
                    }
                }

                _orderCache.Enqueue(order);
            }));
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BinanceDataProvider"/> class.
 /// </summary>
 /// <param name="loggerFactory">Used to create output stream.</param>
 /// <param name="communications">For communication with Binance.</param>
 /// <param name="timerProvider">Ability to keep track of pivots.</param>
 public BinanceDataProvider(ILoggerFactory loggerFactory, BinanceCommunicationsService communications, TimerProvider timerProvider)
     : base(loggerFactory, timerProvider)
 {
     _communications = communications;
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BinancePortfolioFetcher"/> class.
 /// </summary>
 /// <param name="loggerFactory">To enable logging.</param>
 /// <param name="comms">Provides access to binance.</param>
 public BinancePortfolioFetcher(ILoggerFactory loggerFactory, BinanceCommunicationsService comms)
 {
     _logger  = loggerFactory.CreateLogger(GetType());
     _binance = comms;
 }