本文整理汇总了C#中Bond.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Bond.SetProperty方法的具体用法?C# Bond.SetProperty怎么用?C# Bond.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bond
的用法示例。
在下文中一共展示了Bond.SetProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public IList<Trade> Import(Market market, Feed feed, StringBuilder sb, FilterData filterData)
{
var trades = new List<Trade>();
var infos = filterData.Data ?? TradeImportHelper.ReadData(FilterInfo, filterData, sb);
var dict = new Dictionary<TradeInfo, Trade>();
var symbols = new Dictionary<string, Product>();
if (filterData.Progress != null) filterData.Progress.AnalysisInit(infos.Count, "Building Products");
int count = 0;
//int skipped = 0;
foreach (var info in infos)
{
count++;
if (filterData.Progress != null) filterData.Progress.AnalysisProgress(count, "");
if (filterData.Progress != null && filterData.Progress.IsCanceled) return new List<Trade>();
if (FilterInfo(info)) continue;
var trade = new Trade();
if (!TradeImportHelper.InitTrade(trade, info, filterData, sb)) continue;
dict[info] = trade;
//trades.Add(trade);
var symbol = info.Symbol; // symbol is either cusip/isin, or r-symbol
if (symbol != null) symbol = symbol.Trim();
if (!string.IsNullOrEmpty(symbol))
{
var p = Env.Current.Trade.GetProductByCode(Product.CusipProductCode, symbol) ??
Env.Current.Trade.GetProductByCode(Product.IsinProductCode, symbol);
if (p == null)
{
if (symbols.Count < MaxBonds)
{
symbols[symbol] = null; // bond;
}
else dict[info] = null;//Remove it
}
else info.Security = p;
}
else
sb.Append(TradeImportHelper.FormatErrorMessage("Symbol is null", info.HoldingID, info.TradeID, info.Instrument));
}
if (filterData.Progress != null && filterData.Progress.IsCanceled) return new List<Trade>();
if (filterData.Progress != null) filterData.Progress.AnalysisDone();
//Now Get Bonds by Cusips and by Isins
var snapped = new List<Product>();
var exceptions = new List<Exception>();
if (symbols.Count > 0 && feed != null)
{
var prodcs = new List<Product>();
foreach (var s in symbols.Keys)
{
var bond = new Bond();
bond.SetProperty(Product.DefaultTicker, s);
prodcs.Add(bond);
}
sb.Append("Snapping Bonds By Symbol " + symbols.Count + " " + Utilities.ToString(new List<string>(symbols.Keys)) + "\n");
try{
FeedImportSecurityTaskExecutor.SnapProducts("Bond.FeedMapping.xml", prodcs, feed, exceptions, true, snapped);
}
catch (Exception x)
{
sb.Append(x.ToString());
}
}
foreach (var p in snapped)
{
var isin = p.Isin;
var cusip = p.Cusip;
if (p.Id > 0)
{
if (symbols.ContainsKey(isin))
symbols[isin] = p;
else if (symbols.ContainsKey(cusip))
symbols[cusip] = p;
}
}
if (snapped.Count > 0) sb.Append("Snapped " + snapped.Count + " bonds by Symbol\n");
var tempBondProvider = new BondTemplateProvider();
if (filterData.Progress != null) filterData.Progress.AnalysisInit(dict.Count, "Initializing Trades");
count = 0;
//int fxbcount = 0;
foreach (var kvp in dict)
{
if (filterData.Progress != null && filterData.Progress.IsCanceled) return new List<Trade>();
count++;
if (filterData.Progress != null) filterData.Progress.AnalysisProgress(count, "");
var info = kvp.Key;
var trade = kvp.Value;
if (trade == null)
{
//skipped++;
continue;
}
if (info.Security == null)
{
if (!string.IsNullOrEmpty(info.Symbol) && symbols.ContainsKey(info.Symbol))
{
info.Security = symbols[info.Symbol];
}
}
//.........这里部分代码省略.........