Esempio n. 1
0
        public XlMarket(MarketInfo marketInfo)
        {
            MarketDataDefinition[] rawDefinitions;
            MarketDataDefinition[] ripeDefinitions;
            _marketInfo = marketInfo;
            marketInfo.GetClassifiedDefinitions(out rawDefinitions, out ripeDefinitions);
            _mktDataDict = ripeDefinitions.ToDictionary(x => x.Name, x => x);
            foreach (var marketDataDefinition in rawDefinitions)
            {
                _mktDataDict[marketDataDefinition.Name] = marketDataDefinition;
            }

            var historicalIndexRates = new Dictionary <IndexType, SortedDictionary <Date, double> >();

            if (marketInfo.HistoricalIndexRates != null && marketInfo.HistoricalIndexRates.Any())
            {
                foreach (var historicalIndexKey in marketInfo.HistoricalIndexRates.Keys)
                {
                    var indexKey = historicalIndexKey.ToIndexType();
                    var historicalIndexDateDic = new SortedDictionary <Date, double>();
                    foreach (var historicalIndexDateKey in marketInfo.HistoricalIndexRates[historicalIndexKey].Keys)
                    {
                        historicalIndexDateDic.Add(historicalIndexDateKey.ToDate(),
                                                   marketInfo.HistoricalIndexRates[historicalIndexKey][historicalIndexDateKey]);
                    }
                    historicalIndexRates.Add(indexKey, historicalIndexDateDic);
                }
            }
            else
            {
                historicalIndexRates = XlUdf.HistoricalIndexRates;
            }

            _qdpMarket = new QdpMarket(marketInfo.MarketName, marketInfo.ReferenceDate.ToDate(), historicalIndexRates, ripeDefinitions);
            var result = _qdpMarket.UpdateMarketRawData(rawDefinitions);

            result.WaitTillFinished();
        }