当前位置: 首页>>代码示例>>C#>>正文


C# Bond.SetProperty方法代码示例

本文整理汇总了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];
                    }
                }
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:BondImporter.cs


注:本文中的Bond.SetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。