本文整理汇总了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);
}
示例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);
}
}
示例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)");
}
}