• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# OptionType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中OptionType的典型用法代码示例。如果您正苦于以下问题:C# OptionType类的具体用法?C# OptionType怎么用?C# OptionType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OptionType类属于命名空间,在下文中一共展示了OptionType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PriceEuropeanOption

 // 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;
 }
开发者ID:bytefire,项目名称:QuantRecipes,代码行数:30,代码来源:MonteCarloEngine.cs


示例2: Option

        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();
        }
开发者ID:Autoaddress-AA2,项目名称:autoaddress2.0-sdk-net,代码行数:32,代码来源:Option.cs


示例3: AVM2Argument

        /// <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;
            }
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:33,代码来源:AVM2Argument.cs


示例4: DynamicOption

 public DynamicOption(string name, OptionType expectedType, bool isRequired, IEnumerable<object> permittedValues)
 {
     Name = name;
     ExpectedType = expectedType;
     IsRequired = isRequired;
     PermittedValues = permittedValues;
 }
开发者ID:notgerry,项目名称:oneget,代码行数:7,代码来源:DynamicOption.cs


示例5: Option

 public Option(OptionType Type, bool OnlineOnly, string Name, Uri ImageUrl)
 {
     this.Type = Type;
     this.OnlineOnly = OnlineOnly;
     this.Name = Name;
     this.ImageUrl = ImageUrl;
 }
开发者ID:TomekJurkowski,项目名称:ZPP-wazniak4ever,代码行数:7,代码来源:Option.cs


示例6: FxOption

 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;
 }
开发者ID:nashp,项目名称:OptionPricing,代码行数:7,代码来源:FXOption.cs


示例7: OptionItem

        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;

            }
        }
开发者ID:kenkendk,项目名称:gnuplot-columns,代码行数:26,代码来源:Options.cs


示例8: add

        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
开发者ID:raphaelivo,项目名称:a-webshop,代码行数:25,代码来源:option_typesController.cs


示例9: update

        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
开发者ID:raphaelivo,项目名称:a-webshop,代码行数:34,代码来源:option_typesController.cs


示例10: ProfileOption

 public ProfileOption(MenuType menuType, string id, OptionType type, string value)
 {
     MenuType = menuType;
     Id = id;
     Type = type;
     Value = value;
 }
开发者ID:BEEBEEISADOG,项目名称:OKTRAIO,代码行数:7,代码来源:ChampionProfiles.cs


示例11: loadCharSkill

    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;
    }
开发者ID:Devnithz,项目名称:RPG-1,代码行数:33,代码来源:BoxAction.cs


示例12: Price

        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();
        }
开发者ID:joelhoro,项目名称:JHLib,代码行数:27,代码来源:BlackScholes.cs


示例13: AbstractOption

        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());                
        }
开发者ID:vetesii,项目名称:7k,代码行数:8,代码来源:Options.cs


示例14: OptionInfo

 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;
 }
开发者ID:RubensYamamoto,项目名称:Mestrado,代码行数:8,代码来源:OptionInfo.cs


示例15: OptionSpec

 public OptionSpec(string name, OptionType valueType, string helpText, bool isRequired, string valueText = null)
 {
    Name = name;
    ValueType = valueType;
    HelpText = helpText;
    IsRequired = isRequired;
    ValueText = valueText;
 }
开发者ID:logikonline,项目名称:AlphaVSS,代码行数:8,代码来源:OptionSpec.cs


示例16: PriceWithMarketData

        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);
        }
开发者ID:alexvictoor,项目名称:PricerTuto,代码行数:8,代码来源:Pricer.cs


示例17: AnalyzeOptionInfo

 public AnalyzeOptionInfo(string fullName, 
     string description,
     OptionType optionType)
 {
     FullName = fullName;
     Description = description;
     OptionType = optionType;
 }
开发者ID:kocharyan-ani,项目名称:random_networks_explorer,代码行数:8,代码来源:AnalyzeOptionInfo.cs


示例18: EquityOptionStaticData

 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;
 }
开发者ID:RubensYamamoto,项目名称:Mestrado,代码行数:9,代码来源:EquityOptionStaticData.cs


示例19: Option

 protected Option(IUnderlying underlying, DateTime expirationDate, OptionType callOrPut, decimal strike,
     decimal premium)
 {
     Underlying = underlying;
     ExpirationDate = expirationDate;
     CallOrPut = callOrPut;
     Strike = strike;
     Premium = premium;
 }
开发者ID:g0t4,项目名称:Presentations,代码行数:9,代码来源:Option.cs


示例20: Option

 public Option()
 {
     _price = 50.0;
     _strike = 50.0;
     _rate = 0.06;
     _dividend = 0.0;
     _timeToMaturity = 1;
     _type = OptionType.Call;
     _exercise = OptionExercise.European;
 }
开发者ID:bytefire,项目名称:QuantRecipes,代码行数:10,代码来源:Option.cs



注:本文中的OptionType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Optional类代码示例发布时间:2022-05-24
下一篇:
C# OptionSet类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap