コード例 #1
0
        public override bool getNumericValue(string stockID, out double val)
        {
            StockFinanceData fd = StockDataCenter.getInstance().getFinanceData(stockID);
            StockMarketData  md = StockDataCenter.getInstance().getMarketData(stockID);

            val = 0.0;
            if (fd == null || md == null)
            {
                return(false);
            }

            double epsTTM      = fd.eps4Quarter;
            double epsLastYear = fd.epsLastYear;

            if (epsTTM < 0.0)
            {
                return(false);
            }

            if (epsLastYear < 0.0 && epsTTM > double.Epsilon)
            {
                return(true);
            }

            val = (epsTTM - epsLastYear) / md.latestPrice;

            return(false);
        }
コード例 #2
0
        public void Setup()
        {
            var mockHttp = new MockHttpMessageHandler();
            var client   = mockHttp.ToHttpClient();

            var stockMarketAPI  = new StockMarketAPI(client);
            var stockMarketData = new StockMarketData(stockMarketAPI);

            TestHelpers.MockStockData(mockHttp);
            TestHelpers.MockFondData(mockHttp);
            TestHelpers.MockBondData(mockHttp);

            TestHelpers.MockDividendData(mockHttp);
            TestHelpers.MockCouponsData(mockHttp);

            var context = TestHelpers.GetMockFinanceDbContext();

            TestHelpers.SeedOperations1(context);

            _financeDataService = new FinanceDataService(context);
            var assetFactory   = new AssetsFactory(_financeDataService, stockMarketData);
            var balanceService = new BalanceService(_financeDataService);

            _marketService    = new MarketService(_financeDataService, assetFactory, balanceService);
            _portfolioService = new PortfolioService(_financeDataService, balanceService, assetFactory);
        }
コード例 #3
0
        private async void btnCPUBoundOperations_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(_data))
            {
                StockMarketData stockMarketData = new StockMarketData();
                _data = await stockMarketData.GetDataAsync();
            }

            StockMarketDataAnalysis stockMarketDataAnalysis = new StockMarketDataAnalysis(_data);

            // string result = await Task.Run(() => stockMarketDataAnalysis.CalculateStockastics());

            // AddListItem(result);

            List <Task <string> > tasks = new List <Task <string> >();

            tasks.Add(Task.Run(() => stockMarketDataAnalysis.CalculateFastMovingAverage()));
            tasks.Add(Task.Run(() => stockMarketDataAnalysis.CalculateSlowMovingAverage()));
            tasks.Add(Task.Run(() => stockMarketDataAnalysis.CalculateStockastics()));
            tasks.Add(Task.Run(() => stockMarketDataAnalysis.CalculateBollingerbands()));

            // Task.WaitAll(tasks.ToArray());
            await Task.WhenAll(tasks.ToArray());

            //await Task.WhenAll(tasks.ToArray()).ConfigureAwait(false);

            AddListItem(tasks[0].Result);
            AddListItem(tasks[1].Result);
            AddListItem(tasks[2].Result);
            AddListItem(tasks[3].Result);

            DisplayIndicatorsOnChart(tasks[0].Result, tasks[1].Result, tasks[2].Result, tasks[3].Result);
            // SaveIndicatorDataToFile(tasks[0].Result, tasks[1].Result, tasks[2].Result, tasks[3].Result);
        }
コード例 #4
0
        public KLineAnalyzer(List <StockKLine> data, StockMarketData md)
        {
            m_kLineData     = data;
            m_curMarketData = md;

            init();
        }
コード例 #5
0
        public void Setup()
        {
            _mockHttp = new MockHttpMessageHandler();
            var client         = _mockHttp.ToHttpClient();
            var stockMarketAPI = new StockMarketAPI(client);

            MockData();
            var stockMarketData = new StockMarketData(stockMarketAPI);

            _graphService = new GraphService(stockMarketData);
        }
コード例 #6
0
        public void Setup()
        {
            var mockHttp = new MockHttpMessageHandler();
            var client   = mockHttp.ToHttpClient();

            var stockMarketAPI  = new StockMarketAPI(client);
            var stockMarketData = new StockMarketData(stockMarketAPI);

            TestHelpers.MockStockData(mockHttp);

            _data = stockMarketData.GetStockData("YNDX").Result;
        }
コード例 #7
0
        public override bool filterMethod(string stockID)
        {
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            if (md != null &&
                PriceAnalyzer.isPriceScaleSatisfied(stockID, md.latestPrice, m_ratio))
            {
                return(true);
            }

            return(false);
        }
