public DataSourceDispatcher(
            IStockDataDataSource assetDataDataSource, IPricesDataSource pricesDataSouce, IOptionChainDataSource optionChainDataSource,
            IFinancialDataSource financialDataSource, IRiskFreeRatesDataSource riskFreeRatesDataSource,
            IAssetTypeDataSource assetTypeDataSource, IStatisticsDataSource statisticsDataSource, IIndexesDataSource indexesDataSource,
            ICacheManager cacheManager)
        {
            //TODO: Implementar un data source builder para poder elegir. Por ejemplo: se puede usar Yahoo, Nasdaq y Reuters para traer los balances
            //

            this.assetDataDataSource     = assetDataDataSource;
            this.pricesDataSouce         = pricesDataSouce;
            this.optionChainDataSource   = optionChainDataSource;
            this.financialDataSource     = financialDataSource;
            this.riskFreeRatesDataSource = riskFreeRatesDataSource;
            this.assetTypeDataSource     = assetTypeDataSource;
            this.statisticsDataSource    = statisticsDataSource;
            this.indexesDataSource       = indexesDataSource;
            this.cacheManager            = cacheManager;
        }
Example #2
0
        public void Test_Serialization()
        {
            IStockDataDataSource     stockDataDataSource     = new ReutersDataSource();
            IPricesDataSource        pricesDataSource        = new YahooDataSource();
            IOptionChainDataSource   optionChainDataSource   = new NasdaqDataSource();
            IFinancialDataSource     financialDataSource     = new NasdaqDataSource();
            IRiskFreeRatesDataSource riskFreeRatesDataSource = null;
            IAssetTypeDataSource     assetTypeDataSource     = null;
            IStatisticsDataSource    statisticsDataSource    = null;
            IIndexesDataSource       indexesDataSource       = null;
            ICacheManager            cacheManager            = new FileCacheManager();

            IDataSource dataSource = new DataSourceDispatcher(stockDataDataSource, pricesDataSource, optionChainDataSource, financialDataSource, riskFreeRatesDataSource, assetTypeDataSource, statisticsDataSource, indexesDataSource, cacheManager);
            bool        ok         = dataSource.TryGetCompleteAssetData("AAPL", Common.Entities.Exchange.NASDAQ, AssetClass.Stock, true, true, out AssetBase asset, out string message);

            Assert.IsTrue(ok);
            string    json = JsonConvert.SerializeObject(asset);
            AssetBase a    = JsonConvert.DeserializeObject <AssetBase>(json);
        }