void loadPrevious() { if (bundle != null) { // Debug.Log("Testing in previous"); bundle.Unload(false); } // Debug.Log("Testing Inside focus-13"); Destroy(mBundleInstance); mBundleInstance.SetActive(false); //changed on 11/6/19 mAttached = false; AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); currentActivity = UnityPlayer.GetStatic <AndroidJavaObject>("currentActivity"); if (orders.Count > 0) { flag_order = 1; var a = new WrapperClass() { list = orders }; json = JsonUtility.ToJson(a); } else { flag_order = 0; json = "null"; } currentActivity.Call("onBackAndroid", flag_order, json, panId); }
public static WrapperClass GetEverything() { var wrapper = new WrapperClass(); // set wrapper properties return(wrapper); }
void loadScne() { if (bundle != null) { bundle.Unload(false); } Destroy(mBundleInstance); mAttached = true; AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); currentActivity = UnityPlayer.GetStatic <AndroidJavaObject>("currentActivity"); var a = new WrapperClass() { list = orders }; string json = JsonUtility.ToJson(a); Debug.Log("JSON" + json); loadingpanel.SetActive(true); currentActivity.Call("onGameFinish", json); }
protected override MyCollection Revert(WrapperClass value) { var c = new MyCollection(); c.AddRange(value.Items); c.MyField = value.MyField; return(c); }
protected override MyCollection Revert(string fieldName, WrapperClass fieldValue) { var c = new MyCollection(); c.AddRange(fieldValue.Items); c.MyField = fieldValue.MyField; return(c); }
static void Main(string[] args) { Console.WriteLine("---------Start---------"); var wrapper = new WrapperClass(); wrapper.Run(); Console.WriteLine("---------End---------"); }
public static WrapperClass GetEverything() { var wrapper = new WrapperClass(); wrapper.DayNightControl = DNControl.Instance; wrapper.MapHandler = MapHandler.Instance; wrapper.TemperatureControl = TemperatureControl.Instance; return(wrapper); }
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 void TestHierarchicalAutoSerialization() { var o1 = new WrapperClass(new WrapperClass(new string[] { "request", "response", "event" }, new WrapperClass(new WrapperClass(new Guid[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }, null), null)), null); writer.Write(o1); var result = writer.ToString(); Assert.IsNotNull(result, "Expected serialized object"); Assert.IsFalse(result.Contains("null"), "Unexpected token found"); }
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(); }
private void Form1_Load(object sender, EventArgs e) { //Configure remoting. RemotingConfiguration.Configure(Application.StartupPath + "\\Client.exe.config", false); // Create a proxy from remote object. remoteClass = (RemoteClass)Activator.GetObject(typeof(RemoteClass), "http://localhost:5000/Chat"); //Create an instance of wrapper class. wrapperClass = new WrapperClass(); //Associate remote object event with wrapper method. remoteClass.MessageReceived += new MessageHandler(wrapperClass.WrapperMessageReceivedHandler); //Associate wrapper event with current form event handler. wrapperClass.WrapperMessageReceived += new MessageHandler(MessageReceivedHandler); }
public UserControls.FormControl BuildFormControl <T>(T Class) { if (Debug) { formControl.DebugStatsWrapPanel.Visibility = Visibility.Visible; } var sw = Stopwatch.StartNew(); object RootClass = Class; if (Class is System.Collections.IList) { var wrapperClass = new WrapperClass { List = Class }; RootClass = wrapperClass; } formControl.Tag = RootClass; ProcessRootClass(RootClass, formControl); OnPropertyModified += (name, value) => { HasChanged = true; }; sw.Stop(); if (Debug) { formControl.LoadTimeLabel.Content = $"Load Time: {sw.ElapsedMilliseconds}ms"; sw.Restart(); formControl.Loaded += (sender, args) => { formControl.DisplayTimeLabel.Content = $"Display Time: {sw.ElapsedMilliseconds}ms"; sw.Stop(); }; } return(formControl); }
public View() { InitializeComponent(); this.wrapperClass = new WrapperClass(); this.typeDocuments = new Dictionary <Type, DockControl> (); this.loadedAssemblies = new List <string> (); this.Size = new Size(1200, 750); this.languageToolStripComboBox.SelectedIndex = 0; string mscorlib = Environment.ExpandEnvironmentVariables(@"%WinDir%\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll"); //if (File.Exists (mscorlib)) //{ // this.assemblyBrowser.Assemblies.Add (mscorlib); //} }
protected void Button3_Click(object sender, EventArgs e) { int samples = int.Parse(TextBox5.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.getPriceSamples(size, spot, K, sigma, r, coeff, rho, T, N, M, samples); Label7.Text = Math.Round(wc.getVrP(), 4).ToString(); Label8.Text = Math.Round(wc.getMxP(), 4).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 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 Button2_Click(object sender, EventArgs e) { double t = double.Parse(TextBox3.Text); int H = int.Parse(TextBox4.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.getDelta(t, size, spot, K, sigma, r, coeff, rho, T, N, H, M); Label4.Text = Math.Round(wc.getDelta(), 4).ToString(); Label5.Text = Math.Round(wc.getICD(), 4).ToString(); Label6.Text = Math.Round(wc.getDeltaBS(), 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) { int resultNumber = 0; // ����Managed C++����ʵ�� WrapperClass wrapperObj = new WrapperClass(); // ���ó˷�������P/Invoke) resultNumber = wrapperObj.MultiplyNumbers_PInvoke(2, 3); Console.WriteLine("�˷���P/Invoke����2x3 = {0}", resultNumber); // ���ó˷�������C++ Interop) resultNumber = wrapperObj.MultiplyNumbers_CppInterop(4, 5); Console.WriteLine("�˷���C++ Interop����4x5 = {0}", resultNumber); // ��ת�ַ�������(P/Invoke) wrapperObj.ReverseString_PInvoke(); // ��ת�ַ�������(C++ Interop) wrapperObj.ReverseString_CppInterop(); Console.WriteLine("\r\n��������˳�..."); Console.Read(); }
public double displayPrice() { DateTime date = new DateTime(2015, 03, 27); DateTime debutProduit = new DateTime(2014, 12, 18); DateTime finProduit = new DateTime(2022, 12, 08); Data.RecupData recup = new RecupData(new DateTime(2000, 1, 1), date); //Data.RecupData recup1 = new RecupData(new DateTime(2000, 1, 1), debutProduit); recup.Fetch(); //recup1.Fetch(); double t = recup.DateToDouble(debutProduit, date, finProduit); double[,] covLogR = recup.exportCov(new DateTime(2004, 01, 01), new DateTime(2014, 01, 01)); double[,] pastDelta = recup.exportPast(t, 7, debutProduit, finProduit); double[,] pastPrice = recup.exportPast(t, 182, debutProduit, finProduit); DateTime debutBackTest = new DateTime(2010, 03, 22); DateTime finBacktest = new DateTime(2018, 03, 22); double t0 = recup.DateToDouble(debutBackTest, finBacktest, finBacktest); double[,] donneesHistoriques = recup.exportPast(t0, 7, debutBackTest, finBacktest); //int size, double r, double* VarHis, double* spot, double* trend, double fdStep, int nbSamples, double strike, double T1, int nbTimeSteps1, double* lambdas1 double r_eu = 0.002; double r_aus = 0.025; double r_us = 0.00025; int size = 5; double r = r_eu; double[] spots = new double[5]; for (int i = 0; i < 5; i++) { spots[i] = pastPrice[0, i]; } double[] trends = new double[5]; trends[0] = r_eu; trends[1] = r_us - covLogR[1, 3]; trends[2] = r_aus - covLogR[2, 4]; trends[3] = r_eu - r_us; trends[4] = r_eu - r_aus; double[] lambdas = new double[5]; for (int i = 0; i < 5; i++) { lambdas[i] = 0.05; } WrapperClass wc = new WrapperClass(size, r, covLogR, spots, trends, 0.1, 500, 10, 8.0, 16, lambdas); double[] delta = new double[5]; double H = 416; int m = pastDelta.GetLength(0); double[] price = new double[m]; double[] pocket = new double[m]; double[] tracking = new double[m - 1]; wc.trackingError(pastDelta, pastPrice, t, H, price, pocket, tracking, m, pastPrice.GetLength(0)); Stock stock = new Stock(recup); stock.Add(0.0, wc.getDeltaEurostral(recup.exportPast(0, 182, debutProduit, finProduit), 0.0, H), price[0], 0.0); for (int i = 1; i < m - 1; i++) { stock.Add(i * 8.0 / H, wc.getDeltaEurostral(recup.exportPast(i * 8.0 / H, 182, debutProduit, finProduit), i * 8.0 / H, H), price[i], tracking[i - 1]); } stock.Add(t, wc.getDeltaEurostral(recup.exportPast(t, 182, debutProduit, finProduit), t, H), price[m - 1], tracking[m - 2]); stock.SaveToCSV(); return(wc.getPriceEurostral(t, pastPrice)); }
public Bind(ref WrapperClass wrapper) { wrapper = new WrapperClass(); wrapper.Input = new OtherClass(); // instantiating the object _wrapper = wrapper; // keeping a reference of the created object for later usage! }
protected void Start_Click() { DateTime DateDeb = DateTime.Now; DateTime DateFin = new DateTime(2016,05,29); rebalancement = double.Parse(estimate_time.Text.ToString()); Dictionary<string,string> dic = acces.getLastCouv(DateTime.Now); double[] delt = new double[4]; delt[0] = double.Parse(dic["deltaFTSE"]); delt[1] = double.Parse(dic["deltaS_P"]); delt[2] = double.Parse(dic["deltaNIKKEI"]); delt[3] = double.Parse(dic["deltaEURO"]); double riskinit = double.Parse(dic["risk"]); double riskfreeinit = double.Parse(dic["riskfree"]); double ValLiq = double.Parse(dic["ValLiq"]); wrap = new WrapperClass(4, 60, ValLiq, delt, riskinit, riskfreeinit); acces.DeleteCompo(DateTime.Now.Date.AddHours(1), new DateTime(2016, 5, 29)); //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 //Préparation du calcul des valeurs DateTime previousDate = DateDeb; DateTime LastTimeBD = new DateTime(1, 1, 1); spot = acces.getLastSpot(ref LastTimeBD); int taille = ((((DateFin.Date - DateDeb.Date).Days) / pas) + 1); //Calcul des valeurs de marché durant la couverture int taille_bis = (DateFin.Date - DateDeb.Date).Days; double[] futurSpot = new double[4]; double[] PathSim = new Double[4 * (taille_bis+1)]; 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"; 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); DateTime lastDatCouv = new DateTime(1,1,1); acces.getLastCompoDate(ref lastDatCouv); //Traitement du cas où la date de départ est celle de début du produit if (lastDatCouv.AddDays(pas) == DateTime.Now.Date) { // wrap.computePortfolio(past[0].Length, 4, 30, 1000, (int)rebalancement, ((Maturity.Date - Datee.Date).Days) / 365.0, (DateTime.Now - Datee).Days / 365.0, 0.05, sigma, rho, coeff, realPast); // acces.Insert(DateDeb, wrap.getPrice(), wrap.getDelta(), wrap.getRiskFree(), wrap.getRisk()); previousDate = DateDeb; String[,] values = acces.extractData(Datee, DateTime.Now.AddDays(pas)); for (int i = 0; i < values.Length / 3; ++i) { Chart1.Series[0].Points.AddXY(DateTime.Parse(values[2, i]), double.Parse(values[1, i])); Chart1.Series[1].Points.AddXY(DateTime.Parse(values[2, i]), double.Parse(values[0, i])); Chart1.Series[0].Points[i].ToolTip = string.Format("Date = {0}, Valeur Portefeuille = {1}", values[2, i], Math.Round(double.Parse(values[1, i]), 2)); Chart1.Series[1].Points[i].ToolTip = string.Format("Date = {0}, Valeur Liquidative = {1}", values[2, i], Math.Round(double.Parse(values[0, i]), 2)); } } else { String[,] values = acces.extractData(Datee, DateTime.Now); for (int i = 0; i < values.Length / 3; ++i) { Chart1.Series[0].Points.AddXY(DateTime.Parse(values[2, i]), double.Parse(values[1, i])); Chart1.Series[1].Points.AddXY(DateTime.Parse(values[2, i]), double.Parse(values[0, i])); Chart1.Series[0].Points[i].ToolTip = string.Format("Date = {0}, Valeur Portefeuille = {1}", values[2, i], Math.Round(double.Parse(values[1, i]), 2)); Chart1.Series[1].Points[i].ToolTip = string.Format("Date = {0}, Valeur Liquidative = {1}", values[2, i], Math.Round(double.Parse(values[0, i]), 2)); } } DateTime LastCov = new DateTime(1, 1, 1); double[] parts = acces.getLastParts(ref LastCov); double[] sp = new double[4]; sp[0] = acces.getAssetSpot("FTSE", LastCov.AddHours(23), LastCov, 1)[0]; sp[1] = acces.getAssetSpot("S&P", LastCov.AddHours(23), LastCov, 1)[0]; sp[2] = acces.getAssetSpot("NIKKEI", LastCov.AddHours(23), LastCov, 1)[0]; sp[3] = acces.getAssetSpot("EUROSTOXX", LastCov.AddHours(23), LastCov, 1)[0]; double ValPort = acces.getCurrentRisk(LastCov) + acces.getCurrentRiskFree(LastCov); CreateChart(parts,sp); BisCreatChart(acces.getAllStackedColumn(pas)); //Portfolio_value.Text = "0"; //Product_value.Text = "0"; //Err_value.Text = "0"; //Start.Visible = false; // Next_day.Text = "Calcul au jour " + day.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"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //DateTime DateDeb = new DateTime(2010, 4, 29); DateTime DateDeb = new DateTime(1, 1, 1); acces.getLastCompoDate(ref DateDeb); bool att = false; if (DateDeb.CompareTo(Datee) < 0) { DateDeb = Datee; att = true; } DateTime DateFin = DateTime.Now; TimeSpan difference = Maturity.Date - Datee.Date; rebalancement = double.Parse(estimate_time.Text.ToString()); wrap = new WrapperClass(4, 60); //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 cp.param(600, DateDeb.AddDays(-600)); for (int i = 0; i < 4; i++) { coeff[i] = 0.25; sigma[i] = cp.Volatility[i] + 0.1; for (int j = 0; j < 4; j++) { rho[i * 4 + j] = cp.Corel[i, j]; } } //Préparation du calcul des valeurs DateTime previousDate = DateDeb; pas = (difference.Days) / (int)rebalancement + 1; //Traitement du cas où la date de départ est celle de début du produit int taille = ((((DateFin.Date - DateDeb.Date).Days) / pas) + 1); if (DateDeb.CompareTo(Datee) >= 0 && !att) { DateDeb = DateDeb.AddDays(pas); } att = false; while (DateFin.CompareTo(DateDeb) > 0) { 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]; } } if (DateDeb.CompareTo(Datee) > 0) { Dictionary<string, string> dic = acces.getLastCouv(DateTime.Now); double[] tmpDelta = new double[4]; tmpDelta[0] = double.Parse(dic["deltaFTSE"]); tmpDelta[1] = double.Parse(dic["deltaS_P"]); tmpDelta[2] = double.Parse(dic["deltaNIKKEI"]); tmpDelta[3] = double.Parse(dic["deltaEURO"]); double risk = double.Parse(dic["risk"]); double riskfree = double.Parse(dic["riskfree"]); double ValLiq = double.Parse(dic["ValLiq"]); wrap = new WrapperClass(4, 60, ValLiq, tmpDelta, risk, riskfree); } //Traitement du cas où la date de départ est celle de début du produit wrap.computePortfolio(past[0].Length, 4, 30, 1000, (int)rebalancement, ((Maturity.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()); previousDate = DateDeb; DateDeb = DateDeb.AddDays(pas); } Start_Click(); } else { Start_Click(); } }
void FixedUpdate() { //Check if the current scene is AR view if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("ARMainScreen_3")) { //Null check on BundleInstance clear = GameObject.Find("ImageTarget").GetComponent <ARLoader>().clear; android_order = GameObject.Find("ImageTarget").GetComponent <ARLoader>().android_order; // Debug.Log("Android order in fixed update of App manager:" + android_order); mBundleInstance = GameObject.Find("ImageTarget").GetComponent <ARLoader>().mBundleInstance; mAttached = GameObject.Find("ImageTarget").GetComponent <ARLoader>().mAttached; bundle = GameObject.Find("ImageTarget").GetComponent <ARLoader>().bundle; string temp = GameObject.Find("ImageTarget").GetComponent <ARLoader>().temp; sn = JsonUtility.FromJson <Restaurants>(temp); restaurant_id = GameObject.Find("ImageTarget").GetComponent <ARLoader>().restaurant_id; panId = GameObject.Find("ImageTarget").GetComponent <ARLoader>().category_id; if (Input.GetKey(KeyCode.Escape)) { if (bundle != null) { // Debug.Log("Testing in previous"); bundle.Unload(false); } // Debug.Log("Testing Inside focus-13"); Destroy(mBundleInstance); mBundleInstance.SetActive(false); //changed on 11/6/19 mAttached = false; AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); currentActivity = UnityPlayer.GetStatic <AndroidJavaObject>("currentActivity"); if (orders.Count > 0) { flag_order = 1; var a = new WrapperClass() { list = orders }; json = JsonUtility.ToJson(a); } else { flag_order = 0; json = "null"; } currentActivity.Call("onBackAndroid", flag_order, json, panId); } if (GameObject.Find("ImageTarget").GetComponent <ARLoader>().mBundleInstance != null) { mCurrentInstance = new ARItems(); } //Create a new ARItems object and assign it to CurrentInstance try { //Set item names & their customization options mCurrentAssetName = GameObject.Find("ImageTarget").GetComponent <ARLoader>().Assename.text; mCurrentInstance.name = mCurrentAssetName; mCurrentInstance.price = GameObject.Find("ImageTarget").GetComponent <ARLoader>().Price.text.Substring(1); // Debug.Log("Price:"+mCurrentInstance.price); mCurrentInstance.description = GameObject.Find("ImageTarget").GetComponent <ARLoader>().Description.text; // mCurrentInstance.Labels = sn.Restaurants[restaurant_id].Categories[panId].Items[GameObject.Find("ImageTarget").GetComponent<ARLoader>().currentAsset].Customisation; //mCurrentInstance.mOptions = new Options[mCurrentInstance.Labels.Length]; //for (int l = 0; l < mCurrentInstance.Labels.Length; l++) //{ // mCurrentInstance.mOptions[l] = new Options(); // if (mCurrentInstance.Labels[l] =="999") // { // mCurrentInstance.Labels[l] = "null"; // } // mCurrentInstance.mOptions[l].label = mCurrentInstance.Labels[l]; //} if (android_order.Equals("nodata") && orders.Count < 1) { mCurrentInstance.jain = 0; mCurrentInstance.quantity = 0; mCurrentInstance.instructions = " "; mCurrentInstance.hasCustomisation = false; } else { if (!orders.Contains(mCurrentInstance)) { mCurrentInstance.jain = 0; mCurrentInstance.quantity = 0; mCurrentInstance.instructions = " "; mCurrentInstance.hasCustomisation = false; } else { // Debug.Log("sdasddad"); mCurrentInstance.jain = orders[orders.IndexOf(mCurrentInstance)].jain; mCurrentInstance.quantity = orders[orders.IndexOf(mCurrentInstance)].quantity; mCurrentInstance.instructions = orders[orders.IndexOf(mCurrentInstance)].instructions; mCurrentInstance.hasCustomisation = orders[orders.IndexOf(mCurrentInstance)].hasCustomisation; //Debug.Log("Instruction: " + ""+orders[orders.IndexOf(mCurrentInstance)].instructions); } } mCurrentAssetName = GameObject.Find("ImageTarget").GetComponent <ARLoader>().Assename.text; mCurrentItemCount = "" + mCurrentInstance.quantity; } catch { } if (addBtn == null || remBtn == null) { shwBtn = GameObject.Find("ShowTable").GetComponent <Button>(); remBtn = GameObject.Find("RemoveItem").GetComponent <Button>(); addBtn = GameObject.Find("AddItem").GetComponent <Button>(); loadingpanel = GameObject.Find("LoadingPanel"); g = GameObject.Find("ViewOrders").GetComponent <Button>(); back = GameObject.Find("Back").GetComponent <Button>(); back.onClick.AddListener(loadPrevious); g.GetComponent <Button>().onClick.AddListener(loadScne); addBtn.onClick.AddListener(AddItem); remBtn.onClick.AddListener(RemoveItem); mcountText = shwBtn.GetComponentInChildren <Text>(); mcountText.text = mCurrentItemCount; shwBtn.GetComponent <Image>().sprite = mButtonMask[0]; addBtn.GetComponent <Image>().sprite = mButtonMask[1]; remBtn.GetComponent <Image>().sprite = mButtonMask[2]; } mcountText.text = mCurrentItemCount; // mCurrentItemCount = "" + orderItems.Count(x => x.Equals(mCurrentAssetName)); //int index = orders.FindIndex(x => x.Equals(mCurrentAssetName)); if (orders.Count < 1 && mActivated) { mActivated = false; if (g.gameObject.activeSelf) { g.gameObject.SetActive(false); } } //Else if order is not empty, show the View Orders button if (orders.Count > 0 && !mActivated) { mActivated = true; if (g != null) { g.gameObject.SetActive(true); } } } }
public static string GenerateWrapper(WrapperClass wrapperClass, Language language) { // Namespace CodeNamespace _namespace = new CodeNamespace(wrapperClass.Namespace); // Comments string comment = @"------------------------------------------------------------------------------" + Environment.NewLine + @" <auto-generated>" + Environment.NewLine + @" This code was generated by '.NET Wrapper Class Generator'" + Environment.NewLine + @" Product Version:" + Assembly.GetExecutingAssembly().GetName().Version + Environment.NewLine + Environment.NewLine + @" Changes to this file may cause incorrect behavior and will be lost if" + Environment.NewLine + @" the code is regenerated." + Environment.NewLine + @" </auto-generated>" + Environment.NewLine + @" ------------------------------------------------------------------------------"; _namespace.Comments.Add(new CodeCommentStatement(comment)); // Class CodeTypeDeclaration classDeclaration = new CodeTypeDeclaration(wrapperClass.ClassName); classDeclaration.IsPartial = wrapperClass.Partial; if (wrapperClass.Sealed) { classDeclaration.TypeAttributes |= TypeAttributes.Sealed; } _namespace.Types.Add(classDeclaration); // Initialization CodeParameterDeclarationExpressionCollection initializationParameters = null; CodeStatementCollection initiazationStatements = null; if (wrapperClass.Partial) { // Initialization method CodeMemberMethod initializer = new CodeMemberMethod(); classDeclaration.Members.Add(initializer); initializer.Name = "InitializeWrapper"; initializer.Attributes = MemberAttributes.Private; { comment = @"***************************************************************" + Environment.NewLine + @" This method should be called by the user-provided constructor!" + Environment.NewLine + @"***************************************************************"; initializer.Comments.Add(new CodeCommentStatement(comment)); } initializationParameters = initializer.Parameters; initiazationStatements = initializer.Statements; } else { // Constructor CodeConstructor constructor = new CodeConstructor(); classDeclaration.Members.Add(constructor); constructor.Attributes = MemberAttributes.Public; initializationParameters = constructor.Parameters; initiazationStatements = constructor.Statements; } // Iterate over the wrapped types foreach (WrappedType wrappedType in wrapperClass.WrappedTypes) { // Fields CodeMemberField field = new CodeMemberField(wrappedType.Type, wrappedType.FieldName); if (wrappedType.Acquisition != Acquisition.UserManaged) { classDeclaration.Members.Add(field); } string memberPrefix = string.Empty; if (wrappedType.PrefixMembers) { memberPrefix = wrappedType.FieldName; memberPrefix = memberPrefix.Substring(0, 1).ToUpper() + memberPrefix.Substring(1); } CodeFieldReferenceExpression fieldReference = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), wrappedType.FieldName); if (wrappedType.Acquisition == Acquisition.Construct) { // Instantiation CodeObjectCreateExpression instantiation = new CodeObjectCreateExpression(wrappedType.Type); CodeAssignStatement instanceAssignment = new CodeAssignStatement(fieldReference, instantiation); initiazationStatements.Add(instanceAssignment); } else if (wrappedType.Acquisition == Acquisition.Parameter) { // Pass as parameter initializationParameters.Add(new CodeParameterDeclarationExpression(wrappedType.Type, wrappedType.FieldName)); initiazationStatements.Add(new CodeAssignStatement(fieldReference, new CodeVariableReferenceExpression(wrappedType.FieldName))); } else if (wrappedType.Acquisition == Acquisition.Property) { // Set as property CodeMemberProperty property = new CodeMemberProperty(); property.Attributes = MemberAttributes.Public; property.HasGet = property.HasSet = true; property.Type = new CodeTypeReference(wrappedType.Type); property.Name = wrappedType.Type.Name; property.GetStatements.Add(new CodeMethodReturnStatement(fieldReference)); property.SetStatements.Add(new CodeAssignStatement(fieldReference, new CodeVariableReferenceExpression("value"))); classDeclaration.Members.Add(property); } // Methods foreach (WrappedMethod wrappedMethod in wrappedType.WrappedMethods) { // Method CodeMemberMethod method = new CodeMemberMethod(); classDeclaration.Members.Add(method); method.Name = memberPrefix + wrappedMethod.Method.Name; method.ReturnType = new CodeTypeReference(wrappedMethod.Method.ReturnType); Generator.SetMember(method, wrappedMethod); if (!string.IsNullOrEmpty(wrappedMethod.Interface)) { method.PrivateImplementationType = new CodeTypeReference(wrappedMethod.Interface); } // Parameters List <CodeExpression> arguments = Generator.SetParameters(method, wrappedMethod.Method.GetParameters()); // Statement CodeMethodInvokeExpression invocation = null; if (!wrappedMethod.Method.IsStatic) { invocation = new CodeMethodInvokeExpression(fieldReference, wrappedMethod.Method.Name, arguments.ToArray()); } else { invocation = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(wrappedType.Type), wrappedMethod.Method.Name, arguments.ToArray()); method.Attributes |= MemberAttributes.Static; } if (wrappedMethod.Method.ReturnType == typeof(void)) { method.Statements.Add(invocation); } else { method.Statements.Add(new CodeMethodReturnStatement(invocation)); } } // Properties foreach (WrappedProperty wrappedProperty in wrappedType.WrappedProperties) { // Property CodeMemberProperty property = new CodeMemberProperty(); classDeclaration.Members.Add(property); property.Name = memberPrefix + wrappedProperty.Property.Name; property.Type = new CodeTypeReference(wrappedProperty.Property.PropertyType); Generator.SetMember(property, wrappedProperty); if (!string.IsNullOrEmpty(wrappedProperty.Interface)) { property.PrivateImplementationType = new CodeTypeReference(wrappedProperty.Interface); } CodePropertyReferenceExpression invocation = null; if (true) // TODO: check if property is static { invocation = new CodePropertyReferenceExpression(fieldReference, wrappedProperty.Property.Name); } else { } // Get statement if (wrappedProperty.Get) { property.GetStatements.Add(new CodeMethodReturnStatement(invocation)); } // Set statement if (wrappedProperty.Set) { property.SetStatements.Add(new CodeAssignStatement(invocation, new CodeVariableReferenceExpression("value"))); } } // Events foreach (WrappedEvent wrappedEvent in wrappedType.WrappedEvents) { // Event MethodInfo eventDelegate = wrappedEvent.Event.EventHandlerType.GetMethod("Invoke"); CodeMemberEvent _event = new CodeMemberEvent(); classDeclaration.Members.Add(_event); _event.Name = memberPrefix + wrappedEvent.Event.Name; _event.Type = new CodeTypeReference(wrappedEvent.Event.EventHandlerType); Generator.SetMember(_event, wrappedEvent); if (!string.IsNullOrEmpty(wrappedEvent.Interface)) { _event.PrivateImplementationType = new CodeTypeReference(wrappedEvent.Interface); } // Event handler/raiser CodeMemberMethod eventHandler = new CodeMemberMethod(); classDeclaration.Members.Add(eventHandler); eventHandler.Name = string.Format("On{0}", _event.Name); eventHandler.ReturnType = new CodeTypeReference(eventDelegate.ReturnType); eventHandler.Attributes = MemberAttributes.Private; List <CodeExpression> arguments = Generator.SetParameters(eventHandler, eventDelegate.GetParameters()); CodeEventReferenceExpression eventReference = new CodeEventReferenceExpression(new CodeThisReferenceExpression(), _event.Name); CodeConditionStatement conditional = new CodeConditionStatement(); eventHandler.Statements.Add(conditional); conditional.Condition = new CodeBinaryOperatorExpression(eventReference, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null)); CodeDelegateInvokeExpression eventInvocation = new CodeDelegateInvokeExpression(eventReference, arguments.ToArray()); if (eventDelegate.ReturnType == typeof(void)) { conditional.TrueStatements.Add(eventInvocation); } else { conditional.TrueStatements.Add(new CodeMethodReturnStatement(eventInvocation)); } // Event registration CodeEventReferenceExpression wrappedEventReference = new CodeEventReferenceExpression(fieldReference, wrappedEvent.Event.Name); CodeMethodReferenceExpression eventRaiserReference = new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), eventHandler.Name); CodeAttachEventStatement eventRegistration = new CodeAttachEventStatement(wrappedEventReference, eventRaiserReference); initiazationStatements.Add(eventRegistration); } } // Generate the code StringWriter stringWriter = new StringWriter(); CodeDomProvider codeProvider = null; if (language == Language.CSharp) { codeProvider = new CSharpCodeProvider(); } else if (language == Language.VBNet) { codeProvider = new VBCodeProvider(); } else { throw new ArgumentException("Specified language is not supported: " + language); } CodeGeneratorOptions options = new CodeGeneratorOptions(); options.BracingStyle = "C"; codeProvider.GenerateCodeFromNamespace(_namespace, stringWriter, options); return(stringWriter.ToString()); }
public ActionResult DeltaEnt() { if (ind != 0) { return(View(eurost)); } else { ind++; //ViewBag.Message = "Your contact page."; DateTime date = DateTime.Today; DateTime debutProduit = new DateTime(2014, 12, 18); DateTime finProduit = new DateTime(2022, 12, 08); RecupData recup = new RecupData(new DateTime(2005, 12, 18), date); eurost.t = recup.DateToDouble(debutProduit, eurost.DateCourante, finProduit); List <String> Symbols = new List <String>(); Symbols.Add("^STOXX50E"); Symbols.Add("^GSPC"); Symbols.Add("^AXJO"); eurost.dataPoints_GSPC = new List <DataPoint>(); eurost.dataPoints_STOXX50E = new List <DataPoint>(); eurost.dataPoints_AXJO = new List <DataPoint>(); Symbols.Add("USDEUR=X"); Symbols.Add("AUDEUR=X"); eurost.dataPoints_EURUSD = new List <DataPoint>(); eurost.dataPoints_EURAUD = new List <DataPoint>(); eurost.dataPoints_trackingError = new List <DataPoint>(); eurost.dataPoints_PfC = new List <DataPoint>(); eurost.dataPoints_prix = new List <DataPoint>(); DateTime debut = new DateTime(2014, 12, 18); DateTime fin = DateTime.Today; recup.Fetch(); List <double> values = recup.getData("^GSPC").Values.ToList(); List <DateTime> dates = recup.getData("^GSPC").Keys.ToList(); List <double> values2 = recup.getData("^STOXX50E").Values.ToList(); List <DateTime> dates2 = recup.getData("^STOXX50E").Keys.ToList(); List <double> values3 = recup.getData("^AXJO").Values.ToList(); List <DateTime> dates3 = recup.getData("^AXJO").Keys.ToList(); List <double> values4 = recup.getData("USDEUR=X").Values.ToList(); List <DateTime> dates4 = recup.getData("USDEUR=X").Keys.ToList(); List <double> values5 = recup.getData("AUDEUR=X").Values.ToList(); List <DateTime> dates5 = recup.getData("AUDEUR=X").Keys.ToList(); for (int i = 0; i < values.Count; i++) { eurost.dataPoints_GSPC.Add(new DataPoint(recup.DateToDouble(debutProduit, dates[i], finProduit) + 2014, values[i])); } for (int i = 0; i < values2.Count; i++) { eurost.dataPoints_STOXX50E.Add(new DataPoint(recup.DateToDouble(debutProduit, dates2[i], finProduit) + 2014, values2[i])); } for (int i = 0; i < values3.Count; i++) { eurost.dataPoints_AXJO.Add(new DataPoint(recup.DateToDouble(debutProduit, dates3[i], finProduit) + 2014, values3[i])); } for (int i = 0; i < values4.Count; i++) { eurost.dataPoints_EURUSD.Add(new DataPoint(recup.DateToDouble(debutProduit, dates4[i], finProduit) + 2014, values4[i])); } for (int i = 0; i < values5.Count; i++) { eurost.dataPoints_EURAUD.Add(new DataPoint(recup.DateToDouble(debutProduit, dates5[i], finProduit) + 2014, values5[i])); } List <string> symbols = recup.getSymbols(); Dictionary <DateTime, double> dico = recup.getData(symbols[0]); eurost.covLogR = recup.exportCov(new DateTime(2004, 12, 18), debutProduit); eurost.pastDelta = recup.exportPast(eurost.t, 7, debutProduit, finProduit); //eurost.pastPrice = recup.exportPast(eurost.t, 182, debutProduit, finProduit); eurost.pastPrice = recup.exportPastSemestre(eurost.t, debutProduit, finProduit); double r_eu = 0.0026; double r_aus = 0.025; double r_us = 0.00025; int size = 5; double r = r_eu; double[] spots = new double[5]; for (int i = 0; i < 5; i++) { spots[i] = eurost.pastPrice[0, i]; } double[] trends = new double[5]; trends[0] = r_eu; trends[1] = r_us - eurost.covLogR[1, 3]; trends[2] = r_aus - eurost.covLogR[2, 4]; trends[3] = r_eu - r_us; trends[4] = r_eu - r_aus; double[] lambdas = new double[5]; for (int i = 0; i < 5; i++) { lambdas[i] = 0.05; } WrapperClass wr1 = new WrapperClass(size, r, eurost.covLogR, spots, trends, 0.1, eurost.nb_iterations, 100, 8.0, 16, lambdas); eurost.wc = wr1; double H = 416; eurost.deltaEnt = wr1.getDeltaEurostral(eurost.pastPrice, eurost.t, H); //wr1.getPriceEurostral(eurost.t, pastPrice); eurost.prixEnt = wr1.getPriceEurostral(eurost.t, eurost.pastPrice); /*DateTime debutBackTest = new DateTime(2010, 03, 22); * DateTime finBacktest = new DateTime(2018, 03, 22); * double t0 = recup.DateToDouble(debutBackTest, finBacktest, finBacktest); * double[,] donneesHistoriques = recup.exportPast(t0, 7, debutBackTest, finBacktest); * eurost.PL=wr1.getPLEurostral(donneesHistoriques, H);*/ // eurost.pastPrice = recup.exportPast(eurost.t, 182, debutProduit, finProduit); double[] track = new double[eurost.pastDelta.GetLength(0) - 1]; double[] pp = new double[eurost.pastDelta.GetLength(0)]; double[] pock = new double[eurost.pastDelta.GetLength(0)]; double[] v = new double[eurost.pastDelta.GetLength(0)]; wr1.trackingError(eurost.pastDelta, eurost.pastPrice, eurost.t, H, pp, pock, track, v, eurost.pastDelta.GetLength(0), eurost.pastPrice.GetLength(0)); eurost.PandL = track; eurost.pock = pock; eurost.pp = pp; eurost.v = v[eurost.pastDelta.GetLength(0) - 1]; int m = eurost.pastDelta.GetLength(0); eurost.stock = new Stock(recup); eurost.stock.Add(0.0, wr1.getDeltaEurostral(recup.exportPast(0, 182, debutProduit, finProduit), 0.0, H), pp[0], 0.0, v[0]); for (int i = 1; i < m - 1; i++) { eurost.stock.Add(i * 8.0 / H, wr1.getDeltaEurostral(recup.exportPast(i * 8.0 / H, 182, debutProduit, finProduit), i * 8.0 / H, H), pp[i], track[i - 1], v[i]); } eurost.stock.Add(eurost.t, wr1.getDeltaEurostral(recup.exportPast(eurost.t, 182, debutProduit, finProduit), eurost.t, H), pp[m - 1], track[m - 2], v[m - 1]); eurost.stock.SaveToCSV(); eurost.deltaD = eurost.stock.getPreDelta(eurost.t); //Ajout for (int i = 0; i < 5; i++) { eurost.prixActifs[i] = eurost.pastPrice[(eurost.pastPrice.GetLength(0)) - 1, i]; } eurost.prixActifs[1] = eurost.prixActifs[1] * eurost.prixActifs[3]; eurost.prixActifs[2] = eurost.prixActifs[2] * eurost.prixActifs[4]; eurost.prixActifs[3] = eurost.prixActifs[3] * Math.Exp(-r_us * (8.0 - eurost.t)); eurost.prixActifs[4] = eurost.prixActifs[4] * Math.Exp(-r_aus * (8.0 - eurost.t)); for (int i = 0; i < 5; i++) { eurost.pocketD += eurost.prixActifs[i] * eurost.deltaD[i]; } eurost.pocketD += eurost.stock.getPreCash(eurost.t) * Math.Exp(eurost.t - eurost.stock.findPre(eurost.t)); eurost.dataPoints_trackingError.Add(new DataPoint(0, 0)); for (int j = 1; j < track.Count <double>(); j++) { eurost.dataPoints_trackingError.Add(new DataPoint(j, 100 * track[j - 1] / pp[j - 1])); } for (int k = 0; k < pock.Count <double>(); k++) { eurost.dataPoints_PfC.Add(new DataPoint(k, eurost.pock[k])); } for (int k = 0; k < pp.Count <double>(); k++) { eurost.dataPoints_prix.Add(new DataPoint(k, eurost.pp[k])); } ViewData["price"] = eurost.prixEnt; //return RedirectToAction("PrixEnt"); return(View(eurost)); } }
static void Main(string[] args) { string gg = "66"; // A way to make Main async. MainAsync().Wait(); // Thread sample: Thread thread1 = new Thread(new ThreadStart(ThreadMethod)); Thread thread2 = new Thread(new ParameterizedThreadStart(ThreadMethodI)); thread1.Start(); thread2.Start(1); thread1.Join(); thread2.Join(); // Delegate usage sample: OwnDelegate a = IntMethod1; a += IntMethod2; a += (x => x.Length + 1); int b = a(gg); // Task usage sample: Task <int> taskInt1 = new Task <int>(WrapperMethod, gg); taskInt1.Start(); WrapperClass <string, int> wrapperClass = new WrapperClass <string, int>(IntMethod2, gg); Task <int> taskInt2 = Task.Run(wrapperClass.Call); Task <int> abc = Task.Run(() => IntMethod1(gg)); // async method call from sync code: Task <int> innyTask = IntMethodAsync(1); // async lambda: var test = new Func <Task <int> >(async() => await IntMethodAsync(gg)); Task.WaitAll(taskInt1, innyTask); // btw: Nullable int?nullableInt = null; nullableInt = 6; if (nullableInt != null) { nullableInt++; } // LINQ var list = new List <int> { 1, 2, 3, 4 }; var aa = list.Select(x => x + 3); aa.Where(x => x != null); var cc = list.Aggregate((x, y) => x + y); Console.WriteLine(cc); int WrapperMethod(object state) { return(IntMethod1(gg)); } }