本文整理汇总了C#中CarbonClient.SubscribeToMarketData方法的典型用法代码示例。如果您正苦于以下问题:C# CarbonClient.SubscribeToMarketData方法的具体用法?C# CarbonClient.SubscribeToMarketData怎么用?C# CarbonClient.SubscribeToMarketData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CarbonClient
的用法示例。
在下文中一共展示了CarbonClient.SubscribeToMarketData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: populate
//.........这里部分代码省略.........
break;
case "term":
bond.Term = dict[key].AsDouble();
break;
case "aswyylambda":
bond.ASWyyLambda = dict[key].AsDouble();
break;
case "yieldlamda":
bond.YieldLambda = dict[key].AsDouble();
break;
case "zspreadlambda":
bond.ZSpreadLambda = dict[key].AsDouble();
break;
}
}
if (!string.IsNullOrEmpty(bond.Isin))
{
bondDict[bond.Isin] = bond;
}
}
m_bonds = bondDict;
// need to get some more static data about the bonds
var dateSetups = new[]
{
new Tuple<string, Action<Bond, DateTime>>("maturityDt", (bs, date) => bs.Maturity = date),
new Tuple<string, Action<Bond, DateTime>>("issueDt", (bs, date) => bs.IssueDate= date),
new Tuple<string, Action<Bond, DateTime>>("firstCpnDt", (bs, date) => bs.FirstCouponDate= date),
new Tuple<string, Action<Bond, DateTime>>("effectiveDt", (bs, date) => bs.EffectiveDate= date),
};
var dblSetups = new[]
{
new Tuple<string, Action<Bond, double>>("cpnRate", (bs, dbl) => bs.Coupon = dbl),
};
var statics = await cc_.GetStaticDataAsync(m_bonds.Keys, "static-bond");
foreach (var s in statics)
{
var isin = s.Identifier;
Bond bs;
if (m_bonds.TryGetValue(isin, out bs) == false)
continue;
DateTime dt;
foreach (var setup in dateSetups)
{
var strVal = s.Properties.GetString(setup.Item1);
if (DateTime.TryParseExact(strVal, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
setup.Item2(bs, dt);
}
foreach (var setup in dblSetups)
{
var dblVal = s.Properties.GetDouble(setup.Item1);
if (dblVal.HasValue)
setup.Item2(bs, dblVal.Value);
}
}
var histPrices =
await cc_.GetTimeSeriesAsync(m_bonds.Keys, Market.CarbonCloseSnapCollection(), DateTime.Today.AddMonths(-2));
foreach (var v in histPrices.Where(x=>x.Series!=null))
{
var isin = v.Identifier;
Bond bs;
if (m_bonds.TryGetValue(isin, out bs) == false)
continue;
var px = new SortedDictionary<DateTime, double>();
foreach (var obj in v.Series.Where(x=>x.ContainsKey("close") && x.ContainsKey("date")))
{
var strVal = obj.GetString("date");
DateTime dt;
double? dblVal;
if (DateTime.TryParseExact(strVal, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)
&& (dblVal = obj.GetDouble("close")).HasValue)
px[dt] = dblVal.Value;
}
if (px.Count > 0)
bs.HistoricPrices = new DatedDataCollectionGen<double>(px.Keys.ToArray(), px.Values.ToArray());
Logger.Debug(v.Series.ToString(), typeof (BondMarket));
}
m_priceSub = cc_.SubscribeToMarketData(m_bonds.Keys.ToList(),handlePriceCallback);
}