public void AddToPortfolio(object sender, RoutedEventArgs e) { OptionData tradedOption = (OptionData)optionDataGrid.SelectedItem; var newWindow = new AddToPortfolio(tradedOption, portfolioList); newWindow.Show(); }
public AddToPortfolio(OptionData tradedOption, BindingList <PortfolioData> pList) { portfolioList = pList; addOption = new PortfolioData(); addOption.Delta = -0.1; addOption.Instrument = tradedOption.Type + " option"; addOption.Value = tradedOption.Price; InitializeComponent(); typeLabel.Content = tradedOption.Type; priceLabel.Content = tradedOption.Price.ToString(); dateLabel.Content = tradedOption.Maturity.ToShortDateString(); volLabel.Content = "0.20"; delLabel.Content = "-0.1"; }
private void CreateOption(object sender, RoutedEventArgs e) { var newOption = new OptionData(); bool correctOption = true; typeWarningLabel.Visibility = Visibility.Hidden; priceWarningLabel.Visibility = Visibility.Hidden; dateWarningLabel.Visibility = Visibility.Hidden; if ((bool)PutButton.IsChecked) { newOption.Type = "Put"; } else if ((bool)CallButton.IsChecked) { newOption.Type = "Call"; } else { correctOption = false; typeWarningLabel.Visibility = Visibility.Visible; typeWarningLabel.Content = "Please select the type"; } if (String.IsNullOrEmpty(Price.Text)) { correctOption = false; priceWarningLabel.Visibility = Visibility.Visible; priceWarningLabel.Content = "Please enter the price"; } else { try { newOption.Price = Convert.ToDouble(Price.Text); } catch (FormatException) { correctOption = false; priceWarningLabel.Visibility = Visibility.Visible; priceWarningLabel.Content = "Please use digits and/or the comma"; } } try { newOption.Maturity = DateTime.Parse(Date.Text); } catch (ArgumentNullException) { correctOption = false; dateWarningLabel.Visibility = Visibility.Visible; dateWarningLabel.Content = "Please select a date"; } catch (FormatException) { correctOption = false; dateWarningLabel.Visibility = Visibility.Visible; dateWarningLabel.Content = "Please enter the date in format: yyy-mm-dd"; } if (newOption.Maturity < DateTime.Today) { correctOption = false; dateWarningLabel.Visibility = Visibility.Visible; dateWarningLabel.Content = "Please enter the future date"; } if (correctOption) { list.Add(newOption); CloseWindow(sender, e); } }