public GroupHistoryViewModel(IStockProvider dataService)
        {
            _dataService = dataService;

            StockGroups = new ObservableCollection <StockQuoteGroup>();

            var groupingsStream = from quote in _dataService.StockQuoteStream.ObserveOnDispatcher()
                                  group quote by quote.Symbol into company
                                  let grp = new StockQuoteGroup(company.Key)
                                            from quote in company
                                            select new
            {
                Group = grp,
                Quote = quote
            };

            var res = groupingsStream.Select(item =>
            {
                //Add it to the list of all groups if it doesn't exist
                if (!StockGroups.Contains(item.Group))
                {
                    StockGroups.Insert(0, item.Group);
                }
                item.Group.Quotes.Insert(0, item.Quote);
                item.Group.Latest = item.Quote;

                return(item);
            });

            res.Subscribe();
        }
 public StockService(ILogger <StockService> logger, IStockProvider stockProvider, ICsvDataProvider csvDataProvider, IStockRespository stockRespository)
 {
     this.logger           = logger;
     this.stockProvider    = stockProvider;
     this.csvDataProvider  = csvDataProvider;
     this.stockRespository = stockRespository;
 }
        public GroupHistoryViewModel(IStockProvider dataService)
        {
            _dataService = dataService;

            StockGroups = new ObservableCollection<StockQuoteGroup>();

            var groupingsStream = from quote in _dataService.StockQuoteStream.ObserveOnDispatcher()
                                  group quote by quote.Symbol into company
                                  let grp = new StockQuoteGroup(company.Key)
                                  from quote in company
                                  select new
                                  {
                                      Group = grp,
                                      Quote = quote
                                  };

            var res =  groupingsStream.Select(item =>
            {
                //Add it to the list of all groups if it doesn't exist
                if (!StockGroups.Contains(item.Group))
                {
                    StockGroups.Insert(0, item.Group);
                }
                item.Group.Quotes.Insert(0, item.Quote);
                item.Group.Latest = item.Quote;

                return item;
            });
            res.Subscribe();
        }
Beispiel #4
0
        // **********************************************************************

        public static void Deactivate()
        {
            foreach (IConnector connector in connectors)
            {
                IStockProvider sp = connector as IStockProvider;
                if (sp != null)
                {
                    sp.Unsubscribe();
                }

                ITicksProvider tp = connector as ITicksProvider;
                if (tp != null)
                {
                    tp.Unsubscribe();
                }

                ISettingsProvider stp = connector as ISettingsProvider;
                if (stp != null)
                {
                    stp.Unsubscribe();
                }

                ITradesProvider trp = connector as ITradesProvider;
                if (trp != null)
                {
                    trp.Unsubscribe();
                }
            }

            Activated = false;
        }
Beispiel #5
0
        public GroupViewModel(IStockProvider dataService)
        {
            _dataService = dataService;
            Quotes = new ObservableCollection<StockQuote>();

            var singleStream = _dataService.StockQuoteStream.ObserveOnDispatcher();
            singleStream.Subscribe(UpdateQuoteCallback());
        }
Beispiel #6
0
 public ChatService(IMessageRepository messageRepository, IMapper mapper, ILogger <ChatService> logger, IStockProvider stockProvider, IHubProvider hubProvider)
 {
     _messageRepo   = messageRepository;
     _mapper        = mapper;
     _logger        = logger;
     _stockProvider = stockProvider;
     _hubProvider   = hubProvider;
 }
Beispiel #7
0
        public GroupViewModel(IStockProvider dataService)
        {
            _dataService = dataService;
            Quotes       = new ObservableCollection <StockQuote>();

            var singleStream = _dataService.StockQuoteStream.ObserveOnDispatcher();

            singleStream.Subscribe(UpdateQuoteCallback());
        }
 public CartController(IShoppingCartProvider shoppingCartProvider, IAccountProvider accountProvider,
                       IPluginClassesService pluginClassesService, IStockProvider stockProvider,
                       IApplicationProvider applicationProvider)
 {
     _applicationProvider  = applicationProvider ?? throw new ArgumentNullException(nameof(applicationProvider));
     _shoppingCartProvider = shoppingCartProvider ?? throw new ArgumentNullException(nameof(shoppingCartProvider));
     _accountProvider      = accountProvider ?? throw new ArgumentNullException(nameof(accountProvider));
     _pluginClassesService = pluginClassesService ?? throw new ArgumentNullException(nameof(pluginClassesService));
     _stockProvider        = stockProvider ?? throw new ArgumentNullException(nameof(stockProvider));
 }
        public CachedStockProvider(IStockProvider stockProvider, IDistributedCache cache)
        {
            this.stockProvider = stockProvider ?? throw new ArgumentNullException(nameof(stockProvider));
            this.cache         = cache ?? throw new ArgumentNullException(nameof(cache));

            this.cacheOptions = new DistributedCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)
            };
        }
