public static decimal CalculateOptionPrice_BS(OptionTypes type, decimal spotPrice, decimal strike, decimal daysLeft, decimal daysInYear, decimal vola) { double d1 = 0.0; double d2 = 0.0; double interestRate = 0.0; double optionTime = (double)(daysLeft / daysInYear); double dBlackScholes = 0.0; d1 = (double)Calculate_d1(spotPrice, strike, daysLeft, daysInYear, vola); d2 = (double)Calculate_d2(spotPrice, strike, daysLeft, daysInYear, vola); switch (type) { case OptionTypes.Call: dBlackScholes = (double)spotPrice * CalculateDistributionOfStNrmDstr((decimal)d1) - (double)strike * Math.Exp(-interestRate * optionTime) * CalculateDistributionOfStNrmDstr((decimal)d2); break; case OptionTypes.Put: dBlackScholes = (double)strike * Math.Exp(-interestRate * optionTime) * CalculateDistributionOfStNrmDstr((decimal) - d2) - (double)spotPrice * CalculateDistributionOfStNrmDstr((decimal) - d1); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return((decimal)dBlackScholes); }
public static decimal CalculateImpliedVolatility(OptionTypes type, decimal spotPrice, decimal strike, decimal daysLeft, decimal daysInYear, decimal optionPrice, decimal volaGuess) { double dVol = 0.00001; double epsilon = 0.00001; double maxIterNumber = 100; double vol1 = (double)volaGuess; int i = 1; double vol2 = 0.0; double tempVal1 = 0.0; double tempVal2 = 0.0; double dx = 0.0; while (true) { tempVal1 = (double)CalculateOptionPrice_BS(type, spotPrice, strike, daysLeft, daysInYear, (decimal)vol1); vol2 = vol1 - dVol; tempVal2 = (double)CalculateOptionPrice_BS(type, spotPrice, strike, daysLeft, daysInYear, (decimal)vol2); dx = (tempVal2 - tempVal1) / dVol; if (Math.Abs(dx) < epsilon || i == maxIterNumber) { break; } vol1 = vol1 - ((double)optionPrice - tempVal1) / dx; i++; } return(GetRoundValue((decimal)vol1)); }
public Option(OptionTypes _type, ushort _strike, DateTime _exp, double _vol) { OpType = _type; StrikePrice = _strike; Expiration = _exp; Volatility = _vol; }
protected ConfigOption(OptionTypes optionType, string id, string label) { this.OptionType = optionType; this.Id = id; this.Label = label; LinkedProperty = typeof(ModConfig).GetProperty(id); }
/// <summary> /// Use this method to define which processor the current Option should be using. /// </summary> /// <param name="type">OptionType - the type of option the current object should be defined as.</param> public void SetProcessor(OptionTypes type) { switch (type) { case OptionTypes.CheckBoxes: Processor = new CheckBoxes(); break; case OptionTypes.DropDownList: Processor = new DropDownList(); break; case OptionTypes.FileUpload: Processor = new FileUpload(); break; case OptionTypes.Html: Processor = new Html(); break; case OptionTypes.RadioButtonList: Processor = new RadioButtonList(); break; case OptionTypes.TextInput: Processor = new TextInput(); break; } }
/// <summary> /// This is a shared method to instantiate a new Option, set it's processor and then return the Option back to the /// calling code. /// </summary> /// <param name="type">OptionType - the type of option the new Option object should be defined as.</param> /// <returns>A new instance of Option with defaults set, except for the OptionType.</returns> public static Option Factory(OptionTypes type) { var result = new Option(); result.SetProcessor(type); return(result); }
FlagsOption(GUIContent label, object value, bool isSelected, OptionTypes type) { Label = label; Value = value; Type = type; IsSelected = isSelected; }
private static Security CreateStrike(decimal strike, decimal oi, decimal iv, OptionTypes type, DateTime expiryDate, Security asset, decimal?lastTrade) { var s = new Security { Code = "RI {0} {1}".Put(type == OptionTypes.Call ? 'C' : 'P', strike), Strike = strike, OpenInterest = oi, ImpliedVolatility = iv, HistoricalVolatility = iv, OptionType = type, ExpiryDate = expiryDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id, LastTrade = lastTrade == null ? null : new Trade { Price = lastTrade.Value }, Volume = RandomGen.GetInt(10000), Type = SecurityTypes.Option }; s.BestBid = new QuoteChange(s.StepPrice ?? 1m * RandomGen.GetInt(100), s.VolumeStep ?? 1m * RandomGen.GetInt(100)); s.BestAsk = new QuoteChange(s.BestBid.Value.Price.Max(s.StepPrice ?? 1m * RandomGen.GetInt(100)), s.VolumeStep ?? 1m * RandomGen.GetInt(100)); return(s); }
/// <summary> /// To calculate the option rho. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="strike">The strike price.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="riskFree">The risk free interest rate.</param> /// <param name="deviation">Standard deviation.</param> /// <param name="timeToExp">The option period before the expiration.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <returns>Option rho.</returns> public static decimal Rho(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal deviation, double timeToExp, double d1) { var expRate = ExpRate(riskFree, timeToExp); var sign = optionType == OptionTypes.Call ? 1 : -1; return(sign * (0.01m * strike * (decimal)(timeToExp * expRate * NormalDistr(sign * D2(d1, deviation, timeToExp))))); }
public MessageDialog(SurfaceObject parent, OptionTypes type) : base(parent) { InitializeComponent(); this.Options = type; _opt1.Click += _opt1_Click; _opt2.Click += _opt2_Click; InitButtons(); }
public OptionSpec(string name, OptionTypes valueType, string helpText, bool isRequired, string valueText = null) { Name = name; ValueType = valueType; HelpText = helpText; IsRequired = isRequired; ValueText = valueText; }
/// <summary> /// To calculate the option premium. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="strike">The strike price.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="riskFree">The risk free interest rate.</param> /// <param name="dividend">The dividend amount on shares.</param> /// <param name="deviation">Standard deviation.</param> /// <param name="timeToExp">The option period before the expiration.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <returns>The option premium.</returns> public static decimal Premium(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal dividend, decimal deviation, double timeToExp, double d1) { var sign = (optionType == OptionTypes.Call) ? 1 : -1; var expDiv = ExpRate(dividend, timeToExp); var expRate = ExpRate(riskFree, timeToExp); return((assetPrice * (decimal)(expDiv * NormalDistr(d1 * sign)) - strike * (decimal)(expRate * NormalDistr(D2(d1, deviation, timeToExp) * sign))) * sign); }
/// <summary> /// To calculate the option delta. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <returns>Option delta.</returns> public static decimal Delta(OptionTypes optionType, decimal assetPrice, double d1) { var delta = (decimal)NormalDistr(d1); if (optionType == OptionTypes.Put) { delta -= 1; } return(delta); }
/// <summary> /// To calculate the option theta. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="strike">The strike price.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="riskFree">The risk free interest rate.</param> /// <param name="deviation">Standard deviation.</param> /// <param name="timeToExp">The option period before the expiration.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <param name="daysInYear">Days per year.</param> /// <returns>Option theta.</returns> public static decimal Theta(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal deviation, double timeToExp, double d1, decimal daysInYear = 365) { var nd1 = InvertD1(d1); var expRate = ExpRate(riskFree, timeToExp); var sign = optionType == OptionTypes.Call ? 1 : -1; return ((-(assetPrice * deviation * (decimal)nd1) / (2 * (decimal)timeToExp.Sqrt()) - sign * (strike * riskFree * (decimal)(expRate * NormalDistr(sign * D2(d1, deviation, timeToExp))))) / daysInYear); }
/// <summary> /// Parses the given arguments into a filled option object. /// </summary> /// <param name="args">the arguments to parse</param> /// <returns>The parsed result</returns> /// <see cref="ParseResult"/> public ParseResult Parse(params string[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } var queue = new Queue <string>(args); var result = new ParseResult { Parser = this }; var optionType = OptionType; if (OptionTypes.Count > 1) { if (queue.Count == 0) { result.SetState(State.MissingVerb, "no verb given"); } else { var verb = queue.Dequeue(); if (verb == "") { result.SetState(State.MissingVerb, "empty verb"); } else if (IsHelp(verb)) { result.SetState(State.RequestHelp); } else { if (!OptionTypes.TryGetValue(verb, out optionType)) { result.SetState(State.MissingVerb, $"verb '{args[0]}' not defined"); } result.Verb = verb; } } } if (result.State == State.Succeeded) { optionType.Parse(result, queue); } return(result); }
// TO DO[OPTIONAL]: Clean up this method. private static void RunOption(OptionTypes option) { switch (option) { case OptionTypes.ParseCsv: var container = CsvAccess.ParseCsv(); if (container == null) { return; } // Add default update times (hard coded). container.UpdateTimes.AddRange(UpdateTime.DefaultUpdateTimes); // Add default projects (hard coded). Currently empty!!! container.Projects.AddRange(Project.DefaultProjects()); File.WriteAllText(JsonAccess.DefaultFilename, JsonConvert.SerializeObject(container, Formatting.Indented)); return; case OptionTypes.RunDataCollector: var data = JsonAccess.DeserializeEdges(); var status = -100; if (data == null) { return; } Task.Run(() => status = GoogleAccess.RunDataCollector(data).Result).Wait(); if (status == 0) { JsonAccess.SerializeEdges(data); } return; case OptionTypes.GenerateCsvReport: CsvAccess.GenerateCsvReportGroupedByUpdateTime(); return; default: return; } }
/// <summary> /// Find shared option by name and option type /// </summary> /// <param name="name">name of the option</param> /// <param name="optionType"><see cref="OptionTypes" /> of the option</param> /// <returns></returns> public Option FindSharedOptionByNameAndType(string name, OptionTypes optionType) { var storeId = Context.CurrentStore.Id; using (var s = CreateStrategy()) { var option = GetJoinedQuery(s).FirstOrDefault(y => y.Item.StoreId == storeId && y.Item.IsShared && y.ItemTranslation.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase) && y.Item.OptionType == (int)optionType); return(FirstPoco(option)); } }
/** * <summary>Parse a MemBlock packet into a Dhcp Packet</summary> * <param name="Packet">The dhcp packet to parse</param> */ public DhcpPacket(MemBlock Packet) { if (Packet.Length < 240) { throw new Exception("Invalid Dhcp Packet: Length < 240."); } _packet = Packet; op = Packet[0]; int hlen = Packet[2]; xid = Packet.Slice(4, 4); ciaddr = Packet.Slice(12, 4); yiaddr = Packet.Slice(16, 4); siaddr = Packet.Slice(20, 4); chaddr = Packet.Slice(28, hlen); MemBlock key = Packet.Slice(236, 4); if (!key.Equals(magic_key)) { throw new Exception("Invalid Dhcp Packet: Invalid magic key."); } int idx = 240; /* Parse the options */ Options = new Dictionary <OptionTypes, MemBlock>(); /* 255 is end of options */ while (Packet[idx] != 255) { /* 0 is padding */ if (Packet[idx] != 0) { OptionTypes type = (OptionTypes)Packet[idx++]; byte length = Packet[idx++]; Options[type] = Packet.Slice(idx, length); idx += length; } else { idx++; } } }
public static decimal CalculateDelta(OptionTypes type, decimal distr_d1) { decimal result = 0; switch (type) { case OptionTypes.Call: result = distr_d1; break; case OptionTypes.Put: result = distr_d1 - 1; break; default: break; } return(GetRoundValue(result)); }
public static decimal CalculateDelta(OptionTypes type, decimal spotPrice, decimal strike, decimal daysLeft, decimal daysInYear, decimal vola) { decimal result = 0; switch (type) { case OptionTypes.Call: result = (decimal)CalculateDistributionOfStNrmDstr(Calculate_d1(spotPrice, strike, daysLeft, daysInYear, vola)); break; case OptionTypes.Put: result = (decimal)CalculateDistributionOfStNrmDstr(Calculate_d1(spotPrice, strike, daysLeft, daysInYear, vola)) - 1; break; default: break; } return(GetRoundValue(result)); }
public object[] OptionParameters(OptionTypes types) { List <object> parms = new List <object>(); if (types.HasFlag(OptionTypes.DbOption)) { if (Connection != null) { parms.Add(Connection); } if (Transaction != null) { parms.Add(Transaction); } if (DataStorageController != null) { parms.Add(DataStorageController); } if (CommandOptions != 0) { parms.Add(CommandOptions); } if (Buffering != 0) { parms.Add(Buffering); } if (Reconnect != 0) { parms.Add(Reconnect); } } if (types.HasFlag(OptionTypes.QueryOption)) { if (QueryOptions != null) { parms.Add(QueryOptions); } } return(parms.ToArray()); }
private void OnOptionToggled(object sender, ToggledArgs e) { TreeIter option; if (optionStore.GetIter(out option, new TreePath(e.Path))) { bool cur = (bool)optionStore.GetValue(option, 0); optionStore.SetValue(option, 0, !cur); OptionTypes ot = (OptionTypes)(int)optionStore.GetValue(option, 2); switch (ot) { case OptionTypes.BindingFlag: BindingFlags bf = (BindingFlags)(int)optionStore.GetValue(option, 3); if (!cur) { Finder.BindingFlags |= bf; } else { Finder.BindingFlags &= ~bf; } break; case OptionTypes.FindMemberTypes: FindMemberTypes fmt = (FindMemberTypes)(int)optionStore.GetValue(option, 3); if (!cur) { Finder.FindMembers |= fmt; } else { Finder.FindMembers &= ~fmt; } break; } } }
public void SetProcessor(OptionTypes type) { switch (type) { case OptionTypes.CheckBoxes: this.Processor = new Options.CheckBoxes(); break; case OptionTypes.DropDownList: this.Processor = new Options.DropDownList(); break; case OptionTypes.FileUpload: this.Processor = new Options.Html(); break; case OptionTypes.Html: this.Processor = new Options.Html(); break; case OptionTypes.RadioButtonList: this.Processor = new Options.RadioButtonList(); break; case OptionTypes.TextInput: this.Processor = new Options.TextInput(); break; } }
/// <summary> /// To calculate the option premium. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="strike">The strike price.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="riskFree">The risk free interest rate.</param> /// <param name="dividend">The dividend amount on shares.</param> /// <param name="deviation">Standard deviation.</param> /// <param name="timeToExp">The option period before the expiration.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <returns>The option premium.</returns> public static decimal Premium(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal dividend, decimal deviation, double timeToExp, double d1) { var sign = (optionType == OptionTypes.Call) ? 1 : -1; var expDiv = ExpRate(dividend, timeToExp); var expRate = ExpRate(riskFree, timeToExp); return (assetPrice * (decimal)(expDiv * NormalDistr(d1 * sign)) - strike * (decimal)(expRate * NormalDistr(D2(d1, deviation, timeToExp) * sign))) * sign; }
/// <summary> /// To get the main strike. /// </summary> /// <param name="underlyingAsset">Underlying asset.</param> /// <param name="securityProvider">The provider of information about instruments.</param> /// <param name="dataProvider">The market data provider.</param> /// <param name="expirationDate">The options expiration date.</param> /// <param name="optionType">Option type.</param> /// <returns>The main strike.</returns> public static Security GetCentralStrike(this Security underlyingAsset, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, DateTimeOffset expirationDate, OptionTypes optionType) { return underlyingAsset.GetCentralStrike(dataProvider, underlyingAsset.GetDerivatives(securityProvider, expirationDate).Filter(optionType)); }
/// <summary> /// To get an option for the underlying futures. /// </summary> /// <param name="future">Underlying futures.</param> /// <param name="provider">The provider of information about instruments.</param> /// <param name="strike">Strike.</param> /// <param name="expirationDate">The options expiration date.</param> /// <param name="optionType">Option type.</param> /// <returns>Options contract.</returns> public static Security GetOption(this Security future, ISecurityProvider provider, decimal strike, DateTimeOffset expirationDate, OptionTypes optionType) { if (future == null) throw new ArgumentNullException("future"); if (provider == null) throw new ArgumentNullException("provider"); var option = provider .Lookup(new Security { Strike = strike, OptionType = optionType, ExpiryDate = expirationDate, UnderlyingSecurityId = future.Id }) .FirstOrDefault(); if (option == null) throw new ArgumentException(LocalizedStrings.Str707Params.Put(future.Id), "future"); return option; }
/// <summary> /// To get the main strike. /// </summary> /// <param name="underlyingAsset">Underlying asset.</param> /// <param name="securityProvider">The provider of information about instruments.</param> /// <param name="dataProvider">The market data provider.</param> /// <param name="expirationDate">The options expiration date.</param> /// <param name="optionType">Option type.</param> /// <returns>The main strike.</returns> public static Security GetCentralStrike(this Security underlyingAsset, ISecurityProvider securityProvider, IMarketDataProvider dataProvider, DateTimeOffset expirationDate, OptionTypes optionType) { return(underlyingAsset.GetCentralStrike(dataProvider, underlyingAsset.GetDerivatives(securityProvider, expirationDate).Filter(optionType))); }
/// <summary> /// To change the option type for opposite. /// </summary> /// <param name="type">The initial value.</param> /// <returns>The opposite value.</returns> public static OptionTypes Invert(this OptionTypes type) { return(type == OptionTypes.Call ? OptionTypes.Put : OptionTypes.Call); }
/// <summary> /// To calculate the option rho. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="strike">The strike price.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="riskFree">The risk free interest rate.</param> /// <param name="deviation">Standard deviation.</param> /// <param name="timeToExp">The option period before the expiration.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <returns>Option rho.</returns> public static decimal Rho(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal deviation, double timeToExp, double d1) { var expRate = ExpRate(riskFree, timeToExp); var sign = optionType == OptionTypes.Call ? 1 : -1; return sign * (0.01m * strike * (decimal)(timeToExp * expRate * NormalDistr(sign * D2(d1, deviation, timeToExp)))); }
/// <summary> /// To calculate the option delta. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <returns>Option delta.</returns> public static decimal Delta(OptionTypes optionType, decimal assetPrice, double d1) { var delta = (decimal)NormalDistr(d1); if (optionType == OptionTypes.Put) delta -= 1; return delta; }
/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="_strike"></param> /// <param name="_exp"></param> /// <param name="_vol"></param> /// <param name="_premium">Price per 1 option</param> /// <param name="_quantity"></param> public ExchangeOption(OptionTypes _type, ushort _strike, DateTime _exp, double _vol, decimal _premium, int _quantity) :base(_type, _strike, _exp, _vol) { Premium = _premium; Quantity = _quantity; }
public async Task <IViewComponentResult> InvokeAsync(OptionTypes optionType) { List <Option> options = await _context.Options.Where(x => x.OptionType == optionType && x.BlackScholesPLPercent > 0).OrderBy(ViewData["sortProperty"].ToString(), ViewData["sortDirection"].ToString()).ToListAsync(); return(View("OptionsTable", options)); }
/// <summary> /// To calculate the option theta. /// </summary> /// <param name="optionType">Option type.</param> /// <param name="strike">The strike price.</param> /// <param name="assetPrice">Underlying asset price.</param> /// <param name="riskFree">The risk free interest rate.</param> /// <param name="deviation">Standard deviation.</param> /// <param name="timeToExp">The option period before the expiration.</param> /// <param name="d1">The d1 parameter of the option fulfilment probability estimating.</param> /// <param name="daysInYear">Days per year.</param> /// <returns>Option theta.</returns> public static decimal Theta(OptionTypes optionType, decimal strike, decimal assetPrice, decimal riskFree, decimal deviation, double timeToExp, double d1, decimal daysInYear = 365) { var nd1 = InvertD1(d1); var expRate = ExpRate(riskFree, timeToExp); var sign = optionType == OptionTypes.Call ? 1 : -1; return (-(assetPrice * deviation * (decimal)nd1) / (2 * (decimal)timeToExp.Sqrt()) - sign * (strike * riskFree * (decimal)(expRate * NormalDistr(sign * D2(d1, deviation, timeToExp))))) / daysInYear; }
public ProgramOption(OptionTypes type, string name, string description) { Type = type; Name = name; Description = description; }
/// <summary> /// To filter options by type <see cref="Security.OptionType"/>. /// </summary> /// <param name="options">Options to be filtered.</param> /// <param name="type">Option type.</param> /// <returns>Filtered options.</returns> public static IEnumerable <Security> Filter(this IEnumerable <Security> options, OptionTypes type) { return(options.Where(o => o.OptionType == type)); }
/// <summary> /// /// </summary> /// <param name="_type"></param> /// <param name="_strike"></param> /// <param name="_exp"></param> /// <param name="_vol"></param> /// <param name="_premium">Price per 1 option</param> /// <param name="_quantity"></param> public ExchangeOption(OptionTypes _type, ushort _strike, DateTime _exp, double _vol, decimal _premium, int _quantity) : base(_type, _strike, _exp, _vol) { Premium = _premium; Quantity = _quantity; }
/// <summary> /// To get an option for the underlying futures. /// </summary> /// <param name="future">Underlying futures.</param> /// <param name="provider">The provider of information about instruments.</param> /// <param name="strike">Strike.</param> /// <param name="expirationDate">The options expiration date.</param> /// <param name="optionType">Option type.</param> /// <returns>Options contract.</returns> public static Security GetOption(this Security future, ISecurityProvider provider, decimal strike, DateTimeOffset expirationDate, OptionTypes optionType) { if (future == null) { throw new ArgumentNullException(nameof(future)); } if (provider == null) { throw new ArgumentNullException(nameof(provider)); } var option = provider .Lookup(new Security { Strike = strike, OptionType = optionType, ExpiryDate = expirationDate, UnderlyingSecurityId = future.Id }) .FirstOrDefault(); if (option == null) { throw new ArgumentException(LocalizedStrings.Str707Params.Put(future.Id), nameof(future)); } return(option); }
private static Security CreateStrike(decimal strike, decimal oi, decimal iv, OptionTypes type, DateTime expiryDate, Security asset, decimal? lastTrade) { var s = new Security { Code = "RI {0} {1}".Put(type == OptionTypes.Call ? 'C' : 'P', strike), Strike = strike, OpenInterest = oi, ImpliedVolatility = iv, HistoricalVolatility = iv, OptionType = type, ExpiryDate = expiryDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id, LastTrade = lastTrade == null ? null : new Trade { Price = lastTrade.Value }, Volume = RandomGen.GetInt(10000) }; s.BestBid = new Quote(s, s.StepPrice ?? 1m * RandomGen.GetInt(100), s.VolumeStep ?? 1m * RandomGen.GetInt(100), Sides.Buy); s.BestAsk = new Quote(s, s.BestBid.Price.Max(s.StepPrice ?? 1m * RandomGen.GetInt(100)), s.VolumeStep ?? 1m * RandomGen.GetInt(100), Sides.Sell); return s; }
public static Option Factory(OptionTypes type) { Option result = new Option(); result.SetProcessor(type); return result; }
protected ConfigOption(OptionTypes optionType, string id, string label) { this.OptionType = optionType; this.Id = id; this.Label = label; }
/// <summary> /// To filter options by type <see cref="Security.OptionType"/>. /// </summary> /// <param name="options">Options to be filtered.</param> /// <param name="type">Option type.</param> /// <returns>Filtered options.</returns> public static IEnumerable<Security> Filter(this IEnumerable<Security> options, OptionTypes type) { return options.Where(o => o.OptionType == type); }
public static IBSocket SendOptionType(this IBSocket socket, OptionTypes? type) { return socket.Send(type == null ? string.Empty : type == OptionTypes.Call ? "C" : "P"); }
public OptionBase(string name, OptionTypes optionType, string lineText) { Name = name; OptionType = optionType; LineText = lineText; }
public object[] OptionParameters(OptionTypes types) { List<object> parms = new List<object>(); if (types.HasFlag(OptionTypes.DbOption)) { if (Connection != null) { parms.Add(Connection); } if (Transaction != null) { parms.Add(Transaction); } if (DataStorageController != null) { parms.Add(DataStorageController); } if (CommandOptions !=0) { parms.Add(CommandOptions); } if (Buffering != 0) { parms.Add(Buffering); } if (Reconnect != 0) { parms.Add(Reconnect); } } if (types.HasFlag(OptionTypes.QueryOption)) { if (QueryOptions != null) { parms.Add(QueryOptions); } } return parms.ToArray(); }