Esempio n. 1
0
        // For 100bp increase in vol, premium = Premium_0 + Vega().
        public double Vega()
        {
            double bumpedVol          = (_Vol + 0.01) * Math.Sqrt(T);
            BlackScholesCalculator up = new BlackScholesCalculator(new PlainVanillaPayoff(Type, Strike), _Spot, GrowthFactor, bumpedVol, DF);

            double vega = up.value() - Option[0].value();

            return((double.IsNaN(vega) ? 0 : vega) / Spot);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="model">the model</param>
        /// <exception cref="ArgumentNullException"/>
        public CalculateCommand(CalculatorModel model)
        {
            if (null == model)
            {
                throw new ArgumentNullException(nameof(model));
            }

            _model      = model;
            _calculator = new BlackScholesCalculator();
        }
        public void Must_Import_Data_And_Calculate_For_Csv(FileReaderTypeEnum fileReaderTypeEnum, string extension)
        {
            IFileReader reader = FileReaderFactory.GetReader(fileReaderTypeEnum);
            List <BlackScholesInput> blackScholesInputData = reader.Read <BlackScholesInput>($"{FullPath}{extension}");

            var optionPricingCalculator = new BlackScholesCalculator();
            List <BlackScholesResult> blackScholesResultData = optionPricingCalculator.CalculateFor(blackScholesInputData);

            List <double> expectedResults =
                new List <double>()
            {
                110, 30, 0, 0, 110, 1.2444594168143162E-196, 110, 0
            };

            List <double> results = optionPricingCalculator.CalculateFor(blackScholesInputData).Select(r => r.Result).ToList();

            CollectionAssert.AreEqual(expectedResults, results);
        }
Esempio n. 4
0
        private void btnInputFile_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialogCsv.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    FileReaderTypeEnum       fileReaderTypeEnum    = GetFileReaderTypeFor(openFileDialogCsv.FileName);
                    IFileReader              reader                = FileReaderFactory.GetReader(fileReaderTypeEnum);
                    List <BlackScholesInput> blackScholesInputData = reader.Read <BlackScholesInput>(openFileDialogCsv.FileName);

                    var optionPricingCalculator = new BlackScholesCalculator();
                    List <BlackScholesResult> blackScholesResultData = optionPricingCalculator.CalculateFor(blackScholesInputData);

                    ShowResultsOnScreen(blackScholesResultData);
                }
                catch (Exception ex)
                {
                    string message = $"{ErrorsResource.ErrorToProcessData} Error: {ex.Message}";
                    MessageBox.Show(message, ErrorsResource.TitleErrorToProcessData, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 5
0
        public void Initialize()
        {
            _calculator = new BlackScholesCalculator();

            _result = _calculator.Calculate(BlackScholesCalculatorPricingData.NewPricingData(45, 23, 0.10M, 0.15M, 123M));
        }
Esempio n. 6
0
        public void Initialize()
        {
            _calculator = new BlackScholesCalculator();

            _result = _calculator.Calculate(BlackScholesCalculatorPricingData.NewPricingData(50, 55, 0.2M, 0.09M, 365M));
        }
        public void Initialize()
        {
            _calculator = new BlackScholesCalculator();

            _result = _calculator.Calculate(BlackScholesCalculatorPricingData.NewPricingData(56, 32, 0.74M, 0.02M, 99M));
        }
        public void Initialize()
        {
            _calculator = new BlackScholesCalculator();

            _result = _calculator.Calculate(BlackScholesCalculatorPricingData.NewPricingData(64, 60, 0.27M, 0.045M, 180M));
        }
Esempio n. 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="viewModel">the view model</param>
 /// <exception cref="ArgumentNullException"/>
 public CalculateCommand(CalculatorViewModel viewModel)
 {
     _viewModel  = viewModel ?? throw new ArgumentNullException(nameof(viewModel));;
     _calculator = new BlackScholesCalculator();
 }
Esempio n. 10
0
        public void Initialize()
        {
            _calculator = new BlackScholesCalculator();

            _result = _calculator.Calculate(BlackScholesCalculatorPricingData.NewPricingData(28, 30, 0.37M, 0.15M, 251M));
        }
 public BlackScholesCalculatorTest()
 {
     _blackScholesCalculator = new BlackScholesCalculator();
     _fileReaderMock         = new FileReaderMock();
 }
Esempio n. 12
0
        public MainFormMetroApp()
        {
            InitializeComponent();

            InitializeWeeklyDataTable();
            _expandimage = Image.FromFile("treeexpand.jpg");
            _collapseimage = Image.FromFile("treecollapse.jpg");
            _blackScholesCalculator = new BlackScholesCalculator();

            uiStrategy_comboBoxExOISStepKind.SelectedIndex = 0;
            uiStrategy_comboBoxExOOOSStepKind.SelectedIndex = 0;
            uiStrategy_comboBoxExOOOSStepKind.KeyPress += KeyPressValidator;
            uiStrategy_comboBoxExOISStepKind.KeyPress += KeyPressValidator;

            uiCalendar_calendarViewResultView.SelectedView = eCalendarView.Month;
            uiBlackSValueDate.Value = DateTime.Now;

            //_monthProfit = new double[12];

            uiBlackSInterestRate.KeyPress += KeyPressValidator;
            uiBlackSUnderlyingPrice.KeyPress += KeyPressValidator;
            uiBlackSVolality.KeyPress += KeyPressValidator;
            uiBlackSQuantity.KeyPress += QuantityKeyPressValidator;
            uiBlackSPriceStrike.KeyPress += KeyPressValidator;
            uiBlackSCallGamma.KeyPress += KeyPressValidator;
            uiBlackSCallTheta.KeyPress += KeyPressValidator;
            uiBlackSCallVega.KeyPress += KeyPressValidator;
            uiBlackSPutGamma.KeyPress += KeyPressValidator;
            uiBlackSPutTheta.KeyPress += KeyPressValidator;
            uiBlackSPutVega.KeyPress += KeyPressValidator;

            uiBlackSInterestRate.KeyDown += SubmitTextBox;
            uiBlackSUnderlyingPrice.KeyDown += SubmitTextBox;
            uiBlackSVolality.KeyDown += SubmitTextBox;
            uiBlackSQuantity.KeyDown += SubmitTextBox;
            uiBlackSPriceStrike.KeyDown += SubmitTextBox;

            uiStrategy_dataGridViewNoOptomizationParameters.KeyPress += DGridKeyPressValidator;
            uiStrategy_dataGridViewOptomizationParameters.KeyPress += DGridKeyPressValidator;

            uiBlackSQuantity.Text = @"45";

            _calendarResult = new List<ResultModel>();
            _weeklist = new List<ResultModel>();

            labelX1.ForeColor = Color.SteelBlue;
            labelX2.ForeColor = Color.SteelBlue;
            labelX3.ForeColor = Color.SteelBlue;
            labelX4.ForeColor = Color.SteelBlue;
            labelX5.ForeColor = Color.SteelBlue;
            labelX7.ForeColor = Color.SteelBlue;
            labelX8.ForeColor = Color.SteelBlue;
            labelX9.ForeColor = Color.SteelBlue;
            uiDataArchive_labelXSymbolsCommands.ForeColor = Color.SteelBlue;
            uiDataArchive_labelXCollectingControl.ForeColor = Color.SteelBlue;
            uiDataArchive_labelXSearch.ForeColor = Color.SteelBlue;

            uiDataArchive_dateTimeInputFindTime.CustomFormat = @"HH:mm:ss";
            uiDataArchive_dateTimeInputFindTime.Format = eDateTimePickerFormat.ShortTime;

            uiDataArchive_dateTimeInputStart.Value = DateTime.Today.AddDays(-1);
            uiDataArchive_dateTimeInputEnd.Value = DateTime.Today;

            uiStrategy_dateTimeAdvOISStart.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiStrategy_dateTimeAdvOISStart.Format = eDateTimePickerFormat.Custom;

            uiStrategy_dateTimeAdvOISEnd.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiStrategy_dateTimeAdvOISEnd.Format = eDateTimePickerFormat.Custom;

            uiStrategy_dateTimeAdvOOOSStart.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiStrategy_dateTimeAdvOOOSStart.Format = eDateTimePickerFormat.Custom;

            uiStrategy_dateTimeAdvOOOSEnd.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiStrategy_dateTimeAdvOOOSEnd.Format = eDateTimePickerFormat.Custom;

            uiBlackSValueDate.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiBlackSValueDate.Format = eDateTimePickerFormat.Custom;

            uiBlackSExpiryDate.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiBlackSExpiryDate.Format = eDateTimePickerFormat.Custom;

            uiDataArchive_dateTimeInputStart.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiDataArchive_dateTimeInputStart.Format = eDateTimePickerFormat.Custom;

            uiDataArchive_dateTimeInputEnd.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiDataArchive_dateTimeInputEnd.Format = eDateTimePickerFormat.Custom;

            uiDataArchive_dateTimeInputFindDate.CustomFormat = DateFormatsManager.CurrentShortDateFormat;
            uiDataArchive_dateTimeInputFindDate.Format = eDateTimePickerFormat.Custom;

            ToastNotification.ToastBackColor = Color.SteelBlue;
            ToastNotification.ToastForeColor = Color.White;
            ToastNotification.ToastFont = new Font("Segoe UI", 10F);
            ToastNotification.CustomGlowColor = Color.Blue;
            ToastNotification.DefaultToastPosition = eToastPosition.TopCenter;
            ToastNotification.DefaultTimeoutInterval = 2000;
        }
Esempio n. 13
0
 public void Initialize()
 {
     _calculator = new BlackScholesCalculator();
 }