Exemple #1
0
        /// <summary>
        /// Add the IBitfinexClient and IBitfinexSocketClient to the sevice collection so they can be injected
        /// </summary>
        /// <param name="services">The service collection</param>
        /// <param name="defaultOptionsCallback">Set default options for the client</param>
        /// <param name="socketClientLifeTime">The lifetime of the IBitfinexSocketClient for the service collection. Defaults to Scoped.</param>
        /// <returns></returns>
        public static IServiceCollection AddBitfinex(
            this IServiceCollection services,
            Action <BitfinexClientOptions, BitfinexSocketClientOptions>?defaultOptionsCallback = null,
            ServiceLifetime?socketClientLifeTime = null)
        {
            if (defaultOptionsCallback != null)
            {
                var options       = new BitfinexClientOptions();
                var socketOptions = new BitfinexSocketClientOptions();
                defaultOptionsCallback?.Invoke(options, socketOptions);

                BitfinexClient.SetDefaultOptions(options);
                BitfinexSocketClient.SetDefaultOptions(socketOptions);
            }

            services.AddTransient <IBitfinexClient, BitfinexClient>();
            if (socketClientLifeTime == null)
            {
                services.AddScoped <IBitfinexSocketClient, BitfinexSocketClient>();
            }
            else
            {
                services.Add(new ServiceDescriptor(typeof(IBitfinexSocketClient), typeof(BitfinexSocketClient), socketClientLifeTime.Value));
            }
            return(services);
        }
        public BitfinexSymbolOrderBook(string symbol, Precision precisionLevel, int limit, LogVerbosity logVerbosity = LogVerbosity.Info, IEnumerable <TextWriter> logWriters = null) : base("Bitfinex", symbol, false, logVerbosity, logWriters)
        {
            socketClient = new BitfinexSocketClient();

            this.limit = limit;
            precision  = precisionLevel;
        }