private void goBtn_Click(object sender, EventArgs e) { // Retrieve the values of the parameters in the TextBoxes WrapperClass wc = new WrapperClass(); wc.getPriceCallEuro(nbSamples, maturity, S0, strike, sigma, r); prixLabel.Text = wc.getPrice().ToString(); icLabel.Text = wc.getIC().ToString(); }
public Form1() { InitializeComponent(); // Récupérer les valeurs des paramètres dans les différentes TextBox WrapperClass wc = new WrapperClass(); double S0 = 100; double sigma = 0.2; double r = 0.095; double T = 1; double K = 100; int J = 12; int M = 50000; wc.getPriceOptionMC(S0, sigma, r, T, K, J, M); PrixMC_Lab.Text = wc.getPrice().ToString(); ICMC_Lab.Text = wc.getIC().ToString(); wc.getPriceOptionMCC(S0, sigma, r, T, K, J, M); PrixMCC_Lab.Text = wc.getPrice().ToString(); ICMCC_Lab.Text = wc.getIC().ToString(); }
protected void Button1_Click(object sender, EventArgs e) { double t = double.Parse(TextBox1.Text); int H = int.Parse(TextBox2.Text); int size = 4; double[] spot = new double[] { 100, 100, 100, 100 }; double[] sigma = new double[] { 0.2, 0.2, 0.2, 0.2 }; double r = 0.05; double[] coeff = new double[] { .25, .25, .25, .25 }; double[] rho = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; double T = 6; int N = 6; int M = 50000; WrapperClass wc = new WrapperClass(); double K = 0.0; wc.getPrice(t, size, spot, K, sigma, r, coeff, rho, T, N, H, M); Label1.Text = Math.Round(wc.getPrice(), 4).ToString(); Label2.Text = Math.Round(wc.getICP(), 4).ToString(); Label3.Text = Math.Round(wc.getPriceBS(), 4).ToString(); }
public void price(object sender, EventArgs e) { // Récupérer les valeurs des paramètres dans les différentes TextBox WrapperClass wc = new WrapperClass(); /*double strike = double.Parse(strike_tb.Text); * int size = int.Parse(size_tb.Text); * double r = double.Parse(r_tb.Text); * double he = double.Parse(h_tb.Text); * int sample = int.Parse(samples_tb.Text);*/ //byte[] abyte1 = new byte[type.Text.Length]; //System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); //abyte1 = encoding.GetBytes(type.Text); //sbyte[] baske = Array.ConvertAll(abyte1, q => Convert.ToSByte(q)); String type = "basket"; //double[] sigma = new double[5]; //sigm[0] = double.Parse(sigma.Text); //double[] rho = new double[1]; //ro[0] = double.Parse(rho.Text); // Valeurs manuels const int size = 5; double strike = 100; double[] spot = new double[size] { 90, 80, 100, 120, 110 }; double maturity = 1; double[] sigma = new double[size] { 0.2, 0.2, 0.2, 0.15, 0.15 }; double r = 0.05; double[] rho = new double[(size - 1) * size / 2] { 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2 }; double[] coeff = new double[size] { 0.2, 0.2, 0.2, 0.2, 0.2 }; int timeStep = 1; int samples = 50000; wc.getPriceOption(type, size, spot, strike, maturity, sigma, r, rho, coeff, timeStep, samples); prix_label.Text = wc.getPrice().ToString(); ic_label.Text = wc.getIC().ToString(); }
static void Main(string[] args) { WrapperClass wc = new WrapperClass(); double px, ic; int M = 50000; double T = 2; double S0 = 100; double K = 110; double L = 80; double sigma = 0.2; double r = 0.05; int J = 24; wc.getPriceOption(M, T, S0, K, L, sigma, r, J); px = wc.getPrice(); ic = wc.getIC(); System.Console.WriteLine("prix: %f\nic: %f\n", px, ic); System.Console.ReadKey(); }
public void price(object sender, EventArgs e) { // Récupérer les valeurs des paramètres dans les différentes TextBox WrapperClass wc = new WrapperClass(); /*double strike = double.Parse(strike_tb.Text); int size = int.Parse(size_tb.Text); double r = double.Parse(r_tb.Text); double he = double.Parse(h_tb.Text); int sample = int.Parse(samples_tb.Text);*/ //byte[] abyte1 = new byte[type.Text.Length]; //System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); //abyte1 = encoding.GetBytes(type.Text); //sbyte[] baske = Array.ConvertAll(abyte1, q => Convert.ToSByte(q)); String type = "basket"; //double[] sigma = new double[5]; //sigm[0] = double.Parse(sigma.Text); //double[] rho = new double[1]; //ro[0] = double.Parse(rho.Text); // Valeurs manuels const int size = 5; double strike = 100; double[] spot = new double[size] {90, 80, 100, 120, 110}; double maturity = 1; double[] sigma = new double[size] { 0.2, 0.2, 0.2, 0.15, 0.15 }; double r = 0.05; double[] rho = new double[(size - 1) * size / 2] { 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2 }; double[] coeff = new double[size] { 0.2, 0.2, 0.2, 0.2, 0.2 }; int timeStep = 1; int samples = 50000; wc.getPriceOption(type, size, spot, strike, maturity, sigma, r, rho, coeff, timeStep, samples); prix_label.Text = wc.getPrice().ToString(); ic_label.Text = wc.getIC().ToString(); }
protected void Hedge(object sender, EventArgs e) { //Affichage de la courbe associée au portefeuille DateTime DateDeb = DateTime.Parse(datepicker.Text.ToString()); DateTime DateFin = DateTime.Parse(datepicker2.Text.ToString()); TimeSpan difference = DateFin.Date - DateDeb.Date ; double rebalancement = double.Parse(estimate_time.Text.ToString()); WrapperClass wrap = new WrapperClass(4,60); AccesBD acces = new AccesDB.AccesBD(); acces.DeleteCompo(new DateTime(2000, 1, 1), new DateTime(2010, 4, 28)); //acces.getAssetSpot("FTSE", DateDeb, DateDeb); AfficheBD affiche = new AffichageBD.AfficheBD(); double[] spot = new double[4]; //On fait l'approximation que tout les spots commençent à la même date et on ne tient pas compte des paramètres pour le moment ComputeParam cp = new ComputeParam(); cp.param(400,DateDeb.AddDays(-300)); double[] sigma = new double[4]; double[] rho = new double[16]; for (int i = 0; i<4; i++){ sigma[i] = cp.Volatility[i]; for (int j = 0 ; j < 4; j++){ rho[i*4+j] = cp.Corel[i,j]; } } double[] coeff = new double[4]; double[][] past = new double[4][]; for (int i = 0; i<4; i++){ coeff[i] = 0.25; } String Date = datepicker.Text.ToString(); DateTime Datee = DateDeb; Chart1.Titles.Add("Composition du portefeuille de couverture"); Chart1.Legends.Add(new Legend("Valeur du portefeuille")); Chart1.Legends.Add(new Legend("Valeur du produit")); Chart1.Series[0].Name = "Valeur du portefeuille"; Chart1.Series[1].Name = "Valeur du produit"; DateTime previousDate = DateDeb; int pas = (difference.Days) / (int)rebalancement+1; DateTime DateFinBD = new DateTime(1,1,1); spot = acces.getLastSpot(ref DateFinBD); bool firstPas = true; int taille = ((((DateFin.Date - DateDeb.Date).Days) / pas) + 1); while ((DateFin.CompareTo(DateDeb) > 0 && acces.getCurrentValLiq(DateDeb)!=0) || firstPas) { firstPas = false; past[0] = acces.getAssetSpot("FTSE", DateDeb, Datee,pas); past[1] = acces.getAssetSpot("S&P", DateDeb, Datee,pas); past[2] = acces.getAssetSpot("NIKKEI", DateDeb, Datee,pas); past[3] = acces.getAssetSpot("EUROSTOXX", DateDeb, Datee,pas); double[] realPast = new double[past[0].Length * 4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < past[0].Length; j++) { realPast[i * past[0].Length + j] = past[i][j]; } } double risk = acces.getCurrentRisk(previousDate); double riskfree = acces.getCurrentRiskFree(previousDate); double[] tmpDelta = acces.getDelta(previousDate); //Traitement du cas où la date de départ est celle de début du produit //Changer le Past en tableaux bidimmensionnels !! wrap.computePortfolio(past[0].Length, 4, 30, 1000, (int)rebalancement, ((DateFin.Date - Datee.Date).Days) / 365.0, (DateDeb-Datee).Days/365.0, 0.05, sigma, rho, coeff, realPast); acces.Insert(DateDeb, wrap.getPrice(), wrap.getDelta(), wrap.getRiskFree(), wrap.getRisk()); //Affichage du portefeuille if (wrap.getPrice() != 0) { Chart1.Series[0].Points.AddXY(DateDeb, wrap.getRisk() + wrap.getRiskFree()); Chart1.Series[1].Points.AddXY(DateDeb, wrap.getPrice()); } //Chart1.Series[1].Points.AddXY(DateDeb, risk + riskfree); previousDate = DateDeb; DateDeb = DateDeb.AddDays(pas); } string[,] toolti = acces.extractData(DateTime.Parse(datepicker.Text.ToString()), DateTime.Parse(datepicker2.Text.ToString())); for (int i = 0; i < Chart1.Series[0].Points.Count; i++) { Chart1.Series[0].Points[i].ToolTip = string.Format("Date = {0}, Valeur Portefeuille = {1}", toolti[2,i], Math.Round(double.Parse(toolti[1,i]),2)); Chart1.Series[1].Points[i].ToolTip = string.Format("Date = {0}, Valeur Liquidative = {1}", toolti[2, i], Math.Round(double.Parse(toolti[0, i]), 2)); } Affichage.Style.Add(HtmlTextWriterStyle.Display, "inline"); }