Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        //TODO: get Name from config file
        public BitfinexClient()
        {
            Name = "Bitfinex market";

            _bitfinexSocketClient = new BitfinexSocketClient();
            _bitfinexClient       = new NativeBitfinexClient();

            _aviablePairs = _bitfinexClient.GetSymbols().Data.ToList().Select(s => new TradingPair(s)).ToList();
        }