コード例 #1
0
        public async Task <ActionResult> MarketStatus()
        {
            var status = await _investagramsApi.GetMarketStatus(DateTime.Now);

            var viewModel = new MarketStatusViewModel
            {
                TopGainer  = status.TopGainer.Select(x => MapMarketStatusTopGainers(x, status.MostActive)).ToArray(),
                TopLoser   = status.TopLoser.Select(x => MapMarketStatusTopGainers(x, status.MostActive)).ToArray(),
                MostActive = status.MostActive.Select(x => MapMarketStatusMostActive(x, status)).ToArray()
            };

            return(View(viewModel));
        }
コード例 #2
0
        public void SaveLatestStockUpdate()
        {
            var stocks        = new List <ScreenerResponse>();
            var realTimePrice = new List <RealTimePrice>();

            var events = new List <Event>();

            ClearCache();

            //Save stocks
            var tasks = new List <Task>
            {
                Task.Run(async() => await _investagramsApiService.GetAllLatestStocks()).ContinueWith(x =>
                {
                    stocks.AddRange(x.Result);
                    AddEvents(x.Result.OrderByDescending(e => e.Volume).Take(10), events, EventTypes.HighestVolume);
                }),
                Task.Run(async() => await _investagramsApiService.GetAllActiveStockPriceRealTime()).ContinueWith(x =>
                {
                    realTimePrice.AddRange(x.Result);
                    AddEvents(x.Result.OrderByDescending(e => e.Trades).Take(10), events, EventTypes.HighestTrade);
                }),

                //adding events
                Task.Run(async() => await _investagramsApiService.GetMarketStatus(DateTime.Now)).ContinueWith(x =>
                {
                    AddEvents(x.Result.MostActive, events, EventTypes.MostActive);
                    AddEvents(x.Result.TopGainer, events, EventTypes.TopWinner);
                    AddEvents(x.Result.TopLoser, events, EventTypes.TopLoser);
                }),

                Task.Run(async() => await _investagramsApiService.Get52WeekLow()).ContinueWith(x => AddEvents(x.Result, events, EventTypes._52WeekLow)),
                Task.Run(async() => await _investagramsApiService.GetOversoldStocks()).ContinueWith(x => AddEvents(x.Result, events, EventTypes.Oversold)),
                Task.Run(async() => await _investagramsApiService.GetTrendingStocks()).ContinueWith(x => AddEvents(x.Result, events, EventTypes.Trending)),
                Task.Run(async() => await _investagramsApiService.GreenVolume()).ContinueWith(x => AddEvents(x.Result, events, EventTypes.GreenVolume)),
            };

            Task.WaitAll(tasks.ToArray());

            if (stocks == null)
            {
                throw new System.Exception("Please update investa cookie");
            }

            SaveStocks(stocks, realTimePrice);
            SaveEvents(events);
        }
コード例 #3
0
        /// <summary>
        /// If stock is top gainer and most active then get the perfect score, otherwise get half if either of the two is true
        /// </summary>
        /// <param name="stockCode"></param>
        /// <returns></returns>
        public async Task <StockScore> GetMostActiveAndGainerScore(string stockCode)
        {
            var score        = new StockScore();
            var perfectScore = _settingRepository.GetSettingValue <decimal>(SettingNames.Score_MostActiveAndTopGainer);

            var marketStatus = await _investagramsApiService.GetMarketStatus(DateTime.Now);

            var isInMostActive = marketStatus.MostActive.Any(x => x.StockCode == stockCode);
            var isInTopGainer  = marketStatus.TopGainer.Any(x => x.StockCode == stockCode);

            if (isInMostActive)
            {
                score.AddReason(perfectScore / 2, "Is in most active");
            }

            if (isInTopGainer)
            {
                score.AddReason(perfectScore / 2, "Is in top gainer");
            }

            return(score);
        }