コード例 #1
0
ファイル: Coordinator.cs プロジェクト: zhangz/QuantSA
        /// <summary>
        /// Initializes the simulators by telling them at which dates they will need to provide which market indices.
        /// </summary>
        /// <param name="valueDate"></param>
        /// <param name="portfolio"></param>
        /// <param name="fwdDates">Extra dates over and above the contract dates where the simulators will need to
        /// provide their indices.  This is likely to be forward values required in EPE and PFE profiles.</param>
        /// <param name="numeraireSimulator"></param>
        /// <param name="mappedSimulators"></param>
        /// <param name="availableSimulators"></param>
        private static void PrepareSimulators(Date valueDate, List <IProduct> portfolio, List <Date> fwdDates,
                                              NumeraireSimulator numeraireSimulator, Dictionary <MarketObservable, Simulator> mappedSimulators,
                                              List <Simulator> availableSimulators)
        {
            // Reset all the simulators
            foreach (var simulator in availableSimulators)
            {
                simulator.Reset();
            }

            // Set up the simulators for the times at which they will be queried
            foreach (var product in portfolio)
            {
                product.SetValueDate(valueDate);
                // Tell the simulators at what times indices will be required.
                foreach (var index in product.GetRequiredIndices())
                {
                    var requiredTimes = product.GetRequiredIndexDates(index);
                    mappedSimulators[index].SetRequiredDates(index, requiredTimes);
                    mappedSimulators[index].SetRequiredDates(index, fwdDates);
                }

                // Tell the numeraire simulator at what times it will be required.
                // Tell the FX simulators at what times they will be required.
                foreach (var ccy in product.GetCashflowCurrencies())
                {
                    var requiredDates = product.GetCashflowDates(ccy);
                    numeraireSimulator.SetNumeraireDates(requiredDates);
                    numeraireSimulator.SetNumeraireDates(fwdDates);
                    if (ccy != numeraireSimulator.GetNumeraireCurrency())
                    {
                        var ccyPair = GetCcyPair(numeraireSimulator, ccy);
                        mappedSimulators[ccyPair].SetRequiredDates(ccyPair, requiredDates);
                        mappedSimulators[ccyPair].SetRequiredDates(ccyPair, fwdDates);
                    }
                }

                foreach (var simulator in availableSimulators)
                {
                    simulator.Prepare(valueDate);
                }
                numeraireSimulator.Prepare(valueDate);
            }

            // Prepare all the simulators
            foreach (var simulator in availableSimulators)
            {
                simulator.Prepare(valueDate);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes the simulators by telling them at which dates they will need to provide which market indices.
        /// </summary>
        /// <param name="extraDates">Extra dates over and above the contract dates where the simulators will need to
        /// provide their indices.</param>
        private void InitializeSimulators(List <Product> portfolio, List <Date> extraDates)
        {
            // Reset all the simulators
            foreach (Simulator simulator in simulators)
            {
                simulator.Reset();
            }

            // Set up the simulators for the times at which they will be queried
            foreach (Product product in portfolio)
            {
                product.SetValueDate(valueDate);
                // Tell the simulators at what times indices will be required.
                foreach (MarketObservable index in product.GetRequiredIndices())
                {
                    List <Date> requiredTimes = product.GetRequiredIndexDates(index);
                    simulators[indexSources[index]].SetRequiredDates(index, requiredTimes);
                    simulators[indexSources[index]].SetRequiredDates(index, extraDates);
                }
                // Tell the nummeraire simulator at what times it will be required.
                // Tell the FX simulators at what times they will be required.
                foreach (Currency ccy in product.GetCashflowCurrencies())
                {
                    List <Date> requiredDates = product.GetCashflowDates(ccy);
                    numeraire.SetNumeraireDates(requiredDates);
                    numeraire.SetNumeraireDates(extraDates);
                    if (ccy != numeraire.GetNumeraireCurrency())
                    {
                        MarketObservable index = new CurrencyPair(ccy, numeraire.GetNumeraireCurrency());
                        simulators[indexSources[index]].SetRequiredDates(index, requiredDates);
                        simulators[indexSources[index]].SetRequiredDates(index, extraDates);
                    }
                }
            }

            // Prepare all the simulators
            foreach (Simulator simulator in simulators)
            {
                simulator.Prepare();
            }
        }