Beispiel #1
0
        }//filterSecuritiesForNewPortfolio

        #endregion Filter Methods

        #region General

        public void setDisabledSecsToActive()
        { // Sets disabled securities back to active state
            // Loop through list of disabled securities and setting them to active state
            for (int iSecs = 0; iSecs < m_colDisabledSecurities.Count; iSecs++)
            {
                m_colDisabledSecurities[iSecs].setSecurityActivity(true);
            }

            // Clear DisabledSecs collection
            m_colDisabledSecurities.Clear();

            // Clear DisabledSecs collection
            m_colActiveSecurities = m_colFullCollection.getListOfActiveSecs(); // Creates active securities list
        }//setDisabledSecsToActive
Beispiel #2
0
        }//clearCalcData

        #endregion Constructors, Initialization & Destructor

        #region Methods

        #region New methods

        public double[,] calcRiskAndCovariance(cDateRange drPeriod, ref ISecurities cSecsCol, Boolean isMatrix, Boolean isBacktest)
        { // Runs the main covariance calculation (including covariance matrix)
            ///  The matrix's first dimension represents the variables (securities)C:\Users\uriel\Documents\Applications\Cherries\Classes\
            ///  The matrix's second dimension represents the observations (history)
            try
            {
                if (isBacktest)
                {
                    for (int iSer = 0; iSer < cSecsCol.Count; iSer++)
                    {
                        cSecsCol[iSer].RatesClass.setUpdatedRateData(drPeriod);
                    }
                }
                else
                {
                    for (int iSer = 0; iSer < cSecsCol.Count; iSer++)
                    {
                        cSecsCol[iSer].RatesClass.setFinalReturnFromServer(drPeriod);
                    }
                }

                cSecsCol = cSecsCol.getListOfActiveSecs();
                for (int iSecs = 0; iSecs < cSecsCol.Count; iSecs++)
                {
                    cSecsCol[iSecs].CovarClass.setCalculationStatistics(isBacktest);
                }

                cSecsCol = cSecsCol.getListOfActiveSecs();
                if (isMatrix)
                {
                    calculateNewCovarianceMatrix(cSecsCol, isBacktest);
                }
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
            return(m_dCovarMatrix);
        }//runMainCalculation
Beispiel #3
0
        private void fillCollectionsFromStaticData()
        { // Loads collections of securities from the static data
            try
            {
                // Init
                if (StaticData <cSecurity, ISecurities> .lst == null)
                { // init Static collection if it is empty
                    DateTime lastUpdate = DateTime.MinValue;
                    SetSecurites();
                }

                //////// Compare to portfolio securities
                //////List<cSecurity> lstSecs = null;


                //*****************************************************************************
                //var portfolioSecurities = m_objPortfolio.Details.SecurityData.Select(x => x.idSecurity).ToList();
                //if ((portfolioSecurities == null) || (portfolioSecurities.Count == 0))
                //*****************************************************************************


                //////lstSecs = StaticData<cSecurity, ISecurities>.lst.Where(x => exchanges.Contains(x.Properties.Market.ID)).ToList();


                //*****************************************************************************
                // Merge collections
                //if (lstSecs != null)
                //{ // Portfolio securities found = we limit our collections to portfolio securities
                //    //lstSecs = new List<TFI.BusinessLogic.Securities.cSecurity>();
                //    lstSecs = (from l in StaticData<cSecurity, ISecurities>.lst
                //               join li in portfolioSecurities
                //               on l.Properties.PortSecurityId equals li
                //               select l).ToList();

                //    var notInMemory = portfolioSecurities.Where(x => !lstSecs.Any(s => s.Properties.PortSecurityId == x)).ToList();
                //    var parallelList = new ConcurrentBag<cSecurity>();
                //    List<Security> secs = new List<Security>();
                //    securityRepository.Execute(session =>
                //    {
                //        secs = AutoMapper.Mapper.Map<List<Security>>(session.Query<Entities.dbo.TopSecurities>().Where(x => notInMemory.Contains(x.idSecurity)));
                //    });
                //    Parallel.ForEach(secs, s =>
                //    {
                //        var CurrentSec = getCurrSecurity(s, m_objPortfolio);
                //        parallelList.Add(CurrentSec);
                //    });
                //    lstSecs.AddRange(parallelList);
                //}//main if
                //*****************************************************************************

                // Set final collections
                m_colFullCollection.Securities.AddRange(StaticData <cSecurity, ISecurities> .lst); // (lstSecs);
                m_colSecurities.Securities.AddRange(StaticData <cSecurity, ISecurities> .lst);     // (lstSecs);
                m_colActiveSecurities = m_colSecurities.getListOfActiveSecs();                     //LR: at this point all securities are active.

                for (int i = 0; i < m_colSecurities.Securities.Count; i++)
                { // Init collection securities
                    m_colSecurities.Securities[i].Init(m_objPortfolio);
                    m_colFullCollection.Securities[i].Init(m_objPortfolio);
                }
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
        }//fillCollectionsFromStaticData