Task ISamsungStockNotifier.NotifyAsync(StockPriceModel stockPriceModel) { return(Task.Run(() => { OnNotify?.Invoke(this, (listObserver) => { listObserver.ForEach((observer) => observer.GetUpdatePrice(stockPriceModel)); }); })); }
async Task ISamsungStockTrigger.ChangePriceAsync(StockPriceModel stockPriceModel) { //this.samsungStockNotifier.OnNotify += SamsungStockNotifier_OnNotify; EventHandler <Action <List <IObserver> > > @event = (sender, notifyToInvestors) => notifyToInvestors.Invoke(this.listInvestors); // Subscribe event this.samsungStockNotifier.OnNotify += @event; await this.samsungStockNotifier.NotifyAsync(stockPriceModel); // UnSubscribe event this.samsungStockNotifier.OnNotify -= @event; }
public async Task <ActionResult> GetData(string searchString, string start, string end) { var user_id = User.Identity.GetUserId(); ViewBag.searchString = searchString; ViewBag.Id = user_id; StockPriceModel models = new StockPriceModel(); if (!String.IsNullOrEmpty(searchString)) { models = await GetStockQuote(searchString); } return(View("Stocks", models)); }
public async Task <StockPriceModel> GetStockQuote(string ticker) { var securities = await Yahoo.Symbols(ticker).Fields("Name", "Price", "weekHigh", "weekLow", "Change", "ChangePercent").Fields(Field.LongName, Field.RegularMarketPrice, Field.FiftyTwoWeekHigh, Field.FiftyTwoWeekLow, Field.RegularMarketChange, Field.RegularMarketChangePercent).QueryAsync(); var security = securities[ticker.ToUpper()]; security.Fields.TryGetValue(ticker, out dynamic key); StockPriceModel models = new StockPriceModel() { Ticker = ticker, Name = security.LongName, Change = security.RegularMarketChange, ChangePercent = security.RegularMarketChangePercent, weekHigh = security.FiftyTwoWeekHigh, weekLow = security.FiftyTwoWeekLow }; return(models); }
internal void ResetVM() { IsStockCodeEnabled = true; StockCode = string.Empty; SelectedPriceIndex = StockPriceModel?.SpecialPriceTypes?.Count > 0 ? 0 : -1; PriceUnits = new List <string> { "$", "%" }; SelectedPriceUnitIndex = 0; IsEditButtonEnabled = IsEditButtonPressed = ShowOnlyPrices = ShowPriceChange = false; ShowPriceCheck = true; _defaultSelectedSpecialPrice = string.Empty; ControlDatesVisibility(false); ControlQuantityAndPriceVisibility(false); ControlPriceVisibility(false); ControlFromToPriceVisibility(false); StockPriceModel = new StockPriceModel(); ChangeGridColumnHeaderValue(); PriceTypeList = new ObservableCollection <PriceTypeModel>(); ShowEditButton = false; ShowSaveButton = false; }
public StockPriceReaderModel ParsePrices(string file) { var stockPriceReaderModel = new StockPriceReaderModel(); List <string> row = new List <string>(); List <StockPriceModel> s = new List <StockPriceModel>(); stockPriceReaderModel.name = "Stock: " + System.IO.Path.GetFileNameWithoutExtension(file); using (var reader = new CsvFileReader(file)) { while (reader.ReadRow(row)) { //Ignore premarket and aftermarket trading eg. before 0930AM and after 0400PM int time = int.Parse(row[1]); if (time >= 930 && time <= 1600) { float open = float.Parse(row[2]); float high = float.Parse(row[3]); float low = float.Parse(row[4]); float close = float.Parse(row[5]); float volume = float.Parse(row[6]); var stockPriceModel = new StockPriceModel(open, close, high, low, volume); stockPriceReaderModel.prices.Add(stockPriceModel); } } } RSI.Calculate(stockPriceReaderModel.prices); SMA.Calculate(stockPriceReaderModel.prices); //identify and name patterns MyStrategy.Apply(stockPriceReaderModel.prices); return(stockPriceReaderModel); }
Task IObserver.GetUpdatePrice(StockPriceModel stockPriceModel) { Console.WriteLine($"Investor B :{stockPriceModel.Price}"); return(Task.CompletedTask); }