コード例 #8
0
ファイル: PEFilter.cs プロジェクト: promzzz/StockAnalyzer
        public override bool getNumericValue(string stockID, out double val)
        {
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            val = 0.0;
            if (md != null)
            {
                val = md.PE;
                return(true);
            }

            return(false);
        }
コード例 #9
0
        public static double calcCurCostRefValue(string stockID, string year, string season)
        {
            double          costRefVal = 0.0;
            StockReportData rd         = StockDBVisitor.getInstance().getStockReportData(stockID, year, season);

            StockMarketData md      = StockDataCenter.getInstance().getMarketData(stockID);
            int             quarter = int.Parse(season);

            if (rd != null && md != null)
            {
                costRefVal = (rd.eps / md.latestPrice) / quarter * 4;
            }

            return(costRefVal);
        }
コード例 #10
0
        public static bool calcDynamicPE(string stockID, out double val)
        {
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            string          year    = GlobalConfig.getInstance().curYear;
            string          quarter = GlobalConfig.getInstance().curQuarter;
            StockReportData rd      = StockDBVisitor.getInstance().getStockReportData(stockID, year, quarter);

            val = 0.0;
            if (md != null && rd != null)
            {
                double profitVal = getEstimateProfitValue(rd.net_profits, quarter);
                val = md.totalCapitalisation * 10000.0 / profitVal;
                return(true);
            }

            return(false);
        }
コード例 #11
0
        public void Setup()
        {
            var mockHttp = new MockHttpMessageHandler();
            var client   = mockHttp.ToHttpClient();

            var stockMarketAPI  = new StockMarketAPI(client);
            var stockMarketData = new StockMarketData(stockMarketAPI);

            TestHelpers.MockStockData(mockHttp);
            TestHelpers.MockFondData(mockHttp);
            TestHelpers.MockDividendData(mockHttp);

            var context = TestHelpers.GetMockFinanceDbContext();

            TestHelpers.SeedOperations1(context);
            var financeDataService = new FinanceDataService(context);

            _assetFactory = new AssetsFactory(financeDataService, stockMarketData);
        }
コード例 #12
0
        public static bool getPriceScaleFromDate(string stockID, string beginDate, out double ratio)
        {
            ratio = 0.0;
            StockMarketData md = StockDataCenter.getInstance().getMarketData(stockID);

            if (md == null)
            {
                return(false);
            }

            double curPrice            = md.latestPrice;
            List <StockKLineBaidu> arr = StockDataCenter.getInstance().getKLineBaidu(stockID);

            if (arr == null || arr.Count == 0)
            {
                return(false);
            }

            ratio = getPriceScale(arr, curPrice, beginDate);
            return(true);
        }
コード例 #13
0
        public void Setup()
        {
            _mockHttp = new MockHttpMessageHandler();
            var client         = _mockHttp.ToHttpClient();
            var stockMarketAPI = new StockMarketAPI(client);

            MockData();
            var stockMarketData = new StockMarketData(stockMarketAPI);

            var context = TestHelpers.GetMockFinanceDbContext();

            TestHelpers.SeedOperations1(context);
            var financeDataService = new FinanceDataService(context);

            TestHelpers.MockStockData(_mockHttp);
            TestHelpers.MockFondData(_mockHttp);
            TestHelpers.MockBondData(_mockHttp);

            TestHelpers.MockDividendData(_mockHttp);
            TestHelpers.MockCouponsData(_mockHttp);

            _searchService = new SearchService(stockMarketData, financeDataService);
        }
コード例 #14
0
        public async Task Setup()
        {
            var mockHttp = new MockHttpMessageHandler();
            var client   = mockHttp.ToHttpClient();

            var stockMarketApi  = new StockMarketAPI(client);
            var stockMarketData = new StockMarketData(stockMarketApi);

            var context = TestHelpers.GetMockFinanceDbContext();

            _financeDataService = new FinanceDataService(context);

            var assetFactory = new AssetsFactory(_financeDataService, stockMarketData);

            _balanceService = new BalanceService(_financeDataService);
            TestHelpers.SeedApp(context);
            _portfolioService = new PortfolioService(_financeDataService, _balanceService, assetFactory);

            TestHelpers.MockStockData(mockHttp);
            TestHelpers.MockFondData(mockHttp);
            TestHelpers.MockBondData(mockHttp);

            TestHelpers.SeedOperations2(context);
        }