本文整理汇总了C#中CarbonClient.GetStaticDataAsync方法的典型用法代码示例。如果您正苦于以下问题:C# CarbonClient.GetStaticDataAsync方法的具体用法?C# CarbonClient.GetStaticDataAsync怎么用?C# CarbonClient.GetStaticDataAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CarbonClient
的用法示例。
在下文中一共展示了CarbonClient.GetStaticDataAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateData
public async Task PopulateData(CarbonClient cc_)
{
var data = await cc_.GetStaticDataAsync(identifier: Identifier);
if (data == null || data.Count == 0) return;
foreach (var kvp in data[0].Properties)
{
switch (kvp.Key)
{
case "desc":
Description = kvp.Value.AsString();
break;
case "firstTradeDt":
FirstTrade = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "lastTradeDt":
LastTrade = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "firstNoticeDt":
FirstNotice = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "expirationDt":
Expiration = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "lastDeliveryDt":
LastDelivery = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
}
}
}
示例2: populateData
public async Task populateData(CarbonClient cc_)
{
var data =
await
cc_.GetStaticDataAsync(
identifier: Identifier,
type: "futures_chains",
options: new Options {IdentifierType = IdentifierType});
if (data == null || data.Count==0 ) return;
if (data[0].Properties != null)
{
foreach (var item in data[0].Properties)
{
switch (item.Key)
{
case "desc":
Description = item.Value.AsString();
break;
case "exch":
Exchange = item.Value.AsString();
break;
case "bbgStart":
BbgStart = item.Value.AsString();
break;
case "bbgSuffix":
BbgEnd = item.Value.AsString();
break;
case "ricChain":
RicChain = item.Value.AsString();
break;
}
}
}
if (data[0].Series != null)
{
m_contracts =
(from item in data[0].Series where item.ContainsKey("ident") select new CarbonFuture(item["ident"].AsString()))
.ToList();
}
}
示例3: populate
private async Task populate(CarbonClient cc_)
{
await populateDates(cc_);
// at the moment, carbon can't give me the list of cmt bonds for 'today' so need to get as of yesterday
var bonds =
await
cc_.GetTimeSeriesAsync(Market.CarbonName(), "cmt-bonds", Yesterday.AsOf);
//var blah =
// await cc_.GetTimeSeriesAsync("US7YT=TWEB", "Snap", null, null, new TimeSeriesOptions {IdentifierType = "RIC"});
if (!bonds.Any())
{
Logger.Error(
string.Format("Did not get any response from carbon asking for cmt-bonds for market {0}", Market.CarbonName()),
typeof (BondMarket));
return;
}
MessagePackObject mpo;
if (bonds[0].Series[0].TryGetValue("cmtBonds", out mpo) == false || !mpo.IsList)
return;
var bondDict = new Dictionary<string, Bond>();
foreach (var v in mpo.AsList())
{
var dict = v.AsDictionary();
var bond = new Bond
{
OwningMarket = this,
};
foreach (var key in dict.Keys)
{
switch (key.AsString())
{
case "isin":
bond.Isin = dict[key].AsString();
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);
}
//.........这里部分代码省略.........