public HttpResponseMessage update(OptionType post, Int32 languageId = 0) { // Check for errors if (post == null) { return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The post is null"); } else if (Language.MasterPostExists(languageId) == false) { return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The language does not exist"); } // Make sure that the data is valid post.title = AnnytabDataValidation.TruncateString(post.title, 100); post.google_name = AnnytabDataValidation.TruncateString(post.google_name, 50); // Get the saved post OptionType savedPost = OptionType.GetOneById(post.id, languageId); // Check if the post exists if (savedPost == null) { return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The record does not exist"); } // Update the post OptionType.UpdateMasterPost(post); OptionType.UpdateLanguagePost(post, languageId); // Return the success response return Request.CreateResponse<string>(HttpStatusCode.OK, "The update was successful"); } // End of the update method
public HttpResponseMessage add(OptionType post, Int32 languageId = 0) { // Check for errors if (post == null) { return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The post is null"); } else if (Language.MasterPostExists(languageId) == false) { return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The language does not exist"); } // Make sure that the data is valid post.title = AnnytabDataValidation.TruncateString(post.title, 100); post.google_name = AnnytabDataValidation.TruncateString(post.google_name, 50); // Add the post Int64 insertId = OptionType.AddMasterPost(post); post.id = Convert.ToInt32(insertId); OptionType.AddLanguagePost(post, languageId); // Return the success response return Request.CreateResponse<string>(HttpStatusCode.OK, "The post has been added"); } // End of the add method
// Prices European option using Monte Carlo simulation public double PriceEuropeanOption(double startingAssetValue, double interestRate, OptionType optionType, double strike, double volatility, double timeStep, int numberOfTimeSteps) { int numberOfSimulations = 250; object syncLock = new object(); double sumOfFutureValuesOfOption = 0.0; Parallel.For(0, numberOfSimulations, simulationNumber => { double currentAssetValue = startingAssetValue, futureValueOfOption = 0.0; // each simulation for (int i = 0; i < numberOfTimeSteps; i++) { currentAssetValue = SimulateNextAssetValue(currentAssetValue, interestRate, timeStep, volatility); } futureValueOfOption = Math.Max((int)optionType * (currentAssetValue - strike), 0); // lock to ensure that each addition is atomic. // TODO: this is a bottleneck as locking not only // makes this loop linear but slows it down even more due to locking overhead. // *Potential Race Condition too!* lock (syncLock) { sumOfFutureValuesOfOption += futureValueOfOption; } }); double averageFutureValueOfOption = sumOfFutureValuesOfOption / numberOfSimulations; // compute present value of the average future value. here timeStep*numberOfTimeSteps gives total time to expiry double optionValue = Math.Exp(-interestRate * timeStep * numberOfTimeSteps) * averageFutureValueOfOption; return optionValue; }
private FxOption(OptionType type, double strike, double spot, double dividend, double riskfreerate, double ttm, double vol, Date date, double crossriskfreerate) : base(type, strike, spot, dividend, riskfreerate, ttm, vol, date) { _crossriskfreerate = crossriskfreerate; _npv = 0.0; }
public static double Price(OptionType optionType, double Fwd, double K, double T, double r, double σ, PriceType priceType = PriceType.Price) { double std = σ * Math.Sqrt(T); double DF = Math.Exp(-r * T); double d1 = (Math.Log(Fwd / K) + 0.5*std*std ) / std; double d2 = d1 - std; switch(priceType) { case PriceType.Price: if (optionType == OptionType.Call) return DF * ( Fwd * N(d1) - K * N(d2) ); else if (optionType == OptionType.Put) return DF * ( K * N(-d2) - Fwd * N(-d1) ); break; case PriceType.Δ: return DF * Fwd * N(d1); case PriceType.Vega: return DF * Fwd * Math.Sqrt(T) * Nprime(d1); case PriceType.Γ: return 1 / ( DF * Fwd * std ) * Nprime(d1); } throw new Exception(); }
/// <summary> /// /// </summary> /// <param name="abc"></param> /// <param name="method"></param> /// <param name="argument"></param> public AVM2Argument( AbcFile abc, UInt32 method, UInt32 argument ) { _ArgumentType = abc.ConstantPool.Multinames[ ( int )abc.Methods[ ( int )method ].ParamType[ ( int )argument ] ].ToString( abc ); if ( abc.Methods[ ( int )method ].FlagHasParamNames ) { _ArgumentName = abc.ConstantPool.Strings[ ( int )abc.Methods[ ( int )method ].ParamNames[ ( int )argument ] ]; } else { _ArgumentName = "(no param name)"; } if ( ( abc.Methods[ ( int )method ].FlagHasOptional ) && ( argument < abc.Methods[ ( int )method ].Option.Count ) ) { _IsOptional = true; _OptionalType = abc.Methods[ ( int )method ].Option[ ( int )argument ].OptionType; _OptionalTypeName = abc.Methods[ ( int )method ].Option[ ( int )argument ].OptionTypeName; _OptionalValue = abc.Methods[ ( int )method ].Option[ ( int )argument ].GetValue( abc ); } else { _IsOptional = false; _OptionalType = OptionType.TotallyInvalid; _OptionalValue = null; } }
public DynamicOption(string name, OptionType expectedType, bool isRequired, IEnumerable<object> permittedValues) { Name = name; ExpectedType = expectedType; IsRequired = isRequired; PermittedValues = permittedValues; }
public OptionItem(string key, string description, string defaultvalue, OptionType type = OptionType.String, bool required = false, Func<string, bool> validator = null) { this.Key = key; this.Description = description; this.DefaultValue = defaultvalue; this.Required = required; this.Type = type; if (validator != null) this.Validator = validator; else { if (this.Type == OptionType.Boolean) this.Validator = (x) => { bool b; return string.IsNullOrEmpty(x) || bool.TryParse(x, out b); }; else if (this.Type == OptionType.Integer) this.Validator = (x) => { int i; return int.TryParse(x, out i); }; else this.Validator = null; } }
public Option(OptionType Type, bool OnlineOnly, string Name, Uri ImageUrl) { this.Type = Type; this.OnlineOnly = OnlineOnly; this.Name = Name; this.ImageUrl = ImageUrl; }
public ProfileOption(MenuType menuType, string id, OptionType type, string value) { MenuType = menuType; Id = id; Type = type; Value = value; }
public void loadCharSkill(OptionType opt) { _count = 0; removeItens(); switch (opt) { case OptionType.Special: for (int i = 0; i < 4; i++) { if (GlobalCharacter.player.specials[i] != null) { addSkill(GlobalCharacter.player.specials[i]); } } break; case OptionType.Item: for (int i = 0; i < 4; i++) { if (GlobalCharacter.player.itens[i] != null) { addItem(GlobalCharacter.player.itens[i]); } } break; } this.guiTexture.pixelInset = new Rect(135, 60, 220, _count * 40); _fight.currentAction = opt; }
internal Option(string displayName, int? addressId, AddressType? addressType, string postcode, OptionType optionType, Model.Link[] links) { if (string.IsNullOrWhiteSpace(displayName)) throw new ArgumentNullException("displayName"); if (links == null) throw new ArgumentNullException("links"); DisplayName = displayName; AddressId = addressId; AddressType = addressType; Postcode = postcode; OptionType = optionType; var newLinks = new List<Model.Link>(); foreach (Model.Link link in links) { Model.Link newLink; switch (link.Rel) { case "next": newLink = new Link(link.Rel, link.Href); break; default: newLink = link; break; } newLinks.Add(newLink); } Links = newLinks.ToArray(); }
public Option PriceWithMarketData(OptionType optionType, string underlyingName, DateTime maturity, double strike) { double spot = this.MarketDataService.GetSpot(underlyingName); double volatility = this.MarketDataService.GetHistoricalVolatility(underlyingName, this.DateService.Now, (int)maturity.Subtract(this.DateService.Now).TotalDays); double interestRate = this.MarketDataService.GetInterestRate(); return this.Price(optionType, underlyingName, maturity, strike, spot, volatility, interestRate); }
public AnalyzeOptionInfo(string fullName, string description, OptionType optionType) { FullName = fullName; Description = description; OptionType = optionType; }
public OptionInfo(string name, string underlying, OptionType type, double strike, DateTime expiryDate) { this.Name = name; this.Underlying = underlying; this.Type = type; this.Strike = strike; this.ExpiryDate = expiryDate; }
public AbstractOption(OptionType key) { this.ID = Guid.NewGuid(); this.Key = key; Name = MultiLanguageTextProxy.GetText("OptionType_" + key.ToString() + "_Name", key.ToString()); Description = MultiLanguageTextProxy.GetText("OptionType_" + key.ToString() + "_Description", key.ToString()); }
public OptionSpec(string name, OptionType valueType, string helpText, bool isRequired, string valueText = null) { Name = name; ValueType = valueType; HelpText = helpText; IsRequired = isRequired; ValueText = valueText; }
protected Option(IUnderlying underlying, DateTime expirationDate, OptionType callOrPut, decimal strike, decimal premium) { Underlying = underlying; ExpirationDate = expirationDate; CallOrPut = callOrPut; Strike = strike; Premium = premium; }
public EquityOptionStaticData(OptionType type, double strike, double spot, double volatility, double riskFreeRate, double timeToMaturity) { this.Type = type; this.Strike = strike; this.Spot = spot; this.Volatility = volatility; this.RiskFreeRate = riskFreeRate; this.TimeToMaturity = timeToMaturity; }
public static double ImpliedVol(OptionType optionType, double price, double Fwd, double K, double T, double r, double accuracy = 1e-4 ) { Func<double,double> pricer = (v) => Price(optionType, Fwd, K, T, r, v) - price; Func<double, double> vega = (v) => Price(optionType, Fwd, K, T, r, v, PriceType.Vega); var solve = MathNet.Numerics.RootFinding.NewtonRaphson.FindRootNearGuess( pricer, vega, 0.2, 0, 1, accuracy: accuracy); return solve; }
public Option() { _price = 50.0; _strike = 50.0; _rate = 0.06; _dividend = 0.0; _timeToMaturity = 1; _type = OptionType.Call; _exercise = OptionExercise.European; }
public MenuItemOption(OptionType optionType, Vector2 position) { _type = optionType; Position = position; _leftButton = new Button(Vector2.Zero, "", Globals.Content.Load<Texture2D>("LeftArrow"), Globals.Content.Load<Texture2D>("LeftArrow"), Globals.Content.Load<Texture2D>("LeftArrow")); _rightButton = new Button(Vector2.Zero, "", Globals.Content.Load<Texture2D>("RightArrow"), Globals.Content.Load<Texture2D>("RightArrow"), Globals.Content.Load<Texture2D>("RightArrow")); _leftButton.Position = new Point((int)Position.X, (int)Position.Y); _rightButton.Position = new Point((int)Position.X + 100, (int)Position.Y); ChangeOption(1.0f); }
public AnalyzeOptionInfo(string fullName, string description, OptionType optionType, string xAxisName, string yAxisName) : this(fullName, description, optionType) { XAxisName = xAxisName; YAxisName = yAxisName; }
public BlackScholesOption(OptionType type, double price, double strike, double dividend, double rate, double timeToMaturity, double volatility) { _type = type; _price = price; _strike = strike; _dividend = dividend; _rate = rate; _timeToMaturity = timeToMaturity; _volatility = volatility; }
public static double Delta(OptionType optionType, double spot, double strike, double time, double rate, double volatility) { if (optionType == OptionType.Call) { return CND(D1(spot, strike, time, rate, volatility)); } else //if (optionType == OptionType.Put) { return -CND(-D1(spot, strike, time, rate, volatility)); } }
public AnalyzeOptionInfo(string fullName, string description, OptionType optionType, Type realizationResultType, Type ensembleResultType, string xAxisName, string yAxisName) : this(fullName, description, optionType, realizationResultType, ensembleResultType) { XAxisName = xAxisName; YAxixName = yAxisName; }
public Option(double price, double strike, double volatility, double rate, double dividend, double timeToMaturity, OptionType type, OptionExercise exercise) { _price = price; _strike = strike; _volatility = volatility; _rate = rate; _dividend = dividend; _timeToMaturity = timeToMaturity; _type = type; _exercise = exercise; }
public AnalyzeOptionInfo(string fullName, string description, OptionType optionType, Type realizationResultType, Type ensembleResultType) { FullName = fullName; Description = description; OptionType = optionType; RealizationResultType = realizationResultType; EnsembleResultType = ensembleResultType; }
public static double CalculateImpliedVolatility(double bpv_, double underlyingPx_, double strike_, DateTime expiry_, DateTime valueDate_, double optionPrice_, double rate_, OptionType optionType_, AccrualMethod accMethod_ = AccrualMethod.Actual365_Fixed) { var singleton = FinCADWrapper.Instance(); lock (singleton.GetLock()) { using (SLog.NDC("aaBL_ivW")) { double ret = 0d; FinCADHelpers.LogFinCADError(FincadFunctions.aaBL_iv(underlyingPx_, strike_, expiry_.ToOADate(), valueDate_.ToOADate(), optionPrice_, rate_, (int)optionType_, (int)accMethod_, ref ret)); return ret; } } }
/// <summary> /// Initializes an instance of the OptionNode class. /// </summary> /// <param name="xmlNode">The XML Node describing the Node.</param> /// <param name="game">The game object related to the Node.</param> public OptionNode(XmlNode xmlNode, Game game) { // entity % entity; #IMPLIED // index NMTOKEN #REQUIRED // type NMTOKEN #REQUIRED // ts NMTOKEN #IMPLIED _game = game; Int32.TryParse(xmlNode.Attributes?["entity"]?.Value, out Entity); Int32.TryParse(xmlNode.Attributes?["index"]?.Value, out Index); if (xmlNode.Attributes?["type"]?.Value == null) { throw new NullReferenceException(); } Type = (OptionType)Enum.Parse(typeof(OptionType), xmlNode.Attributes?["type"]?.Value); Ts = xmlNode.Attributes?["ts"]?.Value; }
static void RunCommand(string[] commands) { if (commands.Length == 0) { return; } switch (commands[0].ToUpper()) { default: _dispatchTable.Execute(commands); break; case "SCRIPT": TextReader x = new StreamReader(commands[1]); RunScript(x); x.Dispose(); break; case "COMMENT": break; case "EXIT": Environment.Exit(0); break; case "PAUSE": Console.ReadLine(); break; case "TIMEOUT": break; case "LOG-LEVEL": if (commands.Length != 2) { Console.WriteLine("Incorrect number of args"); return; } switch (commands[1].ToUpper()) { case "INFO": LogManager.Level = LogLevel.Info; break; case "NONE": LogManager.Level = LogLevel.None; break; case "FATAL": LogManager.Level = LogLevel.Fatal; break; default: Console.WriteLine("Unknown level"); break; } break; case "LOG-TO": break; case "OPTION": OptionType typ = GetOptionType(commands[1]); switch (typ) { case OptionType.ContentFormat: case OptionType.Accept: if (commands.Length == 2) { _Options.Add(Option.Create(typ)); } else { for (int i = 2; i < commands.Length; i++) { int val = MediaType.ApplicationLinkFormat; if (int.TryParse(commands[i], out val)) { _Options.Add(Option.Create(typ, val)); } else { Console.WriteLine($"Bad option value '{commands[i]}'"); } } } break; case OptionType.Unknown: Console.WriteLine("Unrecognized type string"); return; default: if (commands.Length == 2) { _Options.Add(Option.Create(typ)); } else { for (int i = 2; i < commands.Length; i++) { _Options.Add(Option.Create(typ, commands[i])); } } break; } break; case "CLEAR-OPTION": if (commands.Length == 1) { _Options.Clear(); return; } typ = GetOptionType(commands[1]); List <Option> del = new List <Option>(); foreach (Option op in _Options) { if (op.Type == typ) { del.Add(op); } } foreach (Option op in del) { _Options.Remove(op); } break; case "BODY": if (commands.Length == 1) { break; } byte[] b = File.ReadAllBytes(commands[1]); Body = b; break; #if false case "EDHOC": RunEdhoc(commands); break; #endif case "ADD-OSCOAP": if (commands.Length != 3) { Console.WriteLine("Incorrect number of arguments: " + commands.Length); return; } CBORObject cbor = CBORDiagnostics.Parse(commands[2]); SecurityContext ctx = SecurityContext.DeriveContext( cbor[CoseKeyParameterKeys.Octet_k].GetByteString(), cbor[CBORObject.FromObject("RecipID")].GetByteString(), cbor[CBORObject.FromObject("SenderID")].GetByteString(), null, cbor[CoseKeyKeys.Algorithm]); _OscopKeys.Add(commands[1], ctx); break; #if DEV_VERSION case "ADD-OSCOAP-GROUP": if (commands.Length != 3) { Console.WriteLine("Incorrect number of arguments: " + commands.Length); return; } cbor = CBORDiagnostics.Parse(commands[2]); ctx = SecurityContext.DeriveGroupContext(cbor[CoseKeyParameterKeys.Octet_k].GetByteString(), cbor[CoseKeyKeys.KeyIdentifier].GetByteString(), cbor[CBORObject.FromObject("sender")][CBORObject.FromObject("ID")].GetByteString(), null, null, cbor[CoseKeyKeys.Algorithm]); ctx.Sender.SigningKey = new OneKey(cbor["sender"]["sign"]); foreach (CBORObject recipient in cbor[CBORObject.FromObject("recipients")].Values) { ctx.AddRecipient(recipient[CBORObject.FromObject("ID")].GetByteString(), new OneKey(recipient["sign"])); } _OscopKeys.Add(commands[1], ctx); break; #endif case "USE-OSCOAP": if (commands.Length != 2) { Console.WriteLine("Incorrect number of arguments: " + commands.Length); return; } if (commands[1] == "NONE") { _CurrentOscoap = null; return; } if (!_OscopKeys.ContainsKey(commands[1])) { Console.WriteLine($"OSCOAP Key {commands[1]} is not defined"); return; } _CurrentOscoap = _OscopKeys[commands[1]]; break; case "OSCOAP-TEST": OscoapTests.RunTest(Int32.Parse(commands[1])); break; case "OSCOAP-PIV": _CurrentOscoap.Sender.SequenceNumber = Int32.Parse(commands[1]); break; case "EDHOC-ADD-SERVER-KEY": if (commands.Length != 2) { Console.WriteLine("Incorrect number of arguments: " + commands.Length); return; } cbor = CBORDiagnostics.Parse(commands[2]); _EdhocServerKeys.AddKey(new OneKey(cbor)); break; case "EDHOC-ADD-USER-KEY": if (commands.Length != 3) { Console.WriteLine("Incorrect number of arguments: " + commands.Length); return; } cbor = CBORDiagnostics.Parse(commands[2]); _EdhocValidateKeys.Add(commands[1], new OneKey(cbor)); break; } }
/// <summary> /// Creates the option type and takes the type of the /// created option as an argument. /// </summary> protected Option(OptionType tag) { this.tag = tag; }
public OptionBuilder(OptionType optionType, Byte[] value) { OptionType = optionType; RawValue = value; }
public ActionResult edit(FormCollection collection) { // Get the current domain Domain currentDomain = Tools.GetCurrentDomain(); ViewBag.CurrentDomain = currentDomain; // Get query parameters string returnUrl = collection["returnUrl"]; ViewBag.QueryParams = new QueryParams(returnUrl); // Check if the administrator is authorized if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true) { ViewBag.AdminSession = true; } else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true) { ViewBag.AdminSession = true; ViewBag.AdminErrorCode = 1; ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC"); return(View("index")); } else { // Redirect the user to the start page return(RedirectToAction("index", "admin_login")); } // Get all the form values Int32 optionTypeId = Convert.ToInt32(collection["txtId"]); string optionTypeTitle = collection["txtTitle"]; string google_name = collection["selectGoogleName"]; string[] optionIds = collection.GetValues("optionId"); string[] optionTitles = collection.GetValues("optionTitle"); string[] optionSuffix = collection.GetValues("optionSuffix"); // Get the default admin language id Int32 adminLanguageId = currentDomain.back_end_language; // Get translated texts KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC"); // Get the option type OptionType optionType = OptionType.GetOneById(optionTypeId, adminLanguageId); // Check if the option type exists if (optionType == null) { // Create the option type optionType = new OptionType(); } // Update values optionType.title = optionTypeTitle; optionType.google_name = google_name; // Count the options Int32 optionCount = optionIds != null ? optionIds.Length : 0; // Create the list of options List <Option> options = new List <Option>(optionCount); // Add all options to the list for (int i = 0; i < optionCount; i++) { if (optionTitles[i] != string.Empty) { // Create a option Option option = new Option(); option.id = Convert.ToInt32(optionIds[i]); option.title = optionTitles[i]; option.product_code_suffix = optionSuffix[i]; option.sort_order = Convert.ToInt16(i); option.option_type_id = optionType.id; // Add the option to the list options.Add(option); } } // Create a error message string errorMessage = string.Empty; // Check for errors in the option type if (optionType.title.Length > 200) { errorMessage += "• " + String.Format(tt.Get("error_field_length"), tt.Get("title"), "100") + "<br/>"; } if (optionType.google_name.Length > 50) { errorMessage += "• " + String.Format(tt.Get("error_field_length"), tt.Get("google_name"), "50") + "<br/>"; } // Check for errors in options foreach (Option option in options) { if (option.title.Length > 50) { errorMessage += "• " + String.Format(tt.Get("error_field_length"), option.title, "50") + "<br/>"; } if (option.product_code_suffix.Length > 10) { errorMessage += "• " + String.Format(tt.Get("error_field_length"), option.product_code_suffix, "10") + "<br/>"; } } // Check if there is errors if (errorMessage == string.Empty) { // Check if we should add or update the option if (optionType.id == 0) { // Add the option AddOption(optionType, options, adminLanguageId); } else { // Update the option UpdateOption(optionType, options, adminLanguageId); } // Update the option count OptionType.UpdateCount(optionType.id); // Redirect the user to the list return(Redirect("/admin_options" + returnUrl)); } else { // Set form values ViewBag.ErrorMessage = errorMessage; ViewBag.OptionType = optionType; ViewBag.Options = options; ViewBag.TranslatedTexts = tt; ViewBag.ReturnUrl = returnUrl; // Return the edit view return(View("edit")); } } // End of the edit method
public OptionBuilder(OptionType optionType, Int32 value) { OptionType = optionType; IntValue = value; }
public abstract void SetItemView(T item, OptionType type);
public Option(OptionType type, int valueLength, byte[] valueBytes) { Type = type; _valueLength = valueLength; ValueBytes = valueBytes; }
public ActionResult translate(FormCollection collection) { // Get the current domain Domain currentDomain = Tools.GetCurrentDomain(); ViewBag.CurrentDomain = currentDomain; // Get query parameters string returnUrl = collection["returnUrl"]; ViewBag.QueryParams = new QueryParams(returnUrl); // Check if the administrator is authorized if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor", "Translator" }) == true) { ViewBag.AdminSession = true; } else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true) { ViewBag.AdminSession = true; ViewBag.AdminErrorCode = 1; ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC"); return(View("index")); } else { // Redirect the user to the start page return(RedirectToAction("index", "admin_login")); } // Get the admin default language Int32 adminLanguageId = currentDomain.back_end_language; // Get translated texts KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC"); // Get all the form values Int32 translationLanguageId = Convert.ToInt32(collection["selectLanguage"]); Int32 optionTypeId = Convert.ToInt32(collection["hiddenOptionTypeId"]); string optionTypeTitle = collection["txtTranslatedTitle"]; string[] optionIds = collection.GetValues("optionId"); string[] optionTitles = collection.GetValues("optionTranslatedTitle"); // Create the translated option type OptionType translatedOptionType = new OptionType(); translatedOptionType.id = optionTypeId; translatedOptionType.title = optionTypeTitle; // Create a list of translated options Int32 optionCount = optionIds != null ? optionIds.Length : 0; List <Option> translatedOptions = new List <Option>(optionCount); for (int i = 0; i < optionCount; i++) { // Create a new option Option translatedOption = new Option(); translatedOption.id = Convert.ToInt32(optionIds[i]); translatedOption.title = optionTitles[i]; translatedOption.option_type_id = optionTypeId; // Add the translated option translatedOptions.Add(translatedOption); } // Create a error message string errorMessage = string.Empty; // Check the option type title if (optionTypeTitle.Length > 200) { errorMessage += "• " + String.Format(tt.Get("error_field_length"), tt.Get("title"), "200") + "<br/>"; } // Check for errors in options for (int i = 0; i < optionCount; i++) { if (optionTitles[i].Length > 50) { errorMessage += "• " + String.Format(tt.Get("error_field_length"), optionTitles[i], "50") + "<br/>"; } } // Check if there is errors if (errorMessage == string.Empty) { // Get the saved option type OptionType optionType = OptionType.GetOneById(optionTypeId, translationLanguageId); if (optionType == null) { // Add a new translated option type OptionType.AddLanguagePost(translatedOptionType, translationLanguageId); } else { // Update the translated option type optionType.title = translatedOptionType.title; OptionType.UpdateLanguagePost(optionType, translationLanguageId); } // Translate options for (int i = 0; i < translatedOptions.Count; i++) { // Get the option Option option = Option.GetOneById(translatedOptions[i].id, translationLanguageId); if (option == null) { // Add the translated option Option.AddLanguagePost(translatedOptions[i], translationLanguageId); } else { // Update the option option.title = translatedOptions[i].title; Option.UpdateLanguagePost(option, translationLanguageId); } } // Redirect the user to the list return(Redirect("/admin_options" + returnUrl)); } else { // Set form values ViewBag.LanguageId = translationLanguageId; ViewBag.Languages = Language.GetAll(adminLanguageId, "name", "ASC"); ViewBag.StandardOptionType = OptionType.GetOneById(optionTypeId, adminLanguageId); ViewBag.StandardOptions = Option.GetByOptionTypeId(optionTypeId, adminLanguageId); ViewBag.TranslatedOptionType = translatedOptionType; ViewBag.TranslatedOptions = translatedOptions; ViewBag.ErrorMessage = errorMessage; ViewBag.TranslatedTexts = tt; ViewBag.ReturnUrl = returnUrl; // Return the translate view return(View("translate")); } } // End of the translate method
/// <summary> /// Initializes a new instance. /// </summary> public OptionRule( [NotNull] string name, OptionType type) : this(name, "", type) { }
public OptionDeclaration(OptionType optionType, bool optionValue) { }
public AssetsGetRequest() { MsgType = Type; ReqID = string.Empty; OptionType = OptionType.Classic; }
public override void SetItemView(RatherInfo item, OptionType type) { }
/// <summary> /// Creates a channel option with a string value. /// </summary> /// <param name="name">Name.</param> /// <param name="stringValue">String value.</param> public ChannelOption(string name, string stringValue) { this.type = OptionType.String; this.name = GrpcPreconditions.CheckNotNull(name, "name"); this.stringValue = GrpcPreconditions.CheckNotNull(stringValue, "stringValue"); }
public ActionResult delete(Int32 id = 0, string returnUrl = "") { // Get the current domain Domain currentDomain = Tools.GetCurrentDomain(); ViewBag.CurrentDomain = currentDomain; // Get query parameters ViewBag.QueryParams = new QueryParams(returnUrl); // Check if the administrator is authorized if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true) { ViewBag.AdminSession = true; } else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true) { ViewBag.AdminSession = true; ViewBag.AdminErrorCode = 1; ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC"); return(View("index")); } else { // Redirect the user to the start page return(RedirectToAction("index", "admin_login")); } // Get the language id int languageId = 0; if (Request.Params["lang"] != null) { Int32.TryParse(Request.Params["lang"], out languageId); } // Create an error code variable Int32 errorCode = 0; // Check if we should delete the full post or just the translation if (languageId == 0 || languageId == currentDomain.back_end_language) { // Delete the option type and all the connected posts (CASCADE) errorCode = OptionType.DeleteOnId(id); } else { // Delete the option type post errorCode = OptionType.DeleteLanguagePostOnId(id, languageId); } // Check if there is an error if (errorCode != 0) { ViewBag.AdminErrorCode = errorCode; ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC"); return(View("index")); } // Redirect the user to the list return(Redirect("/admin_options" + returnUrl)); } // End of the delete method
public OptionCheck(OptionType optionType, String value) { OptionType = optionType; StringValue = value; _expected = Option.Create(optionType, value); }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_ptpType">The option type.</param> public StaticOptionTypeResolver(OptionType p_ptpType) { m_ptpType = p_ptpType; }
public OptionCheck(OptionType optionType, Byte[] value) { OptionType = optionType; RawValue = value; _expected = Option.Create(optionType, value); }
public OptionBuilder(OptionType optionType) { OptionType = optionType; }
public OptionCheck(OptionType optionType) { OptionType = optionType; }
public static Contract CreateContract(string coinName, DateTime exeTime, decimal exePrice, OptionType optionType, string target, decimal coinCount) { if (exePrice <= 0 || exeTime <= DateTime.Now) { return(null); } var coin = CoinRepo.Instance.GetByName(coinName); if (coin == null) { return(null); } var c = new Contract { Id = IdService <Contract> .Instance.NewId(), ExcutePrice = exePrice, ExcuteTime = exeTime, Coin = coin, ContractType = ContractType.期权, OptionType = optionType, Target = coin.Name, CoinCount = coinCount, TimeSpanType = GetTsType(exeTime) }; c.SetCodeAndName(); return(c); }
public static IRequestBuilder Option(OptionType optionType, Int32 value) { return(new OptionBuilder(optionType, value)); }
public static ICheck OptionEqual(OptionType optionType, Int32 value) { return(new OptionCheck(optionType, value)); }
public static double BlackImpliedVol(double forward, double strike, double riskFreeRate, double expTime, double premium, OptionType CP) { Func <double, double> testBlack = (vol => { return(BlackPV(forward, strike, riskFreeRate, expTime, vol, CP) - premium); }); var impliedVol = Math.Solvers.Brent.BrentsMethodSolve(testBlack, 0.000000001, 5.0000000, 1e-10); return(impliedVol); }
//public static ICheck ETagByteEqual(byte[] b) //{ // return new ETagByteCheck() { Expected=b}; //} public static ICheck HasOption(OptionType optionType) { return(new OptionCheck(optionType)); }
public static double[] BlackDerivs(double forward, double strike, double riskFreeRate, double expTime, double volatility, OptionType CP) { var output = new double[3]; double d1, d2, DF; DF = Exp(-riskFreeRate * expTime); d1 = (Log(forward / strike) + (expTime / 2 * (Pow(volatility, 2)))) / (volatility * Sqrt(expTime)); d2 = d1 - volatility * Sqrt(expTime); //delta if (CP == OptionType.Put) { output[0] = DF * (Statistics.NormSDist(d1) - 1); } else { output[0] = DF * Statistics.NormSDist(d1); } //gamma output[1] = DF * Statistics.Phi(d1) / (forward * volatility * Sqrt(expTime)); //speed output[2] = -output[1] / forward * (1 + d1 / (volatility * Sqrt(expTime))); return(output); }
public OptionCheck(OptionType optionType, Int32 value) { OptionType = optionType; IntValue = value; _expected = Option.Create(optionType, value); }
public OptionBuilder(OptionType optionType, String value) { OptionType = optionType; StringValue = value; }
public override void SetItemView(AccountsIds item, OptionType type) { }
public static PlayerTask KettleOptionToPlayerTask(Game Game, int sendOptionId, int sendOptionMainOption, int sendOptionTarget, int sendOptionPosition, int sendOptionSubOption) { SabberStoneCore.Kettle.PowerAllOptions allOptions = Game.AllOptionsMap[sendOptionId]; Console.WriteLine(allOptions.Print()); List <PlayerTask> tasks = allOptions.PlayerTaskList; SabberStoneCore.Kettle.PowerOption powerOption = allOptions.PowerOptionList[sendOptionMainOption]; OptionType optionType = powerOption.OptionType; PlayerTask task = null; switch (optionType) { case OptionType.END_TURN: task = EndTurnTask.Any(Game.CurrentPlayer); break; case OptionType.POWER: SabberStoneCore.Kettle.PowerSubOption mainOption = powerOption.MainOption; IPlayable source = Game.IdEntityDic[mainOption.EntityId]; ICharacter target = sendOptionTarget > 0 ? (ICharacter)Game.IdEntityDic[sendOptionTarget] : null; List <SabberStoneCore.Kettle.PowerSubOption> subObtions = powerOption.SubOptions; if (source.Zone?.Type == Zone.PLAY) { task = MinionAttackTask.Any(Game.CurrentPlayer, source, target); } else { switch (source.Card.Type) { case CardType.HERO: if (target != null) { task = HeroAttackTask.Any(Game.CurrentPlayer, target); } else { task = PlayCardTask.Any(Game.CurrentPlayer, source); } break; case CardType.HERO_POWER: task = HeroPowerTask.Any(Game.CurrentPlayer, target); break; default: task = PlayCardTask.Any(Game.CurrentPlayer, source, target, sendOptionPosition, sendOptionSubOption); break; } } break; case OptionType.PASS: break; default: throw new NotImplementedException(); } return(task); }
/// <summary> /// Creates a channel option with an integer value. /// </summary> /// <param name="name">Name.</param> /// <param name="intValue">Integer value.</param> public ChannelOption(string name, int intValue) { this.type = OptionType.Integer; this.name = GrpcPreconditions.CheckNotNull(name, "name"); this.intValue = intValue; }