本文整理汇总了C#中SymbolType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolType.ToString方法的具体用法?C# SymbolType.ToString怎么用?C# SymbolType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolType
的用法示例。
在下文中一共展示了SymbolType.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOptionSearchCriteria
/// <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();
}