当前位置: 首页>>代码示例>>C#>>正文


C# IAsset.getName方法代码示例

本文整理汇总了C#中IAsset.getName方法的典型用法代码示例。如果您正苦于以下问题:C# IAsset.getName方法的具体用法?C# IAsset.getName怎么用?C# IAsset.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAsset的用法示例。


在下文中一共展示了IAsset.getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: computeCorrelationAndVol

        protected static Tuple<double[,], double[]> computeCorrelationAndVol(DateTime priceDate, IAsset underlying, ICurrency cur, int date_nb)
        {
            List<DateTime> dates_correl = new List<DateTime>();
            int total = 0, real = 0; // current number of date : total also have not taken dates cause week end
            while (real < date_nb)
            {
                DateTime curr_date = priceDate - TimeSpan.FromDays(total);
                if (!(curr_date.DayOfWeek == DayOfWeek.Saturday || curr_date.DayOfWeek == DayOfWeek.Sunday))
                {
                    dates_correl.Add(curr_date);
                    real++;
                }
                total++;
            }
            // get the prices from database
            Dictionary<DateTime, double> hist_correl = AccessDB.Get_Asset_Price(underlying.getName(), dates_correl);
            // transform the Tuple format to double[,] format
            double[,] hist_correl_double = new double[2, date_nb];
            int j = 0;
            foreach (DateTime d in dates_correl)
            {
                hist_correl_double[0, j] = hist_correl[d];
                j++;
            }
            j = 0;
            foreach (DateTime d in dates_correl)
            {
                hist_correl_double[1, j] = 1 / cur.getChangeToEuro(d);
                j++;
            }

            // compute correl and vol using C++ functions
            Wrapping.Tools tools = new Wrapping.Tools();
            double[,] correl = new double[2, 2];
            double[] vol = new double[2];
            tools.getCorrelAndVol(date_nb, 2, hist_correl_double, correl, vol);
            return new Tuple<double[,], double[]>(correl, vol);
        }
开发者ID:bonkoskk,项目名称:peps,代码行数:38,代码来源:AQuanto.cs

示例2: sell

 public void sell(IAsset asset, int number)
 {
     // manage C# portfolio
     double price = asset.getPrice();
     Hedging_Portfolio.removeAsset(asset, number);
     cash += price * number;
     Operations_History.AddFirst(new Operation.Operation(DateTime.Now, "sell", asset, number, asset.getPrice()));
     // manage BD portfolio
     if (asset is Equity)
     {
         int asset_id = Access.GetIdFromName(asset.getName());
         double total = Access.getPortfolioComposition(asset_id, DateTime.Today);
         AccessBD.Write.storePortfolioComposition(DateTime.Today, asset_id, total - number);
         AccessDB.setHedgingPortfolioValue(DateTime.Today, (Hedging_Portfolio.getPrice() + cash));
         Write.storeCashValue(DateTime.Today, cash);
     }
     else if (asset is Currency)
     {
         int cur_id = Access.getForexIdFromCurrency(((Currency)asset).getEnum());
         double total = Access.getPortfolioComposition(cur_id, DateTime.Today);
         Write.storePortfolioComposition(DateTime.Today, cur_id, total - number);
         AccessDB.setHedgingPortfolioValue(DateTime.Today, Hedging_Portfolio.getPrice() + cash);
         Write.storeCashValue(DateTime.Today, cash);
     }
 }
开发者ID:bonkoskk,项目名称:peps,代码行数:25,代码来源:ModelManage.cs

示例3: buy

 public void buy(IAsset asset, int number)
 {
     double price = asset.getPriceEuro(DateTime.Today);
     if (price * number < cash)
     {
         // manage C# portfolio
         Hedging_Portfolio.addAsset(asset, number);
         cash -= price * number;
         Operations_History.AddFirst(new Operation.Operation(DateTime.Now, "buy", asset, number, asset.getPrice()));
         // manage BD portfolio
         if (asset is Equity) {
             int asset_id = Access.GetIdFromName(asset.getName());
             double total = Access.getPortfolioComposition(asset_id, DateTime.Today);
             AccessBD.Write.storePortfolioComposition(DateTime.Today, asset_id, total + number);
             AccessDB.setHedgingPortfolioValue(DateTime.Today, (Hedging_Portfolio.getPrice() + cash));
             Write.storeCashValue(DateTime.Today, cash);
         }
         else if (asset is Currency)
         {
             int cur_id = Access.getForexIdFromCurrency(((Currency)asset).getEnum());
             double total = Access.getPortfolioComposition(cur_id, DateTime.Today);
             Write.storePortfolioComposition(DateTime.Today, cur_id, total + number);
             AccessDB.setHedgingPortfolioValue(DateTime.Today, Hedging_Portfolio.getPrice() + cash);
             Write.storeCashValue(DateTime.Today, cash);
         }
     }
     else
     {
         throw new ArgumentOutOfRangeException("Not enough cash to buy asset(s)");
     }
 }
开发者ID:bonkoskk,项目名称:peps,代码行数:31,代码来源:ModelManage.cs


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