Beispiel #10
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IStockProvider dataService)
        {
            _dataService = dataService;
            BVM = new BasicViewModel(dataService);
            GVM = new GroupViewModel(dataService);
            GHVM = new GroupHistoryViewModel(dataService);

            var loStreamQuote = _dataService.StockQuoteStream.ObserveOnDispatcher()
                .Scan((quoteA, quoteB) => StockQuote.MinPrice(quoteA, quoteB)).DistinctUntilChanged();
            var hiStreamQuote = _dataService.StockQuoteStream.ObserveOnDispatcher()
                .Scan((quoteA, quoteB) => StockQuote.MaxPrice(quoteA, quoteB)).DistinctUntilChanged();

            loStreamQuote.Subscribe(quote => LoQuote = quote);
            hiStreamQuote.Subscribe(quote => HiQuote = quote);
        }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IStockProvider dataService)
        {
            _dataService = dataService;
            BVM          = new BasicViewModel(dataService);
            GVM          = new GroupViewModel(dataService);
            GHVM         = new GroupHistoryViewModel(dataService);

            var loStreamQuote = _dataService.StockQuoteStream.ObserveOnDispatcher()
                                .Scan((quoteA, quoteB) => StockQuote.MinPrice(quoteA, quoteB)).DistinctUntilChanged();
            var hiStreamQuote = _dataService.StockQuoteStream.ObserveOnDispatcher()
                                .Scan((quoteA, quoteB) => StockQuote.MaxPrice(quoteA, quoteB)).DistinctUntilChanged();

            loStreamQuote.Subscribe(quote => LoQuote = quote);
            hiStreamQuote.Subscribe(quote => HiQuote = quote);
        }
Beispiel #12
0
        public ProductController(IProductProvider productProvider, ISettingsProvider settingsProvider,
                                 IPluginHelperService pluginHelper, IStockProvider stockProvider)
        {
            if (settingsProvider == null)
            {
                throw new ArgumentNullException(nameof(settingsProvider));
            }

            ProductControllerSettings settings = settingsProvider.GetSettings <ProductControllerSettings>("Products");

            _productProvider = productProvider ?? throw new ArgumentNullException(nameof(productProvider));
            _stockProvider   = stockProvider ?? throw new ArgumentNullException(nameof(stockProvider));
            _productsPerPage = settings.ProductsPerPage;
            _hasShoppingCart = pluginHelper.PluginLoaded(SharedPluginFeatures.Constants.PluginNameShoppingCart, out _);
        }
Beispiel #13
0
        // **********************************************************************

        static MarketProvider()
        {
            foreach (IConnector connector in connectors)
            {
                IStockProvider sp = connector as IStockProvider;
                if (sp != null)
                {
                    sp.Connected    += new StatusUpdateHandler(StockConnected);
                    sp.Disconnected += StockStatus.Disconnected;
                    sp.Broken       += StockStatus.SetError;
                    sp.StockHandler += new StockHandler(StockHandler);
                }

                ITicksProvider tp = connector as ITicksProvider;
                if (tp != null)
                {
                    tp.Connected    += TicksStatus.Connected;
                    tp.Disconnected += TicksStatus.Disconnected;
                    tp.Broken       += TicksStatus.SetError;
                    tp.TickHandler  += new TickHandler(TickHandler);
                }

                ISettingsProvider stp = connector as ISettingsProvider;
                if (stp != null)
                {
                    stp.Connected       += SettingsStatus.Connected;
                    stp.Disconnected    += SettingsStatus.Disconnected;
                    stp.Broken          += SettingsStatus.SetError;
                    stp.SettingsHandler += new SettingsHandler(SettingsHandler);
                }

                ITradesProvider trp = connector as ITradesProvider;
                if (trp != null)
                {
                    trp.Connected     += TradeStatus.Connected;
                    trp.Disconnected  += TradeStatus.Disconnected;
                    trp.Broken        += TradeStatus.SetError;
                    trp.TradesHandler += new TradesHandler(TradesHandler);
                }
            }

            Receiver    = new IDataReceiver[1];
            Receiver[0] = new NullReceiver();

            Activated = false;
        }
