示例#1
0
 public ComputeParam()
 {
     data = new AccesDB.AccesBD();
     Assets = new String[4] { "FTSE", "S&P", "NIKKEI", "EUROSTOXX"};
     AssetsChange = new String[3] { "Eur/JPY", "Eur/USD", "Eur/GBP" };
     mean = new double[4];
     meanChange = new double[3];
     Volatility = new double[4];
     VolatilityChange = new double[3];
     corel = new double[4, 4];
     CorelChange = new double[3, 3];
 }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     AccesBD BD = new AccesBD();
     Panel1.Controls.Clear();
     Panel1.Controls.Add(new LiteralControl(DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString()));
     String nomPd= null;
     int nbParts = 0, valNom = 0;
     int info = BD.GetInfoProd(ref nomPd, ref nbParts,ref valNom);
     if (info != 0)
     {
         Panel4.Controls.Clear();
         Panel5.Controls.Clear();
         Panel6.Controls.Clear();
         Panel4.Controls.Add(new LiteralControl(nbParts.ToString()));
         Panel5.Controls.Add(new LiteralControl((valNom).ToString() + "€"));
         LiteralControl ok = (LiteralControl)Panel2.Controls[0];
         Panel6.Controls.Add(new LiteralControl(Math.Round((100 * double.Parse(nbParts.ToString()) / double.Parse(ok.Text.ToString())), 2).ToString() + "%"));
     }
 }
示例#3
0
 protected void ChangePart(object sender, EventArgs e)
 {
     try
     {
         AccesBD BD = new AccesBD();
         int.Parse(TextBox1.Text);
         Panel4.Controls.Clear();
         Panel5.Controls.Clear();
         Panel6.Controls.Clear();
         String parts = TextBox1.Text;
         Panel4.Controls.Add(new LiteralControl(parts));
         Panel5.Controls.Add(new LiteralControl((double.Parse(parts) * 150).ToString() + "€"));
         LiteralControl ok = (LiteralControl)Panel2.Controls[0];
         Panel6.Controls.Add(new LiteralControl(Math.Round((100*double.Parse(parts)/double.Parse(ok.Text.ToString())),2).ToString()+"%"));
         BD.InsertInfoProd("Playlist 2", int.Parse(parts), int.Parse(parts) * 150);
     }
     catch
     {
         System.Console.Write("error");
     }
 }
示例#4
0
        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");
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                //Initialisation manuelle de la base de données en ajoutant les cours des actifs
                AccesBD acces = new AccesDB.AccesBD();
                DateTime LastDat = new DateTime(1,1,1);
                acces.getLastPepDate(ref LastDat);
                List<HistoricalColumn> list = new List<HistoricalColumn>();
                list.Add(HistoricalColumn.Close);
                List<String> symbol = new List<String>();
                symbol.Add("^FTSE");
                symbol.Add("^GSPC");
                symbol.Add("^N225");
                symbol.Add("^STOXX50E");
                DataActif actif = new DataActif(symbol, list, LastDat, DateTime.Now);
                actif.ImportData(new ImportYahoo());
                // actif.Export(new DBExporter());
                //Initialisation des taux de changes
                List<Currency> curr = new List<Currency>();
                curr.Add(Currency.USD);
                curr.Add(Currency.JPY);
                curr.Add(Currency.GBP);
                DateTime init = LastDat.Date;
                DBExporter hello = new DBExporter();
                DataFXTop xchange;
                while (DateTime.Now.CompareTo(init) > 0)
                {
                    if (init.AddYears(1).CompareTo(DateTime.Now) > 0)
                    {
                        xchange = new DataFXTop(Currency.EUR, curr, init, DateTime.Now, Frequency.Daily);
                        xchange.ImportData(new ParserFXTop());
                        hello.Export(actif, xchange, init, DateTime.Now);
                        init = DateTime.Now;
                    }
                    else
                    {
                        xchange = new DataFXTop(Currency.EUR, curr, init, init.AddYears(1), Frequency.Daily);
                        xchange.ImportData(new ParserFXTop());
                        hello.Export(actif, xchange, init, init.AddYears(1));
                        init = init.AddYears(1).AddDays(1);
                    }
                }

                hidden_estimate.Value = "300";
            }
        }