public static OptionManager GetInstance() { if (instance == null) { instance = new OptionManager(); } return instance; }
public void RebalancementVanillaCallATM() { double ratio = 0; double compteur = 0; for (int i = 0; i < 200; i++) { DateTime date = DateTime.Now; PricingLibrary.FinancialProducts.Share Action = new PricingLibrary.FinancialProducts.Share("test", "01"); PricingLibrary.FinancialProducts.Share[] tabAction = { Action }; PricingLibrary.FinancialProducts.VanillaCall Call = new PricingLibrary.FinancialProducts.VanillaCall("test", tabAction, date, 10.0); DateTime dateStart = new DateTime(2014, 9, 9, 0, 0, 0); OptionManager optionCompute = new OptionManager(Call, dateStart, date, 30, true); ComputeResults.computeResults(optionCompute); double firstValue = optionCompute.HedgingPortfolioValue[0]; double lastValue = optionCompute.HedgingPortfolioValue[optionCompute.HedgingPortfolioValue.Count - 1]; double payoff = optionCompute.Payoff[optionCompute.Payoff.Count - 1]; double ratioTmp = Math.Abs(payoff - lastValue) / firstValue; ratio += ratioTmp; compteur += 1; } ratio = ratio / compteur; Console.WriteLine(ratio); }
public void TestVolatilitiesAndSpotPrices() { DateTime date = new DateTime(2014, 6, 1, 0, 0, 0); DateTime date1 = new DateTime(2014, 1, 1, 0, 0, 0); PricingLibrary.FinancialProducts.Share Action = new PricingLibrary.FinancialProducts.Share("test", "ALO FP"); PricingLibrary.FinancialProducts.Share Action2 = new PricingLibrary.FinancialProducts.Share("test2", "BNP FP"); PricingLibrary.FinancialProducts.Share[] mesActions = new PricingLibrary.FinancialProducts.Share[2]; mesActions[0] = Action; mesActions[1] = Action2; double[] weight = { 0.1, 0.9 }; PricingLibrary.FinancialProducts.BasketOption myBasketOption = new PricingLibrary.FinancialProducts.BasketOption("test", mesActions, weight, date, 30.0); OptionManager myOptionManager = new OptionManager(myBasketOption, date1, date, 20, false); Console.WriteLine(" Premiers resultats : "); myOptionManager.HedgingPortfolioValue.ForEach(data => Console.WriteLine(data)); Console.WriteLine(" \n "); myOptionManager.Payoff.ForEach(data => Console.WriteLine(data)); Console.WriteLine(" \n "); ComputeResults.computeResults(myOptionManager); Console.WriteLine(" Fin : \n"); Console.WriteLine("\n"); myOptionManager.HedgingPortfolioValue.ForEach(data => Console.WriteLine(data)); Console.WriteLine("\n"); //myResults.OptionPrice.ForEach(data => Console.WriteLine(data)); Console.WriteLine(" Option price \n"); myOptionManager.OptionPrice.ForEach(data => Console.WriteLine(data)); Console.WriteLine(" \n "); Console.WriteLine(" \n "); myOptionManager.dateTime.ForEach(data => Console.WriteLine(data)); }
/*** getCorrelationMatrix ***/ /* Function that computes correlation matrix for a given date * with a fixed estimation window /* @date : date at which we want to get volatility * @option : class used for the calcul * @Return : volatility at this date */ public static double[,] getCorrelationMatrix(DateTime date, OptionManager option) { // correlation matrix not symetrical and defined positive if (option.TestWindow < option.NbShare) { throw new Exception("ERROR : getCorrelationMatrix encountered a problem: Estimation window too small"); } System.Collections.Generic.List<PricingLibrary.Utilities.MarketDataFeed.DataFeed> histo = option.MyHisto.Data.Where(data => (data.Date >= date.AddDays(-option.TestWindow) && data.Date <= date)).ToList(); histo.OrderBy(data => data.Date); int dimTemps = histo.Count; // correlation matrix not symetrical and defined positive if (dimTemps < option.NbShare) { throw new Exception("ERROR : getCorrelationMatrix encountered a problem: Estimation window too small"); } double[,] shareValuesForVolatilityEstimation = new double[dimTemps, option.NbShare]; int temps = 0; int asset = 0; foreach (PricingLibrary.Utilities.MarketDataFeed.DataFeed data in histo) { asset = 0; foreach (KeyValuePair<string, decimal> keyValue in data.PriceList) { shareValuesForVolatilityEstimation[temps, asset] = (double)keyValue.Value; asset++; } temps++; } return ComputeEstimators.computeCorrelationMatrix(shareValuesForVolatilityEstimation); }
void Awake() { if (instance != null) Destroy(this.gameObject); else { instance = this; DontDestroyOnLoad(this); } }
public RouteControl_TrainList_Page(Route _r) { try { InitializeComponent(); AddControl(this); IconImg = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "ico_ways.png", 5, 7, 1, 6)); Title = TextManager.Get().Text("routecontrol"); r = _r; imgAdd = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_add.png", 5, 7, 1, 6)); imgAddSel = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_add_sel.png", 5, 7, 1, 6)); imgRemove = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_remove.png", 5, 7, 1, 6)); imgRemoveSel = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_remove_sel.png", 5, 7, 1, 6)); lbTitle.Font = new Font(RTCore.Environment.Font, 30); lbTitle.Text = TextManager.Get().Text("train"); lbTitle.ForeColor = ResourceManager.Get("routecontrol.train.title"); lbAccept.Font = new Font(RTCore.Environment.Font, 20); lbAccept.Text = TextManager.Get().Text("accept"); lbAccept.ForeColor = ResourceManager.Get("routecontrol.train.accept.unsel"); lbAccept.SelColor = ResourceManager.Get("routecontrol.train.accept.sel"); lbAccept.Location = new Point(Width - 25 - lbAccept.Width, 553); panListBack.BackColor = ResourceManager.Get("routecontrol.train.list.background"); picAdd.Image = imgAdd; picAdd.MouseEnter += delegate { picAdd.Image = imgAddSel; }; picAdd.MouseLeave += delegate { picAdd.Image = imgAdd; }; picRemove.Image = imgRemove; picRemove.MouseEnter += delegate { picRemove.Image = imgRemoveSel; }; picRemove.MouseLeave += delegate { picRemove.Image = imgRemove; }; ListDraw(); } catch (Exception ex) { RTCore.Environment.ReportError(ex, AccessManager.AccessKey); } }
public void TestSearchOptionInvalidId(InvalidOptionId optionId) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["id"] = InvalidIdMapper[optionId], }; var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidValue).Or.ErrorCode((int)ResultCode.ValueRangeExceeded), $"Still able to search option with id = {optionId.ToString()}"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private static synchronized void loadOptions() throws org.maltparser.core.exception.MaltChainedException private static void loadOptions() { lock (typeof(ConcurrentMaltParserService)) { if (!OptionManager.instance().hasOptions()) { OptionManager.instance().loadOptionDescriptionFile(); OptionManager.instance().generateMaps(); } } }
public void TestSearchOptionDuplicateParameter(OptionSearchParameter parameter) { OptionManager optionHandler = new OptionManager(); List <KeyValuePair <string, string> > requestDic = new List <KeyValuePair <string, string> >(); requestDic.Add(new KeyValuePair <string, string>(parameter.ToString().ToLower(), ParameterValidValueMapper[parameter])); requestDic.Add(new KeyValuePair <string, string>(parameter.ToString().ToLower(), ParameterValidValueMapper[parameter])); var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidValue), $"Still able to search option with duplicate parameter = {parameter.ToString()}"); }
public void WriteRequestWithAnotherParameter(object value) { baseParentParameters["abcxyz"] = value; var options = new List <Dictionary <string, object> >(); options.Add(baseParentParameters); var optionHandler = new OptionManager(); var response = optionHandler.WriteOptions(options); Common.AssertWriteUnsuccessOption(response, ResultCode.InvalidParameter); }
public RegionInfoPage(RTCore.Region r, City c = null) { try { InitializeComponent(); AddControl(this); reg = r; city = c; Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("%NAME%", reg.Name); Title = TextManager.Get().Text("regioninfo", true, data); IconImg = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "ico_timetable.png", 5, 7, 1, 6)); lbTitle.Text = reg.Name; lbTitle.Font = new Font(RTCore.Environment.Font, 30); lbTitle.ForeColor = ResourceManager.Get("regioninfo.title"); ResetRegInfo(); lbRegInfo.Font = new Font(RTCore.Environment.Font, 13); lbRegInfo.Location = new Point(lbTitle.Location.X, lbTitle.Location.Y + lbTitle.Height + 2); lbRegInfo.ForeColor = ResourceManager.Get("regioninfo.reginfo"); cbCitys.Name = "cbCitys"; cbCitys.Font = new Font(RTCore.Environment.Font, 20); cbCitys.DropDownStyle = ComboBoxStyle.DropDownList; cbCitys.Location = new Point(lbRegInfo.Location.X, lbRegInfo.Location.Y + lbRegInfo.Height + 6); foreach (var it in reg.Childs) { cbCitys.Items.Add(it.Name); } cbCitys.SelectedIndex = 0; cbCitys.Size = new Size(Width - (cbCitys.Location.X * 2), cbCitys.Height); cbCitys.SelectedIndexChanged += delegate { ResetCityInfo(); }; if (c != null) { cbCitys.SelectedIndex = reg.Childs.IndexOf(c); } Controls.Add(cbCitys); ResetCityInfo(); lbCityInfo.Font = new Font(RTCore.Environment.Font, 12); lbCityInfo.Location = new Point(cbCitys.Location.X, cbCitys.Location.Y + cbCitys.Height + 10); } catch (Exception ex) { RTCore.Environment.ReportError(ex, AccessManager.AccessKey); } }
public void NameCase_valid_Test(string nameCase) { var options = new Options { Lang = "cs", NameCase = nameCase }; var om = new OptionManager(options); Assert.That(options.Errors, Is.Empty); }
public void WriteParametersWithValues(string parameterName, Values inputType) { var options = new List <Dictionary <string, object> >(); options.Add(GetParameters(parameterName, inputType)); var optionHandler = new OptionManager(); var response = optionHandler.WriteOptions(options, ReplaceParameter, parameterName); Common.AssertWriteUnsuccessOption(response, ResultCode.TooManyParameters); }
public void LanguageTog(bool value) { if (value) { OptionManager.SetIntPreference("language", 1); } else { OptionManager.SetIntPreference("language", 0); } }
static Game() { GameObject game = SafeFind("_app"); m_players = (PlayerManager)SafeComponent(game, "PlayerManager"); m_keybinds = (KeybindManager)SafeComponent(game, "KeybindManager"); m_options = (OptionManager)SafeComponent(game, "OptionManager"); m_audio = (AudioManager)SafeComponent(game, "AudioManager"); m_leaderNetHandler = (LeaderboardNetworkHandler)SafeComponent(game, "LeaderboardNetworkHandler"); m_projPool = (ProjectilePooler)SafeComponent(SafeFind("ProjectilePooler"), "ProjectilePooler"); }
private void Awake() { if (instance != null) { Destroy(this.gameObject); } else { instance = this; } } //--------------인스턴스화를 위함 ----
public void TestSearchOptionInvalidType(InvalidOptionType optionType) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["type"] = InvalidTypeMapper[optionType], }; var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidValue), $"Still able to search option with type = {optionType.ToString()}"); }
public void TestSearchOptionInvalidFieldOrder(ValidOptionField optionField, InvalidOptionOrder optionOrder) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["order"] = $"{ValidFieldMapper[optionField]}:{InvalidOrderMapper[optionOrder]}", }; var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidValue), $"Still able to search option with both field = {optionField.ToString()} and order = {optionOrder.ToString()}"); }
private void Update() { if (Input.GetKeyDown(KeyCode.Escape) && PauseBtn.isPause && !OptionManager.isOption && !AlertManager.isAlert) { ResumeGame(); } else if (Input.GetKeyDown(KeyCode.Escape) && OptionManager.isOption) { OptionManager.TurnOffOptionMenu(); } }
public static List <OptionSearchResponse> GetOptionPhaseList(List <string> optionList, int level) { var phaseList = new List <OptionSearchResponse>(); var optionMng = new OptionManager(); foreach (var optionAlias in optionList) { var result = optionMng.SearchOption(optionAlias, level); phaseList.Add(result.Result.Single()); } return(phaseList); }
public void TestSearchOptionId(ValidOptionId optionId) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>(RequestOptionSearch); ValidIdMapper[optionId](requestDic, OptionCreator.Data.Id); var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.SuccessfulResponse()); PrAssert.That(response.Result, PrIs.Not.Null.And.Not.Empty); PrAssert.That(response.Result.Select(r => r.Id), Has.Exactly(1).EqualTo(OptionCreator.Data.Id), "The expected option cannot be found!"); }
public void TestSearchOptionFieldOrder(ValidOptionField optionField, string optionOrder) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["columns"] = ValidFieldMapper[optionField], ["order"] = ValidFieldMapper[optionField] + ":" + optionOrder, }; var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.SuccessfulResponse()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static boolean canUseConcurrentEngine(int optionContainer) throws org.maltparser.core.exception.MaltChainedException public static bool canUseConcurrentEngine(int optionContainer) { if (!OptionManager.instance().getOptionValueString(optionContainer, "config", "flowchart").Equals("parse")) { return(false); } if (OptionManager.instance().getOptionValueString(optionContainer, "config", "url").Length > 0) { return(false); } return(true); }
private async void Page_Loading(FrameworkElement sender, object args) { var obj = App.Current as App; StudentNumberBox.Text = obj.studentNumber; OptionManager.http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", obj.AccessToken); await OptionManager.GetActiveOptions(Options); YearTermManager.http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", obj.AccessToken); defaultYearTerm = await YearTermManager.DefaultYearTerm(defaultYearTerm); }
IEnumerator InitOptionManager() { GameObject go = new GameObject("OptionManager"); OptionManager option = go.AddComponent <OptionManager>(); DontDestroyOnLoad(go); while (OptionManager.isInitialized == false) { yield return(null); } }
public void TestSearchOptionAliasInvalidSelf(ValidOptionAlias optionAlias, InvalidOptionSelf optionSelf) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["alias"] = ValidAliasMapper[optionAlias], ["self"] = InvalidSelfMapper[optionSelf], }; var response = optionHandler.SearchOption(requestDic); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidValue).Or.ErrorCode((int)ResultCode.ValueRangeExceeded), $"Still able to search option with both alias = {optionAlias.ToString()} and self = {optionSelf.ToString()}"); }
private void Update() { if (clicked && timer <= 0) { OptionManager.SetIntPreference(_missionBox.nextSceneName, 0); SceneManager.LoadScene(_missionBox.nextSceneName); } else if (clicked && timer > 0) { timer -= Time.deltaTime; } }
void Start() { option_manager_script = FindObjectOfType <OptionManager>(); _brightness_ctrler_script = _bright_slider.gameObject.GetComponent <BrightnessController>(); //InitSliderValue(); //GameMgr 스크립트로 옮김 //songManager_script = FindObjectOfType<SoundManger>(); gameMgr_script = GameObject.FindObjectOfType <GameMgr>(); }
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (1 == e.ColumnIndex) { if (e.Value == null) { return; } e.Value = OptionManager.ObjToString(e.Value); } }
void Awake() { if (instance != null) { Destroy(this.gameObject); } else { instance = this; DontDestroyOnLoad(this); } }
private async void AddOption_Click(object sender, RoutedEventArgs e) { if (OptionTitleWillBeAdded.Text != "") { bool active = ((string)OptionActiveWillBeAdded.SelectionBoxItem == "Yes") ? true : false; string title = OptionTitleWillBeAdded.Text; var obj = new { Title = title, IsActive = active }; await OptionManager.AddOption(new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"), Options); Frame.Navigate(typeof(ManageOptionPage)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification) { base.initialize(flowChartinstance, chartItemSpecification); foreach (string key in chartItemSpecification.ChartItemAttributes.Keys) { if (key.Equals("id")) { idName = chartItemSpecification.ChartItemAttributes[key]; } else if (key.Equals("target")) { targetName = chartItemSpecification.ChartItemAttributes[key]; } else if (key.Equals("optiongroup")) { optiongroupName = chartItemSpecification.ChartItemAttributes[key]; } } if (ReferenceEquals(idName, null)) { idName = getChartElement("read").Attributes.get("id").DefaultValue; } else if (ReferenceEquals(targetName, null)) { targetName = getChartElement("read").Attributes.get("target").DefaultValue; } else if (ReferenceEquals(optiongroupName, null)) { optiongroupName = getChartElement("read").Attributes.get("optiongroup").DefaultValue; } InputFormatName = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "format").ToString(); InputFileName = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "infile").ToString(); InputCharSet = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "charset").ToString(); ReaderOptions = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "reader_options").ToString(); if (OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "iterations") != null) { Iterations = (int?)OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "iterations").Value; } else { Iterations = 1; } SyntaxGraphReaderClass = (Type)OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "reader"); NullValueStrategy = OptionManager.instance().getOptionValue(OptionContainerIndex, "singlemalt", "null_value").ToString(); initInput(NullValueStrategy); initReader(SyntaxGraphReaderClass, InputFileName, InputCharSet, ReaderOptions, iterations); }
public static Dictionary <int, List <int> > GetOptionInfos(string alias) { var handler = new OptionManager(); alias = string.IsNullOrEmpty(alias) ? GetOptionsAlias()[new Random().Next(GetOptionsAlias().Count())] : alias; var result = handler.SearchOption(alias); PrAssume.That(result, PrIs.SuccessfulResponse(), "Fail to search option"); return(new Dictionary <int, List <int> > { [result.Result.FirstOrDefault().Id] = result.Result.FirstOrDefault().Children.Select(x => x.Id).ToList() }); }
private void Awake() { if (Instance != null) { Destroy(gameObject); return; } Instance = this; optionCanvas = GameObject.Find("OptionCanvas"); optionCanvas.SetActive(false); DontDestroyOnLoad(gameObject); }
// Use this for initialization void Start() { options = OptionManager.GetInstance(); if (options.snowModeActivated) { Debug.Log("Plop"); floor.collider.material = (PhysicMaterial)Resources.Load("Physic Materials/Ice"); } if (options.windModeActivated) { // objects = GameObject.FindObjectsOfType(typeof(MonoBehaviour)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static void loadAllMalt04Tagset(org.maltparser.core.options.OptionManager om, int containerIndex, org.maltparser.core.symbol.SymbolTableHandler symbolTableHandler, org.apache.log4j.Logger logger) throws org.maltparser.core.exception.MaltChainedException public static void loadAllMalt04Tagset(OptionManager om, int containerIndex, SymbolTableHandler symbolTableHandler, Logger logger) { string malt04Posset = om.getOptionValue(containerIndex, "malt0.4", "posset").ToString(); string malt04Cposset = om.getOptionValue(containerIndex, "malt0.4", "cposset").ToString(); string malt04Depset = om.getOptionValue(containerIndex, "malt0.4", "depset").ToString(); string nullValueStrategy = om.getOptionValue(containerIndex, "singlemalt", "null_value").ToString(); // String rootLabels = om.getOptionValue(containerIndex, "graph", "root_label").toString(); string inputCharSet = om.getOptionValue(containerIndex, "input", "charset").ToString(); loadMalt04Posset(malt04Posset, inputCharSet, nullValueStrategy, symbolTableHandler, logger); loadMalt04Cposset(malt04Cposset, inputCharSet, nullValueStrategy, symbolTableHandler, logger); loadMalt04Depset(malt04Depset, inputCharSet, nullValueStrategy, symbolTableHandler, logger); }
/*** getSpotPrices ***/ /* Function that return the Spot prices for a given date * with a fixed estimation window /* @date : date at which we want to get the spot prices * @Return : spotPrices at this date */ public static double[] getSpotPrices(DateTime date, OptionManager option) { // Verification du correct appel de la methode if (!option.MyHisto.Data.Where(data => data.Date == date).Any()) { throw new Exception("Erreur dans l'appel de GetSpotPrice avec une date a laquelle il n'y a pas de spotPrice"); } double[] spotPrices = new double[option.NbShare]; option.MyHisto.Data.Find(data => data.Date == date).PriceList.OrderBy(dataFeed => dataFeed.Key); int i = 0; foreach (KeyValuePair<string, decimal> data in option.MyHisto.Data.Find(data => data.Date == date).PriceList) { spotPrices[i] = (double)data.Value; i++; } return spotPrices; }
/*** getVolatility ***/ /* Function that computes volatility for a given date * with a fixed estimation window /* @date : date at which we want to get volatility * @option : class used for the calcul * @Return : volatility at this date */ public static double[] getVolatilities(DateTime date, OptionManager option) { System.Collections.Generic.List<PricingLibrary.Utilities.MarketDataFeed.DataFeed> histo = option.MyHisto.Data.Where(data => (data.Date >= date.AddDays(-option.TestWindow) && data.Date <= date)).ToList(); histo.OrderBy(data => data.Date); int dimTemps = histo.Count; double[,] shareValuesForVolatilityEstimation = new double[dimTemps, option.NbShare]; int temps = 0; int asset = 0; foreach (PricingLibrary.Utilities.MarketDataFeed.DataFeed data in histo) { asset = 0; foreach (KeyValuePair<string, decimal> keyValue in data.PriceList) { shareValuesForVolatilityEstimation[temps, asset] = (double)keyValue.Value; asset++; } temps++; } return ComputeEstimators.computeVolatilities(ComputeEstimators.logReturn(shareValuesForVolatilityEstimation), option.Simulated); }
public static void computeResults(OptionManager option) { double[] spotPrice = null; double[] volatility = null; double[,] matriceCorrelation = null; System.Collections.Generic.List<PricingLibrary.Utilities.MarketDataFeed.DataFeed> histo = option.MyHisto.Data.Where(data => (data.Date >= option.StartDate && data.Date <= option.MaturityDate)).ToList(); option.HedgingPortfolioValue.Clear(); option.Payoff.Clear(); option.dateTime.Clear(); option.OptionPrice.Clear(); foreach (PricingLibrary.Utilities.MarketDataFeed.DataFeed data in histo) { spotPrice = Estimators.getSpotPrices(data.Date, option); volatility = Estimators.getVolatilities(data.Date, option); if (option.MyPortfolio.Product is PricingLibrary.FinancialProducts.VanillaCall) { option.MyPortfolio.updatePortfolioValue(spotPrice, data.Date, volatility,option.Simulated); } else if (option.MyPortfolio.Product is PricingLibrary.FinancialProducts.BasketOption) { matriceCorrelation = Estimators.getCorrelationMatrix(data.Date, option); option.MyPortfolio.updatePortfolioValue(spotPrice, data.Date, volatility,option.Simulated, matriceCorrelation); } else { throw new NotImplementedException(); } option.HedgingPortfolioValue.Add(option.MyPortfolio.portfolioValue); option.Payoff.Add(option.MyPortfolio.Product.GetPayoff(data.PriceList)); option.dateTime.Add(data.Date); option.OptionPrice.Add(option.MyPortfolio.ComputeAttribut.priceProduct(option.MyPortfolio.Product, data.Date, spotPrice, volatility, option.Simulated, matriceCorrelation).Price); } }
public void RebalancementBasket5Sj() { double ratio = 0; double compteur = 0; for (int i = 0; i < 200; i++) { DateTime date = DateTime.Now; PricingLibrary.FinancialProducts.Share Action = new PricingLibrary.FinancialProducts.Share("test", "01"); PricingLibrary.FinancialProducts.Share Action1 = new PricingLibrary.FinancialProducts.Share("test1", "02"); PricingLibrary.FinancialProducts.Share Action2 = new PricingLibrary.FinancialProducts.Share("test1", "03"); PricingLibrary.FinancialProducts.Share Action3 = new PricingLibrary.FinancialProducts.Share("test1", "04"); PricingLibrary.FinancialProducts.Share Action4 = new PricingLibrary.FinancialProducts.Share("test1", "05"); PricingLibrary.FinancialProducts.Share[] tabAction = { Action, Action1, Action2, Action3,Action4 }; double[] weightTab = new double[] {0.2,0.2,0.2,0.2,0.2}; PricingLibrary.FinancialProducts.BasketOption Basket = new PricingLibrary.FinancialProducts.BasketOption("basket", tabAction, weightTab, date, 8); DateTime dateStart = new DateTime(2015, 2, 10, 0, 0, 0); OptionManager optionCompute = new OptionManager(Basket, dateStart, date, 30, true); ComputeResults.computeResults(optionCompute); double firstValue = optionCompute.HedgingPortfolioValue[0]; double lastValue = optionCompute.HedgingPortfolioValue[optionCompute.HedgingPortfolioValue.Count - 1]; double payoff = optionCompute.Payoff[optionCompute.Payoff.Count - 1]; double ratioTmp = Math.Abs(payoff - lastValue) / firstValue; ratio += ratioTmp; compteur += 1; } ratio = ratio / compteur; Console.WriteLine(ratio); }
public void RebalancementBasket1SJ_S8() { double ratio = 0; double compteur = 0; for (int i = 0; i < 200; i++) { DateTime date = DateTime.Now; PricingLibrary.FinancialProducts.Share Action = new PricingLibrary.FinancialProducts.Share("ALO FP", "ALO FP"); PricingLibrary.FinancialProducts.Share[] tabAction = { Action }; double[] weightTab = new double[] {1.0}; PricingLibrary.FinancialProducts.BasketOption Basket = new PricingLibrary.FinancialProducts.BasketOption("BASKET", tabAction, weightTab, date, 9.0); DateTime dateStart = new DateTime(2014, 10, 9, 0, 0, 0); OptionManager optionCompute = new OptionManager(Basket, dateStart, date, 30, true); ComputeResults.computeResults(optionCompute); double firstValue = optionCompute.HedgingPortfolioValue[0]; double lastValue = optionCompute.HedgingPortfolioValue[optionCompute.HedgingPortfolioValue.Count - 1]; double payoff = optionCompute.Payoff[optionCompute.Payoff.Count - 1]; double ratioTmp = Math.Abs(payoff - lastValue) / firstValue; ratio += ratioTmp; compteur += 1; } ratio = ratio / compteur; Console.WriteLine(ratio); }
private void ExtractComponents() { // On test les différents paramètres, si ils ne sont pas bons on fait apparaitre un pop-up double sommePoids = 0.0; int nbAction = 0; foreach (var comp in ComponentInfoList) { if (comp.IsSelected) { if (comp.Poids < 0.0) { System.Windows.Forms.MessageBox.Show("ERREUR : Les poids doivent être positif"); return; } sommePoids += comp.Poids; nbAction += 1; } } if (sommePoids != 1.0) { System.Windows.Forms.MessageBox.Show("ERREUR : La somme des poids doit être égale à 1 "); return; } PricingLibrary.FinancialProducts.Share[] tabShare = new PricingLibrary.FinancialProducts.Share[nbAction]; double[] tabWeight = new double[nbAction]; if (tailleFenetre < 0) { System.Windows.Forms.MessageBox.Show("ERREUR : La taille de la fenetre doit être superieure à 0 "); return; } if (maturite.Subtract(dateDebut).Days < tailleFenetre) { System.Windows.Forms.MessageBox.Show("ERREUR : La taille de la fenetre ne doit pas être plus grande que l'écart entre la maturite et la date de début "); return; } if (tailleFenetre < nbAction) { System.Windows.Forms.MessageBox.Show("ERREUR : La taille de la fenetre doit être un entier au minimum égale au nombre de sous jacent "); return; } if ((1 < nbAction)&&(typeOption.Equals("Vanilla Call"))) { System.Windows.Forms.MessageBox.Show("ERREUR : Un Vanilla Call ne peut avoir qu'un sous-jacent "); return; } // On utilise maintenant nb action comme index nbAction = 0; foreach (var comp in ComponentInfoList) { if (comp.IsSelected) { PricingLibrary.FinancialProducts.Share share = new PricingLibrary.FinancialProducts.Share(comp.Name, comp.Name); tabShare[nbAction] = share; tabWeight[nbAction] = comp.Poids; nbAction += 1; } } if (strikePrice < 0) { System.Windows.Forms.MessageBox.Show("ERREUR : Le strike doit être positif"); return; } TimeSpan diff = maturite.Subtract(dateDebut); if (diff.Days < 0) { System.Windows.Forms.MessageBox.Show("ERREUR : La date de debut doit etre avant la maturite "); return; } if (!typeDonnees.Equals("Simulées") && !typeDonnees.Equals("Historiques")) { System.Windows.Forms.MessageBox.Show("ERREUR Type de données : Choisir l'une des deux possibilités "); return; } bool simule; if (typeDonnees.Equals("Simulées")) { simule = true; } else { simule = false; } PricingLibrary.FinancialProducts.IOption option; if (typeOption.Equals("Vanilla Call")) { option = new PricingLibrary.FinancialProducts.VanillaCall("call", tabShare, maturite, strikePrice); } else { option = new PricingLibrary.FinancialProducts.BasketOption("basket", tabShare, tabWeight, maturite, strikePrice); } //////////////////////////////////////////////////////////////////////////// // On calcule le portefeuilles de couverture de l'option OptionManager optionCompute = new OptionManager(option,dateDebut,maturite,tailleFenetre,simule); ComputeResults.computeResults(optionCompute); // On trace les graphes LineSeries courbe = tabToSeries(optionCompute.OptionPrice, optionCompute.dateTime); LineSeries courbe2 = tabToSeries(optionCompute.HedgingPortfolioValue, optionCompute.dateTime); this.MyModel.Series.Clear(); this.MyModel.Axes.Clear(); double min = Math.Min(optionCompute.OptionPrice.Min(),optionCompute.HedgingPortfolioValue.Min())-0.1; double max = Math.Max(optionCompute.OptionPrice.Max(), optionCompute.HedgingPortfolioValue.Max())+0.1; SetUpModel(min, max, optionCompute.dateTime.Min()); courbe.Title = "Prix de l'option"; courbe2.Title = "Valeur Portefeuille de Couverture"; this.MyModel.Series.Add(courbe); this.MyModel.Series.Add(courbe2); // On met à jour les graphes this.MyModel.InvalidatePlot(true); this.MyModel.PlotView.InvalidatePlot(true); }
void Start() { optionmanager = GetComponent<OptionManager>(); OptionsChanged = false; }