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