private void btnPriceFree_Click(object sender, RoutedEventArgs e) { if (Settings.AllowFreeMeals) { PriceMode = PriceMode.Free; RefreshUI(); } resetStudentTextField(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (!Settings.IsConfigFileValid()) { CriticalError("Config file not found or not complete.", "Invalid configuration file"); } else { lblStatus.Content = "Customizing UI from configuration file"; if (!Settings.AllowFreeMeals) { txtPriceFree.Visibility = Visibility.Hidden; btnPriceFree.Visibility = Visibility.Hidden; } if (!Settings.AllowReducedMeals) { txtPriceReduced.Visibility = Visibility.Hidden; btnPriceReduced.Visibility = Visibility.Hidden; } if (!Settings.AllowFreeMeals && !Settings.AllowReducedMeals) { txtPriceFull.Visibility = Visibility.Hidden; btnPriceFull.Visibility = Visibility.Hidden; PriceMode = PriceMode.FullPrice; } ClearLastStudentInfo(); lblStatus.Content = "Loading from " + Settings.ServerURL; lblStatus.Content = "Loading meal types from " + Settings.ServerURL; LoadMealTypes(); lblStatus.Content = "Loading students from " + Settings.ServerURL; LoadStudents(); lblStatus.Content = "Waiting for students to be returned"; // Set up a timer that will help set focus to the student number input when the students have been loaded txtStudentNumberEntry.Focus(); timer.Interval = 100; timer.Elapsed += TimerOnElapsed; timer.Start(); listMealLog.DataContext = mealLog; UILoaded = true; resetStudentTextField(); RefreshUI(); lblStatus.Content = "Ready to start scanning student barcodes"; } }
public SubControlPOSItemPanel(PriceMode paPriceMode, bool paStockOnlyMode) { clPriceMode = paPriceMode; clItemList = null; clStockOnlyMode = paStockOnlyMode; clLanguageManager = ApplicationFrame.GetInstance().ActiveSubscription.ActiveLanguage; clSettingManager = ApplicationFrame.GetInstance().ActiveSubscription.ActiveSetting; clItemCodeMode = General.ParseBoolean(clSettingManager.SystemConfig.GetData(ctKEYItemCodeMode), false); clTransactionSetting = General.JSONDeserialize <Dictionary <String, String> >(clSettingManager.GetSettingValue(ctSETTransactionSetting)); }
public decimal GetMarketPrice(PriceMode priceMode) { return(priceMode switch { PriceMode.Avg => Average, PriceMode.Open => Open, PriceMode.Close => Close, PriceMode.High => High, PriceMode.Low => Low, _ => throw new ArgumentException($"Arg not handled: {priceMode}", nameof(priceMode)), });
private IEnumerable <Product> GetCheapestExpensiveProductsChain(string id, PriceMode mode) { var chain = RepositoryEngine.GetChainById(id); if (mode == PriceMode.Cheap) { return(_cheapestAndExpentivestProductsByChains[chain].Item1); } if (mode == PriceMode.Expensive) { return(_cheapestAndExpentivestProductsByChains[chain].Item2); } return(new List <Product>()); }
protected int LOWEST(int ToIndex, int p, PriceMode PM) { int ci = 0; double Price = double.MaxValue; for (int i = ToIndex - p; i <= ToIndex; i++) { if (getprice(Bars[i], PM) < Price) { ci = i; Price = getprice(Bars[i], PM); } } return(ci); }
protected double getprice(Bar bar, PriceMode PM) { int xPM = (int)PM; switch (xPM) { case (int)PriceMode.Close: return(bar.Close); case (int)PriceMode.High: return(bar.High); case (int)PriceMode.Low: return(bar.Low); case (int)PriceMode.Open: return(bar.Open); case (int)PriceMode.Median: return((bar.High + bar.Low) * 0.5); case (int)PriceMode.Typical: return((bar.High + bar.Low + bar.Close) / 3.0); case (int)PriceMode.Weighted: return((bar.High + bar.Low + bar.Close + bar.Close) * 0.25); default: return(bar.Close); } //return 0.0; }
public async IAsyncEnumerable <IStakingPower> ListStakePowersAsync(Symbol stakeSymbol, PriceMode priceMode, DateTime from, DateTime to, CurrencyCode currencyCode) { var stakeInfo = GetStakeInfo(stakeSymbol); var start = from < stakeInfo.InceptionDate ? stakeInfo.InceptionDate : from; if (to <= stakeInfo.InceptionDate) { yield break; } if (priceMode == PriceMode.Raw) { await foreach (var stakePower in stakingPowerRepository .ListStakingPowersAsync(stakeInfo.ContractAddress, start, to) .WithCancellation(CancellationToken)) { yield return(MapStakingPower(stakeInfo, stakePower, currencyCode)); } yield break; } var stakePowers = await stakingPowerRepository .ListStakingPowersAsync(stakeInfo.ContractAddress, start, to) .ToListAsync(CancellationToken); foreach (var stakePowerGroup in stakePowers.GroupBy(p => p.Date.Date).OrderBy(x => x.Key)) { var mapped = stakePowerGroup .Select(sp => MapStakingPower(stakeInfo, sp, currencyCode)) .ToList(); yield return(new BusinessStakingPower() { Symbol = stakeInfo.Symbol, Date = stakePowerGroup.Key, Power = CurrencyConverter.Convert(Aggregate(stakePowerGroup, x => x.Power, priceMode) ?? decimal.Zero, currencyCode), Summary = mapped.Last().Summary .Select(fs => { var fund = GetFunds().Single(x => x.Symbol == fs.Symbol); return new BusinessStakingPowerSummary() { Symbol = fund.Symbol, Power = CurrencyConverter.Convert( Aggregate( stakePowerGroup, x => x.Summary .SingleOrDefault(y => y.ContractAddress.Equals(fund.ContractAddress.Address, StringComparison.OrdinalIgnoreCase)) ?.Power ?? decimal.Zero, priceMode), currencyCode) ?? decimal.Zero }; }) .ToList() ?? new List <BusinessStakingPowerSummary>() }); } }
public IAsyncEnumerable <ApiPerformance> ListFundPerformanceAsync(Symbol symbol, PriceMode mode, DateTime fromDate, DateTime toDate) { return(ListAsync <ApiPerformance>(string.Format( "/api/v1/funds/{0}/performance?{1}={2}&{3}={4}&{5}={6}", symbol, ApiFilterNames.FromQueryName, fromDate.ToString(Format.DateFormat), ApiFilterNames.ToQueryName, toDate.ToString(Format.DateFormat), ApiFilterNames.ModeQueryName, mode))); }
public async IAsyncEnumerable <IPerformance> ListPerformanceAsync(Symbol symbol, PriceMode priceMode, DateTime from, DateTime to, CurrencyCode currencyCode) { var contractAddress = symbol.IsFund() ? GetFundInfo(symbol).ContractAddress : GetStakeInfo(symbol).ContractAddress; var inceptionDate = symbol.IsFund() ? GetFundInfo(symbol).InceptionDate : GetStakeInfo(symbol).InceptionDate; var start = from < inceptionDate ? inceptionDate : from; if (to <= inceptionDate) { yield break; } if (priceMode == PriceMode.Raw) { await foreach (var perf in fundPerformanceRepository .ListPerformancesAsync(symbol, start, to) .WithCancellation(CancellationToken)) { yield return(new BusinessPerformance() { Date = perf.Date, NetAssetValuePerToken = CurrencyConverter.Convert(perf.Nav, currencyCode), MarketCap = CurrencyConverter.Convert( perf.MarketCap != -1 ? perf.MarketCap : default(decimal?), currencyCode), MarketAssetValuePerToken = CurrencyConverter.Convert( perf.Price != -1 ? perf.Price : default(decimal?), currencyCode), Volume = CurrencyConverter.Convert( perf.Volume != -1 ? perf.Volume : default(decimal?), currencyCode), }); } yield break; } var perfs = await fundPerformanceRepository .ListPerformancesAsync(symbol, start, to) .ToListAsync(CancellationToken); foreach (var perfGroup in perfs.GroupBy(p => p.Date.Date).OrderBy(x => x.Key)) { yield return(new BusinessPerformance() { Date = perfGroup.Key, NetAssetValuePerToken = CurrencyConverter.Convert(Aggregate(perfGroup, x => x.Nav, priceMode).Value, currencyCode), MarketCap = CurrencyConverter.Convert(Aggregate(perfGroup, x => x.MarketCap, priceMode), currencyCode), MarketAssetValuePerToken = CurrencyConverter.Convert(Aggregate(perfGroup, x => x.Price, priceMode), currencyCode), Volume = CurrencyConverter.Convert(Aggregate(perfGroup, x => x.Volume, priceMode), currencyCode), }); } }
private void btnPriceReduced_Click(object sender, RoutedEventArgs e) { PriceMode = PriceMode.ReducedPrice; RefreshUI(); resetStudentTextField(); }