public DcfVM(DataGrid dataGrid, DcfDataDao dcfDataDao, DcfInput dcfInput, FinDataDao finDataDao, FinDataAdapter finDataAdapter) { _dataGrid = dataGrid; _rowMapping = Rowmapping.DcfRows(); _showForecastTable = new ObservableCollection<ForecastData>(); _columnHeader = new List<string>(); _dcfDataDao = dcfDataDao; _dcfInput = dcfInput; _finDataDao = finDataDao; _finDataAdapter = finDataAdapter; _finDataAdapter.DcfOutput.PropertyChanged += OutputChangedEventHandler; }
/// <summary> /// Kutsutav meetod, mis loeb etteantud faiinime järgi async finantsandmed kaasa antud objektides sisalduvatesse hoidjatesse. /// On olemas ka overloaded sama nimega teine meetod juba olemasoleva Xdoc objekti jaoks. /// </summary> /// <param name="fileName">XML faili nimi</param> /// <param name="dao">FinData DAO, kuhu andmed lisatakse</param> /// <param name="finDataAdapter">Kutsuv adapter, vajalik hilisemaks märguandeks, kui andmed loetud</param> public void GetData(string fileName, FinDataDao dao, FinDataAdapter finDataAdapter) { _finDataDao = dao; _finDataAdapter = finDataAdapter; try { //XDocument xdoc = XDocument.Load(fileName); //GetData(xdoc, dao); LoadXMLData(fileName); } catch (XmlException) { System.Windows.MessageBox.Show("Error reading XML"); } }
public YChartsScraper(FinDataAdapter finDataAdapter, string symbol) { _finDataAdapter = finDataAdapter; _symbol = symbol; _xmlScraper = new XmlScraper(finDataAdapter); }
/// <summary> /// Beta arvutus /// </summary> /// <param name="finDataAdapter">Adapter kõigi finantsandmete kättesaamise jaoks</param> /// <param name="dcfInput">DCF arvutuste eelduste hoidja</param> public static void CalculateBeta(FinDataAdapter finDataAdapter, DcfInput dcfInput) { BivariateSample bivariate = new BivariateSample(); MultivariateSample mv = new MultivariateSample(2); decimal prevPrice = 0; double? prevIndex = null; decimal curPrice = 0; double? curIndex = null; int k = 0; for (int i = 0; i < finDataAdapter.PriceDataDao.PriceDatas.Count; i = i + 22) { if (k < 36) { PriceData pd = finDataAdapter.PriceDataDao.PriceDatas[i]; curPrice = pd.AdjClose; curIndex = finDataAdapter.PriceDataDao.GetClosePrice(pd.PriceDate, finDataAdapter.PriceDataDao.IndexDatas)[0]; if (curPrice != 0 && curIndex != null && prevPrice != 0 && prevIndex != null) { //MessageBox.Show("s:" + ((double)(prevPrice / curPrice) - 1)); //MessageBox.Show("i:" + ((double)(prevIndex / curIndex) - 1)); ////bivariate.Add((double) (prevPrice/curPrice)-1,(double) (prevIndex/curIndex)-1); double[] db = new double[2]; db[0] = ((double)(prevPrice / curPrice) - 1); db[1] = ((double)(prevIndex / curIndex) - 1); mv.Add(db); } prevPrice = curPrice; prevIndex = curIndex; //DateTime dt = finDataAdapter.PriceDataDao.PriceDatas[i].PriceDate; //MessageBox.Show(finDataAdapter.PriceDataDao.PriceDatas[i].AdjClose + " " + // dt.ToShortDateString()); //MessageBox.Show(finDataAdapter.PriceDataDao.GetClosePrice(dt, finDataAdapter.PriceDataDao.IndexDatas)[0].ToString()); } k++; } if (mv.Count > 10) { //FitResult fitResult = bivariate.LinearRegression(); FitResult fitResult = mv.LinearRegression(0); dcfInput.Beta = fitResult.Parameter(1).Value; List<FinData> finDatas = finDataAdapter.FinDataDao.FinDatas; dcfInput.CostOfEquity = dcfInput.RiskFreeRate + dcfInput.Beta * dcfInput.MarketRiskPremium; double debt = 0; if (finDatas[finDatas.Count - 1].BsCurrentPortionOfLongTermDebt != null) { debt += (double)finDatas[finDatas.Count - 1].BsCurrentPortionOfLongTermDebt; } if (finDatas[finDatas.Count - 1].BsTotalLongTermDebt != null) { debt += (double)finDatas[finDatas.Count - 1].BsTotalLongTermDebt; } double total = 0.0; if (finDatas[finDatas.Count - 1].BsShareholdersEquity1 != null) { total += (double)(finDatas[finDatas.Count - 1].BsShareholdersEquity1); } total += debt; try { dcfInput.Wacc = dcfInput.CostOfEquity * (double)(finDatas[finDatas.Count - 1].BsShareholdersEquity1 / total) + dcfInput.CostOfDebt * (double)(debt / total) * (1 - dcfInput.TaxRate); } catch (InvalidOperationException) { } //MessageBox.Show("beta: "+fitResult.Parameter(1).Value.ToString()); //double[] pars = fitResult.Parameters(); //foreach (var par in pars) //{ // MessageBox.Show(par.ToString()); //} //MessageBox.Show(fitResult.CorrelationCoefficient(0,1).ToString()); //double[] gfit = fitResult. //MessageBox.Show(fitResult.); //MessageBox.Show(fitResult.Parameter(2).ToString()); } }
/// <summary> /// Meetod kõigi sisendite (ehk eelduste) välja arvutamiseks /// </summary> /// <param name="finDataAdapter">Adapter kõigi finantsandmete kättesaamise jaoks</param> /// <param name="dcfInput">DCF arvutuste eelduste hoidja</param> public static void CalculateInput(FinDataAdapter finDataAdapter, DcfInput dcfInput) { CalculateCorrelation(finDataAdapter, dcfInput); int requiredPeriodsForMean = 1; List<FinData> finDatas = finDataAdapter.FinDataDao.FinDatas; int k = 0; Sample sampleRevenue = new Sample(); Sample sampleTax = new Sample(); Sample sampleInterest = new Sample(); Sample sampleTotalAssets = new Sample(); Sample sampleTotalLiabilities = new Sample(); Sample sampleTotalCurrentAssets = new Sample(); Sample sampleTotalCurrentLiabilities = new Sample(); Sample sampleAllCosts = new Sample(); Sample sampleEbitda = new Sample(); Sample sampleDepreciation = new Sample(); Sample sampleEbit = new Sample(); for (int i = finDatas.Count - 1; i >= 4; i--) { if (k < 12) { if (k == 0) { try { dcfInput.SharesOutstanding = (double)finDatas[i].BsCommonSharesOutstanding; } catch (InvalidOperationException) { } } try { double RevenueGrowth = (double)(finDatas[i].IsRevenue / finDatas[i - 4].IsRevenue) - 1; sampleRevenue.Add(RevenueGrowth); } catch (InvalidOperationException) { } try { double taxRate = (double)((finDatas[i].IsPretaxIncome - finDatas[i].IsIncomeAfterTax) / finDatas[i].IsPretaxIncome); sampleTax.Add(taxRate); } catch (InvalidOperationException) { } double debt = 0; if (finDatas[i].BsCurrentPortionOfLongTermDebt != null) { debt += (double)finDatas[i].BsCurrentPortionOfLongTermDebt; } if (finDatas[i].BsTotalLongTermDebt != null) { debt += (double)finDatas[i].BsTotalLongTermDebt; } if (finDatas[i].FrInterestExpense != null && debt != 0.0) { double interest = (double)(finDatas[i].FrInterestExpense) / debt; if (interest < 0.2) { sampleInterest.Add(interest); } } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && finDatas[i].BsTotalAssets != null) { double temp = (double)(finDatas[i].BsTotalAssets / finDatas[i].IsRevenue); if (temp > 0.5 && temp < 50) { sampleTotalAssets.Add(temp); } } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && finDatas[i].BsTotalLiabilities != null) { double temp = (double)(finDatas[i].BsTotalLiabilities / finDatas[i].IsRevenue); if (temp > 0.5 && temp < 50) { sampleTotalLiabilities.Add(temp); } } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && finDatas[i].BsTotalCurrentAssets != null) { double temp = (double)(finDatas[i].BsTotalCurrentAssets / finDatas[i].IsRevenue); if (temp > 0.5 && temp < 50) { sampleTotalCurrentAssets.Add(temp); } } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && finDatas[i].BsTotalCurrentLiabilities != null) { double temp = (double)(finDatas[i].BsTotalCurrentLiabilities / finDatas[i].IsRevenue); if (temp > 0.5 && temp < 50) { sampleTotalCurrentLiabilities.Add(temp); } } double allCosts = 0.0; if (finDatas[i].IsTotalOperatingExpenses != null) { allCosts += (double)finDatas[i].IsTotalOperatingExpenses; } if (finDatas[i].IsDepreciationAmortization != null) { allCosts -= (double)finDatas[i].IsDepreciationAmortization; } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && allCosts != 0.0) { double temp = (double)(allCosts / finDatas[i].IsRevenue); if (temp > 0.1 && temp < 1) { sampleAllCosts.Add(temp); } } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && finDatas[i].FrEbitda != null) { double temp = (double)(finDatas[i].FrEbitda / finDatas[i].IsRevenue); if (temp > -1.0 && temp < 1.0) { sampleEbitda.Add(temp); } } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && finDatas[i].IsDepreciationAmortization != null) { double temp = (double)(finDatas[i].IsDepreciationAmortization / finDatas[i].IsRevenue); if (temp > -1.0 && temp < 1.0) { sampleDepreciation.Add(temp); } } if (finDatas[i].IsRevenue != null && finDatas[i].IsRevenue != 0.0 && finDatas[i].FrEbit != null) { double temp = (double)(finDatas[i].FrEbit / finDatas[i].IsRevenue); if (temp > -1.0 && temp < 1.0) { sampleEbit.Add(temp); } } } k++; } if (sampleRevenue.Count >= requiredPeriodsForMean) { dcfInput.GrowthRatePrognosis = sampleRevenue.Mean; } if (sampleTax.Count >= requiredPeriodsForMean) { dcfInput.TaxRate = sampleTax.Mean; } if (sampleInterest.Count >= requiredPeriodsForMean) { dcfInput.CostOfDebt = sampleInterest.Mean; } if (sampleTotalAssets.Count >= requiredPeriodsForMean) { dcfInput.TotalAssetsPrcRevenue = sampleTotalAssets.Mean; } if (sampleTotalLiabilities.Count >= requiredPeriodsForMean) { dcfInput.TotalLiabilitiesPrcRevenue = sampleTotalLiabilities.Mean; } if (sampleTotalCurrentAssets.Count >= requiredPeriodsForMean) { dcfInput.TotalCurrentAssetsPrcRevenue = sampleTotalCurrentAssets.Mean; } if (sampleTotalCurrentLiabilities.Count >= requiredPeriodsForMean) { dcfInput.TotalCurrentLiabilitiesPrcRevenue = sampleTotalCurrentLiabilities.Mean; } if (sampleAllCosts.Count >= requiredPeriodsForMean) { dcfInput.AllCostsPrcRevenue = sampleAllCosts.Mean; } if (sampleEbitda.Count >= requiredPeriodsForMean) { dcfInput.EbitdaPrcRevenue = sampleEbitda.Mean; } if (sampleDepreciation.Count >= requiredPeriodsForMean) { dcfInput.DepreciationPrcRevenue = sampleDepreciation.Mean; } if (sampleEbit.Count >= requiredPeriodsForMean) { dcfInput.EbitPrcRevenue = sampleEbit.Mean; } }
/// <summary> /// Korrelatsiooni arvutus valitud näitajate jaoks (Total Assets, Total Liabilities, Total Current Assets, Total Current Liabilities: vs Reveneue) /// </summary> /// <param name="finDataAdapter">Adapter kõigi finantsandmete kättesaamise jaoks</param> /// <param name="dcfInput">DCF arvutuste eelduste hoidja</param> public static void CalculateCorrelation(FinDataAdapter finDataAdapter, DcfInput dcfInput) { MultivariateSample mvTA = new MultivariateSample(2); MultivariateSample mvTL = new MultivariateSample(2); MultivariateSample mvCA = new MultivariateSample(2); MultivariateSample mvCL = new MultivariateSample(2); int k = 0; List<FinData> finDatas = finDataAdapter.FinDataDao.FinDatas; for (int i = finDataAdapter.FinDataDao.FinDatas.Count - 1; i >= 0; i--) { if (k < 20) { double revChange = 0; try { //revChange = (double) (finDatas[i].IsRevenue/finDatas[i - 5].IsRevenue); revChange = (double)finDatas[i].IsRevenue; } catch (InvalidOperationException) { } double caChange = 0; try { //secChange = (double)(finDatas[i].BsTotalCurrentAssets / finDatas[i - 5].BsTotalCurrentAssets); caChange = (double)finDatas[i].BsTotalCurrentAssets; } catch (InvalidOperationException) { } double clChange = 0; try { //secChange = (double)(finDatas[i].BsTotalCurrentAssets / finDatas[i - 5].BsTotalCurrentAssets); clChange = (double)finDatas[i].BsTotalCurrentLiabilities; } catch (InvalidOperationException) { } double taChange = 0; try { //secChange = (double)(finDatas[i].BsTotalCurrentAssets / finDatas[i - 5].BsTotalCurrentAssets); taChange = (double)finDatas[i].BsTotalAssets; } catch (InvalidOperationException) { } double tlChange = 0; try { //secChange = (double)(finDatas[i].BsTotalCurrentAssets / finDatas[i - 5].BsTotalCurrentAssets); tlChange = (double)finDatas[i].BsTotalLiabilities; } catch (InvalidOperationException) { } //MessageBox.Show("s:" + ((double)(prevPrice / curPrice) - 1)); //MessageBox.Show("i:" + ((double)(prevIndex / curIndex) - 1)); ////bivariate.Add((double) (prevPrice/curPrice)-1,(double) (prevIndex/curIndex)-1); double[] db = new double[2]; db[0] = caChange; db[1] = revChange; if (db[0] != 0 || db[1] != 0) mvCA.Add(db); db = new double[2]; db[0] = clChange; db[1] = revChange; if (db[0] != 0 || db[1] != 0) mvCL.Add(db); db = new double[2]; db[0] = taChange; db[1] = revChange; if (db[0] != 0 || db[1] != 0) mvTA.Add(db); db = new double[2]; db[0] = tlChange; db[1] = revChange; if (db[0] != 0 || db[1] != 0) mvTL.Add(db); //DateTime dt = finDataAdapter.PriceDataDao.PriceDatas[i].PriceDate; //MessageBox.Show(finDataAdapter.PriceDataDao.PriceDatas[i].AdjClose + " " + // dt.ToShortDateString()); //MessageBox.Show(finDataAdapter.PriceDataDao.GetClosePrice(dt, finDataAdapter.PriceDataDao.IndexDatas)[0].ToString()); } k++; } // peab vähemalt olema 3 vaatlust if (mvCA.Count > 2) { //FitResult fitResult = bivariate.LinearRegression(); FitResult fitResult = mvCA.LinearRegression(0); dcfInput.TotalCurrentAssetsBeta = fitResult.Parameter(1).Value; dcfInput.TotalCurrentAssetsAlpha = fitResult.Parameter(0).Value; fitResult = mvCL.LinearRegression(0); dcfInput.TotalCurrentLiabilitiesBeta = fitResult.Parameter(1).Value; dcfInput.TotalCurrentLiabilitiesAlpha = fitResult.Parameter(0).Value; fitResult = mvTA.LinearRegression(0); dcfInput.TotalAssetsBeta = fitResult.Parameter(1).Value; dcfInput.TotalAssetsAlpha = fitResult.Parameter(0).Value; fitResult = mvTL.LinearRegression(0); dcfInput.TotalLiabilitiesBeta = fitResult.Parameter(1).Value; dcfInput.TotalLiabilitiesAlpha = fitResult.Parameter(0).Value; //MessageBox.Show("alfa: " + fitResult.Parameter(0).Value.ToString()); //MessageBox.Show("beta: "+fitResult.Parameter(1).Value.ToString()); //double[] pars = fitResult.Parameters(); //foreach (var par in pars) //{ // MessageBox.Show(par.ToString()); //} //MessageBox.Show(fitResult.CorrelationCoefficient(0,1).ToString()); //double[] gfit = fitResult. //MessageBox.Show(fitResult.); //MessageBox.Show(fitResult.Parameter(2).ToString()); } }
/// <summary> /// Arvutab ettevõtte koguväärtuse /// </summary> /// <param name="finDataAdapter">Adapter annab ligipääsu kõigile kogutud andmetele.</param> public static void CalculateTerminal(FinDataAdapter finDataAdapter) { List<DcfData> dcfDatas = finDataAdapter.DcfDataDao.DcfDatas; DcfInput dcfInput = finDataAdapter.DcfInput; DcfOutput dcfOutput = finDataAdapter.DcfOutput; List<FinData> finDatas = finDataAdapter.FinDataDao.FinDatas; // algselt väärtus double presentValueOfFcff = 0.0; // jätkuväärtus double terminalFCFF = 0.0; int j = 1; int finalDiscountFactor = 1; // käime läbi DCFData tuleviku objektid ja diskonteerime sealt FCFF väärtused tänapäeva for (int i = 0; i < dcfDatas.Count; i++) { if (dcfDatas[i].IsPrognosis) { finalDiscountFactor = i; try { presentValueOfFcff += (double)dcfDatas[i].Fcff / Math.Pow(1 + dcfInput.Wacc / 4, j); if (i > dcfDatas.Count - 4) { terminalFCFF += (double)dcfDatas[i].Fcff; } } catch (InvalidOperationException) { } j++; } } dcfOutput.PerpetuityGrowthRate = dcfInput.ContinuousGrowth; dcfOutput.Wacc = dcfInput.Wacc; dcfOutput.TerminalFreeCashFlow = terminalFCFF; // arvutame jätkuväärtuse dcfOutput.TerminalValue = dcfOutput.TerminalFreeCashFlow * dcfInput.ContinuousGrowth / (dcfInput.Wacc - dcfInput.ContinuousGrowth); // edasi toimuvad leitud väärtuste korrigeerimised võla, sularaha jms-ga dcfOutput.PresentValueOfFreeCashFlow = presentValueOfFcff; dcfOutput.PresentValueOfTerminalValue = dcfOutput.TerminalValue / Math.Pow(1 + dcfInput.Wacc, finalDiscountFactor / 4); dcfOutput.EnterpriseValueWithoutCash = dcfOutput.PresentValueOfTerminalValue + dcfOutput.PresentValueOfFreeCashFlow; dcfOutput.CashAndCashEquivalents = finDatas[finDatas.Count - 1].BsCashShortTermInvestments; dcfOutput.EnterpriseValue = dcfOutput.EnterpriseValueWithoutCash + dcfOutput.CashAndCashEquivalents; dcfOutput.LessTotalDebt = 0; if (finDatas[finDatas.Count - 1].BsCurrentPortionOfLongTermDebt != null) { dcfOutput.LessTotalDebt += finDatas[finDatas.Count - 1].BsCurrentPortionOfLongTermDebt; } if (finDatas[finDatas.Count - 1].BsTotalLongTermDebt != null) { dcfOutput.LessTotalDebt += finDatas[finDatas.Count - 1].BsTotalLongTermDebt; } dcfOutput.EquityValue = dcfOutput.EnterpriseValue - dcfOutput.LessTotalDebt; dcfOutput.OutstandingShares = dcfInput.SharesOutstanding; dcfOutput.CurrentSharePrice = finDatas[finDatas.Count - 1].FrPrice; dcfOutput.ModelSharePrice = dcfOutput.EquityValue / dcfOutput.OutstandingShares; // võrdleme mudelit leitud hinda reaalse turuhinnaga ja anname vastavalt sellele ostu/müügi soovituse double? priceDifference = dcfOutput.ModelSharePrice / dcfOutput.CurrentSharePrice - 1; if (priceDifference == null) { dcfOutput.Recommendation = DcfOutput.Recommendations.No_Data_To_Recommend; } else if (priceDifference > 0.4) { dcfOutput.Recommendation = DcfOutput.Recommendations.Strong_Buy; } else if (priceDifference > 0.2) { dcfOutput.Recommendation = DcfOutput.Recommendations.Buy; } else if (priceDifference < -0.4) { dcfOutput.Recommendation = DcfOutput.Recommendations.Strong_Sell; } else if (priceDifference < -0.2) { dcfOutput.Recommendation = DcfOutput.Recommendations.Sell; } else { dcfOutput.Recommendation = DcfOutput.Recommendations.Hold; } }
public YahooFScraper(FinDataAdapter finDataAdapter) { _finDataAdapter = finDataAdapter; }
private void btnRetrieveYCharts_Click(object sender, RoutedEventArgs e) { if (comboDataSource.SelectedIndex == 0) { labelProgrammiStaatus.Content = "Retrieving data from YCharts.com ..."; btnCalculateForecast.IsEnabled = false; string symbol = txtBoxAndmeteAllikas.Text; if (string.IsNullOrEmpty(symbol) || symbol.Equals("input company ticker here") || symbol.Contains(".")) { MessageBox.Show("Illegal symbol or no symbol specified."); return; } _inputVm.LaeAndmed(symbol); if (!PasswordSet) { string[] promptValue = Prompt.ShowDialog("Enter YCharts.com Username"); string user = promptValue[0]; string psw = promptValue[1]; _user = user; _password = psw; } if (!string.IsNullOrEmpty(_user) && !string.IsNullOrEmpty(_password)) { if (panelForecast.DataContext != null) { _dcfVM.ClearTable(); } panelForecast.DataContext = null; panelDcfOutput.DataContext = null; FinAnalysisVM finAnalysisVm = new FinAnalysisVM(dataGrid); _finDataAdapter = new FinDataAdapter(finAnalysisVm, symbol, FinDataAdapter.DataSource.XLS); _finDataAdapter.AddDcfInput(_dci); _finDataAdapter.PrepareDataXLS(_user, _password, this); panelQuarterlyData.DataContext = finAnalysisVm; // need peaks seatud saama alles siis, kui andmed saabuvad YCharts.com-st //labelProgrammiStaatus.Content = "Data retrieved from YCharts.com."; //btnCalculateForecast.IsEnabled = true; } else { PasswordSet = false; MessageBox.Show("Enter username and password, fields cannot be empty."); } } else if (comboDataSource.SelectedIndex == 2) { btnLaeAndmed.IsEnabled = false; string programStatus = labelProgrammiStaatus.Content.ToString(); labelProgrammiStaatus.Content = "Loading data from Google Finance."; GoogleFinanceScraper gfs = new GoogleFinanceScraper(); var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); //get UI thread context string txtBoxAndmeteAllikasText = txtBoxAndmeteAllikas.Text; var task1 = Task.Factory.StartNew(() => gfs.GetData(txtBoxAndmeteAllikasText)); task1.ContinueWith(task => { if (gfs.DownloadedData == null) { MessageBox.Show("Failed to download data for this ticker (" + txtBoxAndmeteAllikasText + ")."); labelProgrammiStaatus.Content = programStatus; } else { if (panelForecast.DataContext != null) { _dcfVM.ClearTable(); } panelDcfOutput.DataContext = null; labelProgrammiStaatus.Content = "Data loaded from Google Finance."; FinAnalysisVM finAnalysisVm = new FinAnalysisVM(dataGrid); _finDataAdapter = new FinDataAdapter(_inputVm, finAnalysisVm, "", FinDataAdapter.DataSource.XML, gfs.XmlPath); // testimiseks: _finDataAdapter.AddMainWindow(this); _finDataAdapter.AddDcfInput(_dci); _finDataAdapter.PrepareData(); panelQuarterlyData.DataContext = finAnalysisVm; } btnLaeAndmed.IsEnabled = true; }, uiScheduler); } }
private void btnAvaXMLFail_Click(object sender, RoutedEventArgs e) { //_inputVm.LaeAndmed("csco"); labelProgrammiStaatus.Content = "Loading XML data ..."; btnCalculateForecast.IsEnabled = false; System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (panelForecast.DataContext != null) { _dcfVM.ClearTable(); } panelDcfOutput.DataContext = null; txtBoxAndmeteAllikas.IsEnabled = true; txtBoxAndmeteAllikas.Text = dialog.FileName; //txtBoxAndmeteAllikas.Foreground = Brushes.Black; //txtBoxAndmeteAllikas.CaretIndex = txtBoxAndmeteAllikas.Text.Length; //labelProgrammiStaatus.Content = "Data loaded from XML file (" + dialog.SafeFileName + ")."; //var rect = txtBoxAndmeteAllikas.GetRectFromCharacterIndex(txtBoxAndmeteAllikas.CaretIndex); //txtBoxAndmeteAllikas.ScrollToHorizontalOffset(rect.Right); FinAnalysisVM finAnalysisVm = new FinAnalysisVM(dataGrid); _finDataAdapter = new FinDataAdapter(_inputVm, finAnalysisVm, "", FinDataAdapter.DataSource.XML, dialog.FileName); // testimiseks: _finDataAdapter.AddMainWindow(this); _finDataAdapter.AddDcfInput(_dci); _finDataAdapter.PrepareData(); panelQuarterlyData.DataContext = finAnalysisVm; //btnCalculateForecast.IsEnabled = true; } }
public XmlScraper(FinDataAdapter finDataAdapter) { _finDataAdapter = finDataAdapter; }