Beispiel #14
0
        // **********************************************************************

        public static void Activate()
        {
            if (!isReplayMode)
            {
                foreach (IConnector connector in connectors)
                {
                    connector.Setup();

                    IStockProvider sp = connector as IStockProvider;
                    if (sp != null)
                    {
                        if (sp == stockProvider)
                        {
                            sp.Subscribe(cfg.u.SecCode);
                        }
                        else
                        {
                            sp.Unsubscribe();
                        }
                    }

                    ITicksProvider tp = connector as ITicksProvider;
                    if (tp != null)
                    {
                        tp.Subscribe();
                    }

                    ISettingsProvider stp = connector as ISettingsProvider;
                    if (stp != null)
                    {
                        stp.Subscribe();
                    }

                    ITradesProvider trp = connector as ITradesProvider;
                    if (trp != null)
                    {
                        trp.Subscribe();
                    }
                }
            }

            Activated = true;
        }
Beispiel #15
0
        // **********************************************************************

        public static void SetMode(bool replay, bool nullTader)
        {
            if (isReplayMode != replay)
            {
                if (isReplayMode = replay)
                {
                    foreach (IConnector connector in connectors)
                    {
                        IStockProvider sp = connector as IStockProvider;
                        if (sp != null)
                        {
                            sp.Unsubscribe();
                        }

                        ITicksProvider tp = connector as ITicksProvider;
                        if (tp != null)
                        {
                            tp.Unsubscribe();
                        }

                        ISettingsProvider stp = connector as ISettingsProvider;
                        if (stp != null)
                        {
                            stp.Unsubscribe();
                        }

                        ITradesProvider trp = connector as ITradesProvider;
                        if (trp != null)
                        {
                            trp.Unsubscribe();
                        }
                    }
                }
            }

            isNullTrader = nullTader;

            Activate();
        }
Beispiel #16
0
 public StockController(IStockProvider provider)
 {
     _provider = provider;
 }
Beispiel #17
0
 public UpdateParser(ITelegramBot telegramBot, IStockProvider stockProvider, CompanyInfoProvider companyInfoProvider)
 {
     this.telegramBot         = telegramBot ?? throw new ArgumentNullException(nameof(telegramBot));
     this.stockProvider       = stockProvider ?? throw new ArgumentNullException(nameof(stockProvider));
     this.companyInfoProvider = companyInfoProvider ?? throw new ArgumentNullException(nameof(companyInfoProvider));
 }
Beispiel #18
0
 public StockManager(IStockProvider stockProvider, ICurrencyConverter currencyConverter)
 {
     this.stockProvider     = stockProvider;
     this.currencyConverter = currencyConverter;
 }
Beispiel #19
0
 public Task<StockQuota> GetQuotaAsync( Stock stock )
 {
     this.provider = StockProviderFactory.Create( stock.Provider );
     return this.provider.GetQuotaAsync( stock.Symbol );
 }
Beispiel #20
0
 public APIController(ISentimentProvider sentimentProvider, IStockProvider stockProvider)
 {
     _sentimentProvider = sentimentProvider;
     _stockProvider     = stockProvider;
 }
Beispiel #21
0
 /// <summary>
 /// Initializes a new instance of the BasicViewModel class.
 /// </summary>
 public BasicViewModel(IStockProvider dataService)
 {
     _dataService = dataService;
     Quotes = new ObservableCollection<StockQuote>();
     _dataService.StockQuoteStream.ObserveOnDispatcher().Subscribe(SubscribeCallback);
 }
 public StockController(IStockProvider stockprovider)
 {
     _stockprovider = stockprovider;
 }
Beispiel #23
0
 /// <summary>
 /// Initializes a new instance of the BasicViewModel class.
 /// </summary>
 public BasicViewModel(IStockProvider dataService)
 {
     _dataService = dataService;
     Quotes       = new ObservableCollection <StockQuote>();
     _dataService.StockQuoteStream.ObserveOnDispatcher().Subscribe(SubscribeCallback);
 }
Beispiel #24
0
 public ValuesController(IStockProvider stockProvider, CompanyInfoProvider companyInfoProvider, IDistributedCache cache)
 {
     this.stockProvider       = stockProvider ?? throw new System.ArgumentNullException(nameof(stockProvider));
     this.companyInfoProvider = companyInfoProvider ?? throw new System.ArgumentNullException(nameof(companyInfoProvider));
     this.cache = cache ?? throw new System.ArgumentNullException(nameof(cache));
 }
Beispiel #25
0
 public BookingFactory(IStockProvider stockProvider) => this.stockProvider = stockProvider;
Beispiel #26
0
 public Stock(IStockProvider stockProvider)
 {
     this.stockProvider = stockProvider;
 }