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()); }
void OnGUI() { mPos = GUILayout.BeginScrollView(mPos); if (GUILayout.Button("테스트 버튼")) { Debug.Log("테스트 버튼 누름"); } for (OptionType i = OptionType.StartIndex + 1; i < OptionType.LastIndex; i++) { GUILayout.BeginHorizontal(); { bool tempBool = EditorOption.Options[i]; EditorOption.Options[i] = GUILayout.Toggle(EditorOption.Options[i], i.ToString()); if (tempBool != EditorOption.Options[i]) { string key = "DevOption_" + i; EditorPrefs.SetInt(key, EditorOption.Options[i] == true ? 1 : 0); } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }
private void Awake() { // Get or create player preferences if (!PlayerPrefs.HasKey(optionType.ToString())) { PlayerPrefs.SetInt(optionType.ToString(), isOff ? 0 : 1); } isOff = PlayerPrefs.GetInt(optionType.ToString()) == 0 ? true : false; // Set text and mixer text.text = isOff ? "Off" : "On"; //SetMixer(); // It doesn't work on awake... so we called it in the main panel // Set button handle GetComponent <Button>().onClick.AddListener(HandleOnClick); }
public bool YieldDynamicOption(OptionCategory category, string name, OptionType expectedType, bool isRequired, IEnumerable <string> permittedValues) { if (CoreVersion() > 0) { return(YieldDynamicOption(category.ToString(), name, expectedType.ToString(), isRequired) && (permittedValues ?? Enumerable.Empty <string>()).All(each => YieldKeyValuePair(name, each))); } return(YieldDynamicOption((int)category, name, (int)expectedType, isRequired) && (permittedValues ?? Enumerable.Empty <string>()).All(each => YieldKeyValuePair(name, each))); }
public bool YieldDynamicOption(OptionCategory category, string name, OptionType expectedType, bool isRequired) { if (CoreVersion() > 0) { return(YieldDynamicOption(category.ToString(), name, expectedType.ToString(), isRequired)); } // Deprecated--August Preview build uses ints. return(YieldDynamicOption((int)category, name, (int)expectedType, isRequired)); }
private void ApplyClosedLogicIfApplicable(DateTimeOffset when, Guid eventId) { if (NumberOfContracts != 0) { return; } Closed = when; var profit = PremiumReceived - PremiumPaid; var description = $"${StrikePrice.ToString("0.00")} {OptionType.ToString()}"; Transactions.Add( Transaction.PLTx(Id, Ticker, description, PremiumPaid, PremiumReceived, when, true) ); }
private static ValueType LoadValue(string key, ValueType defaultValue, OptionType type) { if (options.ContainsKey(key)) { if (options[key].Type != type) { Debug.Log("Option Value for " + key + " is not a " + type.ToString() + "!"); } return(options[key].Value); } else { options.Add(key, new OptionData(key, defaultValue)); return(defaultValue); } }
public static EquityOption GetOption(OptionType optionType, string underlying, DateTime expiryDate, double strike, string discountCurve) { switch (optionType) { case OptionType.EuropeanCall: return(new EuropeanEquityOption(underlying, expiryDate, strike, true, discountCurve)); case OptionType.EuropeanPut: return(new EuropeanEquityOption(underlying, expiryDate, strike, true, discountCurve)); case OptionType.DigitalCall: return(new DigitalOption(underlying, expiryDate, strike, true, discountCurve, false)); case OptionType.DigitalPut: return(new DigitalOption(underlying, expiryDate, strike, true, discountCurve, false)); default: throw new NotImplementedException($"No option defined for {optionType.ToString()}"); } }
public void SetBlackScholesPrice() { double d1 = (1 / (AnnualVolatility * Math.Sqrt(ValuationTimeSpan.Years()))) * (Math.Log(StockPrice / Strike) + (RiskFreeRate + 0.5 * Math.Pow(AnnualVolatility, 2)) * ValuationTimeSpan.Years()); double d2 = d1 - AnnualVolatility * Math.Sqrt(ValuationTimeSpan.Years()); NormalDistribution normalDistribution = new NormalDistribution(); if (OptionType == Enums.OptionType.Call) { BlackScholesValue = normalDistribution.DistributionFunction(d1) * StockPrice - normalDistribution.DistributionFunction(d2) * Strike * Math.Exp(-RiskFreeRate * ValuationTimeSpan.Years()); } else if (OptionType == Enums.OptionType.Put) { BlackScholesValue = -normalDistribution.DistributionFunction(-d1) * StockPrice + normalDistribution.DistributionFunction(-d2) * Strike * Math.Exp(-RiskFreeRate * ValuationTimeSpan.Years()); } else { throw new Exception($"Failed: OptionType {OptionType.ToString()} is not supported"); } }
/// <summary> /// Returns a <see cref="string" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="string" /> that represents this instance. /// </returns> public override string ToString() { return($"{Name} {OptionType.ToString().Replace("AV_OPT_TYPE_", string.Empty)}: {HelpText} "); }
/// <summary> /// Translates the given <see cref="OptionType"/> into the string representation /// used in the XML. /// </summary> /// <param name="p_otpType">The <see cref="OptionType"/> to unparse.</param> /// <returns>The string representation used in the XML for the given <see cref="OptionType"/>.</returns> protected string UnparseOptionType(OptionType p_otpType) { return p_otpType.ToString(); }
void InitForm() { this.Text = optionType.ToString(); switch (optionType) { case OptionType.EventNotification: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select file event type", 200, System.Windows.Forms.HorizontalAlignment.Left); eventNotification = uint.Parse(value); foreach (FilterAPI.EVENTTYPE eventType in Enum.GetValues(typeof(FilterAPI.EVENTTYPE))) { if (eventType == FilterAPI.EVENTTYPE.NONE) { continue; } string item = eventType.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = eventType; if ((eventNotification & (uint)eventType) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Register_Request: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Register I/O type", 400, System.Windows.Forms.HorizontalAlignment.Left); requestRegistration = uint.Parse(value); foreach (FilterAPI.MessageType messageType in Enum.GetValues(typeof(FilterAPI.MessageType))) { string item = messageType.ToString(); if (item.ToLower().StartsWith("pre") && isMonitorFilter) { //for monitor filter driver, there are only POST IO can be registered. continue; } ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = messageType; if ((requestRegistration & (uint)messageType) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.RegistryAccessFlag: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Registry Access Control Flag", 400, System.Windows.Forms.HorizontalAlignment.Left); registryAccessFlags = uint.Parse(value); foreach (FilterAPI.RegControlFlag regAccessFlag in Enum.GetValues(typeof(FilterAPI.RegControlFlag))) { string item = regAccessFlag.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = regAccessFlag; if ((registryAccessFlags & (uint)regAccessFlag) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.RegistryCallbackClass: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Registry Callback Class", 400, System.Windows.Forms.HorizontalAlignment.Left); registryCallbackClass = ulong.Parse(value); foreach (FilterAPI.RegCallbackClass regCallbackClass in Enum.GetValues(typeof(FilterAPI.RegCallbackClass))) { string item = regCallbackClass.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = regCallbackClass; if ((registryCallbackClass & (ulong)regCallbackClass) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.ProccessId: { Process[] processlist = Process.GetProcesses(); listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Process Id", 100, System.Windows.Forms.HorizontalAlignment.Left); listView1.Columns.Add("Process Name", 300, System.Windows.Forms.HorizontalAlignment.Left); List <uint> pidList = new List <uint>(); string[] pids = value.Split(';'); foreach (string pid in pids) { if (!string.IsNullOrEmpty(pid)) { pidList.Add(uint.Parse(pid)); } } for (int i = 0; i < processlist.Length; i++) { string[] item = new string[2]; item[0] = processlist[i].Id.ToString(); item[1] = processlist[i].ProcessName; if (processlist[i].Id == 0) { //this is idle process, skip it. continue; } ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = processlist[i].Id; if (pidList.Contains((uint)(processlist[i].Id))) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Access_Flag: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select AccessFlag", 400, System.Windows.Forms.HorizontalAlignment.Left); accessFlags = uint.Parse(value); foreach (FilterAPI.AccessFlag accessFlag in Enum.GetValues(typeof(FilterAPI.AccessFlag))) { if (accessFlag <= FilterAPI.AccessFlag.ENABLE_REPARSE_FILE_OPEN || accessFlag == FilterAPI.AccessFlag.LEAST_ACCESS_FLAG) { //this is special usage for the filter continue; } string item = accessFlag.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = accessFlag; if (((uint)accessFlag & accessFlags) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.ShareFileAccessFlag: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select AccessFlag", 400, System.Windows.Forms.HorizontalAlignment.Left); accessFlags = uint.Parse(value); foreach (FilterAPI.AccessFlag accessFlag in Enum.GetValues(typeof(FilterAPI.AccessFlag))) { if (accessFlag < FilterAPI.AccessFlag.ALLOW_OPEN_WTIH_ACCESS_SYSTEM_SECURITY || accessFlag == FilterAPI.AccessFlag.LEAST_ACCESS_FLAG) { //this is special usage for the filter continue; } string item = accessFlag.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = accessFlag; if (((uint)accessFlag & accessFlags) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Filter_Status: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Filter Status", 400, System.Windows.Forms.HorizontalAlignment.Left); filterStatus = uint.Parse(value); foreach (FilterAPI.FilterStatus status in Enum.GetValues(typeof(FilterAPI.FilterStatus))) { string item = status.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = status; if (((uint)status & filterStatus) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Return_Status: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Only One Status", 400, System.Windows.Forms.HorizontalAlignment.Left); returnStatus = uint.Parse(value); foreach (NtStatus.Status status in Enum.GetValues(typeof(NtStatus.Status))) { string item = status.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = status; if (((uint)status & filterStatus) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.FilterType: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Filter Driver Type", 400, System.Windows.Forms.HorizontalAlignment.Left); filterType = byte.Parse(value); foreach (FilterAPI.FilterType fltType in Enum.GetValues(typeof(FilterAPI.FilterType))) { string item = fltType.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = fltType; if ((filterType & (byte)fltType) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.ProcessControlFlag: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Process Control Flag", 400, System.Windows.Forms.HorizontalAlignment.Left); processControlFlag = uint.Parse(value); foreach (FilterAPI.ProcessControlFlag controlFlag in Enum.GetValues(typeof(FilterAPI.ProcessControlFlag))) { string item = controlFlag.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = controlFlag; if ((processControlFlag & (uint)controlFlag) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } } }
void InitForm() { this.Text = optionType.ToString(); switch (optionType) { case OptionType.EventNotification: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select file event type", 200, System.Windows.Forms.HorizontalAlignment.Left); eventNotification = uint.Parse(value); foreach (FilterAPI.EVENTTYPE eventType in Enum.GetValues(typeof(FilterAPI.EVENTTYPE))) { if (eventType == FilterAPI.EVENTTYPE.NONE) { continue; } string item = eventType.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = eventType; if ((eventNotification & (uint)eventType) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Register_Request: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Register I/O type", 400, System.Windows.Forms.HorizontalAlignment.Left); requestRegistration = uint.Parse(value); foreach (FilterAPI.MessageType messageType in Enum.GetValues(typeof(FilterAPI.MessageType))) { string item = messageType.ToString(); if (item.ToLower().StartsWith("pre") && isMonitorFilter) { //for monitor filter, it only can register the post I/O request notification. continue; } ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = messageType; if ((requestRegistration & (uint)messageType) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.ProccessId: { Process[] processlist = Process.GetProcesses(); listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Process Id", 100, System.Windows.Forms.HorizontalAlignment.Left); listView1.Columns.Add("Process Name", 300, System.Windows.Forms.HorizontalAlignment.Left); List <uint> pidList = new List <uint>(); string[] pids = value.Split(';'); foreach (string pid in pids) { if (!string.IsNullOrEmpty(pid)) { pidList.Add(uint.Parse(pid)); } } for (int i = 0; i < processlist.Length; i++) { string[] item = new string[2]; item[0] = processlist[i].Id.ToString(); item[1] = processlist[i].ProcessName; ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = processlist[i].Id; if (pidList.Contains((uint)(processlist[i].Id))) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Access_Flag: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select AccessFlag", 400, System.Windows.Forms.HorizontalAlignment.Left); accessFlags = uint.Parse(value); foreach (FilterAPI.AccessFlag accessFlag in Enum.GetValues(typeof(FilterAPI.AccessFlag))) { if (accessFlag < FilterAPI.AccessFlag.REPARSE_FILE_OPEN || accessFlag == FilterAPI.AccessFlag.LAST_ACCESS_FLAG) { //this is special usage for the filter continue; } string item = accessFlag.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = accessFlag; if (((uint)accessFlag & accessFlags) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.ShareAccessOption: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select AccessFlag", 400, System.Windows.Forms.HorizontalAlignment.Left); shareAccessFlags = uint.Parse(value); foreach (FilterAPI.SecureFileAccessRights accessFlag in Enum.GetValues(typeof(FilterAPI.SecureFileAccessRights))) { string item = accessFlag.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = accessFlag; if (((uint)accessFlag & shareAccessFlags) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Filter_Status: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Filter Status", 400, System.Windows.Forms.HorizontalAlignment.Left); filterStatus = uint.Parse(value); foreach (FilterAPI.FilterStatus status in Enum.GetValues(typeof(FilterAPI.FilterStatus))) { string item = status.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = status; if (((uint)status & filterStatus) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } case OptionType.Return_Status: { listView1.Clear(); //clear control //create column header for ListView listView1.Columns.Add("Select Only One Status", 400, System.Windows.Forms.HorizontalAlignment.Left); returnStatus = uint.Parse(value); foreach (NtStatus.Status status in Enum.GetValues(typeof(NtStatus.Status))) { string item = status.ToString(); ListViewItem lvItem = new ListViewItem(item, 0); lvItem.Tag = status; if (((uint)status & filterStatus) > 0) { lvItem.Checked = true; } listView1.Items.Add(lvItem); } break; } } }
/// <summary> /// Translates the given <see cref="OptionType"/> into the string representation /// used in the XML. /// </summary> /// <param name="p_otpType">The <see cref="OptionType"/> to unparse.</param> /// <returns>The string representation used in the XML for the given <see cref="OptionType"/>.</returns> protected string UnparseOptionType(OptionType p_otpType) { return(p_otpType.ToString()); }
/// <summary> /// Private method which exposes all possible parameters, with default values for the optional ones. /// </summary> /// <param name="category">Category=StockOption, IndexOption, FutureOption or CurrencyOption</param> /// <param name="symbolRoot">Symbol root. Required Field, the symbol the option is a derivative of, this search will not return options based on a partial root.</param> /// <param name="strikeCount">Number of strikes prices above and below the underlying price. Defaults to 3. Ignored if strike price high and low are passed.</param> /// <param name="strikePriceLow">Strike price low</param> /// <param name="strikePriceHigh">Strike price high</param> /// <param name="dateCount">Number of expiration dates. Default value 3. Ignored if expiration dates high and low are passed.</param> /// <param name="expirationDateLow">Expiration date low</param> /// <param name="expirationDateHigh">Expiration date high</param> /// <param name="optionType">Option type (Both, Call, Put) Default: Both</param> /// <param name="futureType">Future type (Electronic, Pit) Default: Electronic</param> /// <param name="symbolType">SymbolType (Both, Composite, Regional) Default: Composite</param> /// <param name="country">Country code (US, DE, CA) Default: US</param> /// <returns></returns> public static string GetOptionSearchCriteria(SearchCategory category, string symbolRoot, uint strikeCount = 3, decimal strikePriceLow = 0, decimal strikePriceHigh = decimal.MaxValue, uint dateCount = 3, DateTime? expirationDateLow = null, DateTime? expirationDateHigh = null, OptionType optionType = OptionType.Both, FutureType futureType = FutureType.Electronic, SymbolType symbolType = SymbolType.Composite, CountryCode country = CountryCode.US) { if (string.IsNullOrEmpty(symbolRoot)) throw new ArgumentException("symbolRoot is required.", "symbolRoot"); if (GetAssetType(category) != AssetClass.Option) throw new ArgumentException("SearchCategory must be StockOption, IndexOption, FutureOption or CurrencyOption", "category"); if (strikePriceLow < 0) throw new ArgumentOutOfRangeException("strikePriceLow", "Argument cannot be less than 0."); if (strikePriceHigh < 0) throw new ArgumentOutOfRangeException("strikePriceHigh", "Argument cannot be less than 0."); if ((expirationDateLow.HasValue && !expirationDateHigh.HasValue) || (expirationDateHigh.HasValue && !expirationDateLow.HasValue)) throw new ArgumentException("If either expiration date parameter is passed, both must be passed."); if (expirationDateHigh.HasValue && expirationDateLow.HasValue && expirationDateHigh < expirationDateLow) throw new ArgumentOutOfRangeException("expirationDateHigh", "expirationDateHigh cannot be before expirationDateLow."); StringBuilder criteria = new StringBuilder(255); Append(criteria, "c=" + category.ToString()); Append(criteria, "R=" + symbolRoot); // strike price range takes precidence over strike count if (strikePriceLow > 0 && strikePriceHigh < decimal.MaxValue) { Append(criteria, "Spl=" + strikePriceLow); Append(criteria, "Sph=" + strikePriceHigh); } else if (strikeCount != 3) Append(criteria, "Stk=" + strikeCount); // daterange takes precidence over datacount if (expirationDateLow.HasValue) { Append(criteria, "Edl=" + ((DateTime)expirationDateLow).ToString("MM-dd-yyyy")); Append(criteria, "Edh=" + ((DateTime)expirationDateHigh).ToString("MM-dd-yyyy")); } else if (dateCount != 3) Append(criteria, "Exd=" + dateCount); if (optionType != OptionType.Both) Append(criteria, "OT=" + optionType.ToString()); if (futureType != FutureType.Electronic) Append(criteria, "FT=" + futureType.ToString()); if (symbolType != SymbolType.Composite) Append(criteria, "ST=" + symbolType.ToString()); if (country != CountryCode.US) Append(criteria, "Cnt=" + country.ToString()); return criteria.ToString(); }
public override void Print() { CustomConsole.PrintRow(_id.ToString(), _tradedate.ToShortDateString(), _currencypair.ToString(), _notional.ToString(), _premium.ToString(), _spot.ToString(), _strike.ToString(), _direction.ToString(), _type.ToString(), _executiontype.ToString(), _withdrawdate.ToShortDateString(), _settlementdate.ToShortDateString()); }
public void TestSearchOptionInvalidFieldType(InvalidOptionField optionField, OptionType optionType) { OptionManager optionHandler = new OptionManager(); Dictionary <string, string> requestDic = new Dictionary <string, string>() { ["columns"] = InvalidFieldMapper[optionField], ["type"] = ((int)optionType).ToString(), }; 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 type = {optionType.ToString()}"); }
/// <summary> /// Private method which exposes all possible parameters, with default values for the optional ones. /// </summary> /// <param name="category">Category=StockOption, IndexOption, FutureOption or CurrencyOption</param> /// <param name="symbolRoot">Symbol root. Required Field, the symbol the option is a derivative of, this search will not return options based on a partial root.</param> /// <param name="strikeCount">Number of strikes prices above and below the underlying price. Defaults to 3. Ignored if strike price high and low are passed.</param> /// <param name="strikePriceLow">Strike price low</param> /// <param name="strikePriceHigh">Strike price high</param> /// <param name="dateCount">Number of expiration dates. Default value 3. Ignored if expiration dates high and low are passed.</param> /// <param name="expirationDateLow">Expiration date low</param> /// <param name="expirationDateHigh">Expiration date high</param> /// <param name="optionType">Option type (Both, Call, Put) Default: Both</param> /// <param name="futureType">Future type (Electronic, Pit) Default: Electronic</param> /// <param name="symbolType">SymbolType (Both, Composite, Regional) Default: Composite</param> /// <param name="country">Country code (US, DE, CA) Default: US</param> /// <returns></returns> public static string GetOptionSearchCriteria(SearchCategory category, string symbolRoot, uint strikeCount = 3, decimal strikePriceLow = 0, decimal strikePriceHigh = decimal.MaxValue, uint dateCount = 3, DateTime?expirationDateLow = null, DateTime?expirationDateHigh = null, OptionType optionType = OptionType.Both, FutureType futureType = FutureType.Electronic, SymbolType symbolType = SymbolType.Composite, CountryCode country = CountryCode.US) { if (string.IsNullOrEmpty(symbolRoot)) { throw new ArgumentException("symbolRoot is required.", "symbolRoot"); } if (GetAssetType(category) != AssetClass.Option) { throw new ArgumentException("SearchCategory must be StockOption, IndexOption, FutureOption or CurrencyOption", "category"); } if (strikePriceLow < 0) { throw new ArgumentOutOfRangeException("strikePriceLow", "Argument cannot be less than 0."); } if (strikePriceHigh < 0) { throw new ArgumentOutOfRangeException("strikePriceHigh", "Argument cannot be less than 0."); } if ((expirationDateLow.HasValue && !expirationDateHigh.HasValue) || (expirationDateHigh.HasValue && !expirationDateLow.HasValue)) { throw new ArgumentException("If either expiration date parameter is passed, both must be passed."); } if (expirationDateHigh.HasValue && expirationDateLow.HasValue && expirationDateHigh < expirationDateLow) { throw new ArgumentOutOfRangeException("expirationDateHigh", "expirationDateHigh cannot be before expirationDateLow."); } StringBuilder criteria = new StringBuilder(255); Append(criteria, "c=" + category.ToString()); Append(criteria, "R=" + symbolRoot); // strike price range takes precidence over strike count if (strikePriceLow > 0 && strikePriceHigh < decimal.MaxValue) { Append(criteria, "Spl=" + strikePriceLow); Append(criteria, "Sph=" + strikePriceHigh); } else if (strikeCount != 3) { Append(criteria, "Stk=" + strikeCount); } // daterange takes precidence over datacount if (expirationDateLow.HasValue) { Append(criteria, "Edl=" + ((DateTime)expirationDateLow).ToString("MM-dd-yyyy")); Append(criteria, "Edh=" + ((DateTime)expirationDateHigh).ToString("MM-dd-yyyy")); } else if (dateCount != 3) { Append(criteria, "Exd=" + dateCount); } if (optionType != OptionType.Both) { Append(criteria, "OT=" + optionType.ToString()); } if (futureType != FutureType.Electronic) { Append(criteria, "FT=" + futureType.ToString()); } if (symbolType != SymbolType.Composite) { Append(criteria, "ST=" + symbolType.ToString()); } if (country != CountryCode.US) { Append(criteria, "Cnt=" + country.ToString()); } return(criteria.ToString()); }
/// <summary> /// Saves the cart and redirects. /// </summary> /// <param name="cartName">Cart name.</param> /// <param name="update">Flag to update the same saved cart</param> private void SaveCart(string cartName, bool update) { if (!update) { var optionType = (ServiceProvider.CatalogSvc.DeliveryOptionType)Enum.Parse(typeof(ServiceProvider.CatalogSvc.DeliveryOptionType), OptionType.ToString()); ShoppingCart.CopyCartWithShippingInfo(true, cartName, ShippingAddresssID, DeliveryOptionID, optionType); if (ShoppingCart.CustomerOrderDetail == null) { ShoppingCart.ClearCart(); } } OnNewOrder(this, new EventArgs()); }
private void sendState(IList <InstallStep> lstSteps, string strPrefixPath, int stepIdx) { Func <IEnumerable <InstallStep>, IEnumerable <InstallerStep> > convertSteps = steps => { int idx = 0; return(steps.Select(step => new InstallerStep(idx++, step.Name, step.VisibilityCondition == null || step.VisibilityCondition.GetIsFulfilled(m_csmState, m_Delegates)))); }; Func <IEnumerable <Option>, OptionsPresetGroup?, bool, IEnumerable <Interface.ui.Option> > convertOptions = (options, groupPreset, selectAll) => { int idx = 0; return(options.Select(option => { OptionType type = resolveOptionType(option); bool choicePreset = false; if (groupPreset.HasValue && (type != OptionType.Required) && !selectAll && (groupPreset.Value.choices != null)) { choicePreset = groupPreset.Value.choices.Any(preOption => preOption.name == option.Name); } string conditionMsg = type == OptionType.NotUsable ? option.GetConditionMessage(m_csmState, m_Delegates) : null; return new Interface.ui.Option(idx++, option.Name, option.Description, string.IsNullOrEmpty(option.ImagePath) ? null : Path.Combine(strPrefixPath, option.ImagePath), m_SelectedOptions.Contains(option), choicePreset, type.ToString(), conditionMsg); })); }; Func <IEnumerable <OptionGroup>, OptionsPresetStep?, IEnumerable <Group> > convertGroups = (groups, stepPreset) => { int idx = 0; return(groups.Select(group => { OptionsPresetGroup?groupPreset = null; if ((stepPreset.HasValue) && (stepPreset.Value.groups != null)) { groupPreset = stepPreset.Value.groups.FirstOrDefault(preGroup => preGroup.name == group.Name); } return new Group(idx++, group.Name, group.Type.ToString(), convertOptions(group.Options, groupPreset, group.Type == OptionGroupType.SelectAll).ToArray()); })); }; Action <InstallerStep[], int> insertGroups = (InstallerStep[] steps, int idx) => { InstallStep inStep = lstSteps[idx]; OptionsPresetStep?stepPreset = null; if ((m_Preset.HasValue) && (m_Preset.Value.steps != null)) { stepPreset = m_Preset.Value.steps.FirstOrDefault(preStep => preStep.name == inStep.Name); } steps[idx].optionalFileGroups.order = inStep.GroupSortOrder.ToString(); steps[idx].optionalFileGroups.group = convertGroups(inStep.OptionGroups, stepPreset).ToArray(); }; InstallerStep[] uiSteps = convertSteps(lstSteps).ToArray(); // previously we only sent the groups for the current step but sending all makes it easier to track and save all // installer choices made for (int i = 0; i < lstSteps.Count; ++i) { insertGroups(uiSteps, i); } m_Delegates.ui.UpdateState(uiSteps, stepIdx); }