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


C# IAsset.getPrice方法代码示例

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


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

示例1: 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

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