Class ResultsGroup

  • All Implemented Interfaces:
    com.strategyquant.lib.settings.IXMLAble, java.io.Serializable

    public class ResultsGroup
    extends java.lang.Object
    implements com.strategyquant.lib.settings.IXMLAble, java.io.Serializable
    The Class ResultsGroup.
    See Also:
    Serialized Form
    • Field Detail

      • Log

        public static final org.slf4j.Logger Log
        The Constant Log.
      • Portfolio

        public static final java.lang.String Portfolio
        The Constant Portfolio.
        See Also:
        Constant Field Values
      • MergedPortfolio

        public static final java.lang.String MergedPortfolio
        The Constant MergedPortfolio.
        See Also:
        Constant Field Values
      • WFResult

        public static final java.lang.String WFResult
        The Constant WFResult.
        See Also:
        Constant Field Values
      • AdditionalMarket

        public static final java.lang.String AdditionalMarket
        The Constant AdditionalMarket.
        See Also:
        Constant Field Values
      • updated

        public boolean updated
        The updated.
      • correlationPeriods

        public TimePeriods correlationPeriods
    • Constructor Detail

      • ResultsGroup

        public ResultsGroup​(java.lang.String resultName)
        Instantiates a new results group.
        Parameters:
        resultName - the result name
    • Method Detail

      • init

        public static void init()
        Inits the.
      • getName

        public java.lang.String getName()
        Gets the name.
        Returns:
        the name
      • setName

        public void setName​(java.lang.String name)
        Use this method only when creating a new strategy before saving.
        Parameters:
        name - the new name
      • addResultSymbol

        public void addResultSymbol​(java.lang.String resultKey,
                                    java.lang.String symbolName)
                             throws java.lang.Exception
        Adds the result symbol.
        Parameters:
        resultKey - the result key
        symbolName - the symbol name
        Throws:
        java.lang.Exception - the exception
      • subResult

        public Result subResult​(java.lang.String resultKey)
                         throws java.lang.Exception
        Sub result.
        Parameters:
        resultKey - the result key
        Returns:
        the result
        Throws:
        java.lang.Exception - the exception
      • getMainResultKey

        public java.lang.String getMainResultKey()
                                          throws java.lang.Exception
        Gets the main result key.
        Returns:
        the main result key
        Throws:
        java.lang.Exception - the exception
      • mainResult

        public Result mainResult()
                          throws java.lang.Exception
        Main result.
        Returns:
        the result
        Throws:
        java.lang.Exception - the exception
      • portfolio

        public Result portfolio()
                         throws java.lang.Exception
        Portfolio.
        Returns:
        the result
        Throws:
        java.lang.Exception - the exception
      • addSubresult

        public void addSubresult​(java.lang.String resultKey,
                                 SettingsMap settings)
                          throws java.lang.Exception
        Adds the subresult.
        Parameters:
        resultKey - the result key
        settings - the settings
        Throws:
        java.lang.Exception - the exception
      • addSubresult

        public void addSubresult​(java.lang.String resultKey,
                                 SettingsMap settings,
                                 Result result)
                          throws java.lang.Exception
        Adds the subresult.
        Parameters:
        resultKey - the result key
        settings - the settings
        result - the result
        Throws:
        java.lang.Exception - the exception
      • removeSubresult

        public void removeSubresult​(java.lang.String resultKey,
                                    boolean destroyRemovedResult)
                             throws java.lang.Exception
        Removes the subresult.
        Parameters:
        resultKey - the result key
        destroyRemovedResult - the destroy removed result
        Throws:
        java.lang.Exception - the exception
      • getResultKeys

        public java.util.List<java.lang.String> getResultKeys()
                                                       throws java.lang.Exception
        Gets the result keys.
        Returns:
        the result keys
        Throws:
        java.lang.Exception - the exception
      • additionalMarketKeys

        public java.util.List<java.lang.String> additionalMarketKeys()
                                                              throws java.lang.Exception
        Additional market keys.
        Returns:
        the list
        Throws:
        java.lang.Exception - the exception
      • hasResult

        public boolean hasResult​(java.lang.String resultKey)
                          throws java.lang.Exception
        Checks for result.
        Parameters:
        resultKey - the result key
        Returns:
        true, if successful
        Throws:
        java.lang.Exception - the exception
      • symbols

        public com.strategyquant.tradinglib.results.SymbolsMap symbols()
        returns symbols map.
        Returns:
        the symbols map
      • setDatabank

        public void setDatabank​(Databank databank)
        Sets the databank.
        Parameters:
        databank - the new databank
        Throws:
        java.lang.Exception - the exception
      • updateResults

        public void updateResults​(ResultsGroup newResults,
                                  boolean sendEvent)
                           throws java.lang.Exception
        updates this results group - it will completely replace everything in the old ResultsGroup with the new one .
        Parameters:
        newResults - the new results
        sendEvent - the send event
        Throws:
        java.lang.Exception - the exception
      • orders

        public OrdersList orders()
                          throws java.lang.Exception
        Orders.
        Returns:
        the orders list
        Throws:
        java.lang.Exception - the exception
      • getFilePath

        public java.lang.String getFilePath()
        Gets the file path.
        Returns:
        the file path
      • getDatabank

        public Databank getDatabank()
        Gets the databank.
        Returns:
        the databank
      • generateUniqueResultKeyName

        public java.lang.String generateUniqueResultKeyName​(java.lang.String resultKey)
                                                     throws java.lang.Exception
        Generate unique result key name.
        Parameters:
        resultKey - the result key
        Returns:
        the string
        Throws:
        java.lang.Exception - the exception
      • merge

        public static ResultsGroup merge​(java.util.ArrayList<ResultsGroup> results,
                                         java.lang.String[] excludedKeys,
                                         com.strategyquant.tradinglib.project.SQProject project)
                                  throws java.lang.Exception
        Merge.
        Parameters:
        results - the results
        excludedKeys - the excluded keys
        project - the project
        Returns:
        the results group
        Throws:
        java.lang.Exception - the exception
      • merge

        public static ResultsGroup merge​(ResultsGroup... results)
                                  throws java.lang.Exception
        merge multiple results groups into one and return it.
        Parameters:
        results - the results
        Returns:
        the results group
        Throws:
        java.lang.Exception - the exception
      • mergeWith

        public void mergeWith​(ResultsGroup rg)
                       throws java.lang.Exception
        Merge with.
        Parameters:
        rg - the rg
        Throws:
        java.lang.Exception - the exception
      • mergeWith

        public void mergeWith​(ResultsGroup rg,
                              java.lang.String[] excludedKeys)
                       throws java.lang.Exception
        Merge with.
        Parameters:
        rg - the rg
        excludedKeys - the excluded keys
        Throws:
        java.lang.Exception - the exception
      • isPortfolio

        public boolean isPortfolio()
                            throws java.lang.Exception
        Checks if is portfolio.
        Returns:
        true, if is portfolio
        Throws:
        java.lang.Exception - the exception
      • specialValues

        public SettingsMap specialValues()
        Special values.
        Returns:
        the settings map
      • getXML

        public org.jdom2.Element getXML()
        Gets the xml.
        Specified by:
        getXML in interface com.strategyquant.lib.settings.IXMLAble
        Returns:
        the xml
      • setFromXML

        public void setFromXML​(org.jdom2.Element element)
                        throws java.lang.Exception
        Sets the from XML.
        Specified by:
        setFromXML in interface com.strategyquant.lib.settings.IXMLAble
        Parameters:
        element - the new from XML
        Throws:
        java.lang.Exception - the exception
      • computeAllStats

        public void computeAllStats()
                             throws java.lang.Exception
        Compute all stats.
        Throws:
        java.lang.Exception - the exception
      • clone

        public ResultsGroup clone()
        Clone.
        Returns:
        the results group
      • getStrategyXml

        public org.jdom2.Element getStrategyXml()
                                         throws java.lang.Exception
        Gets the strategy xml.
        Returns:
        the strategy xml
        Throws:
        java.lang.Exception - the exception
      • setResultFileName

        public void setResultFileName​(java.lang.String fileName)
        Sets the result file name.
        Parameters:
        fileName - the new result file name
      • getParams

        public java.lang.String getParams()
        Gets the params.
        Returns:
        the params
      • getOriginalWFResultKey

        public java.lang.String getOriginalWFResultKey()
                                                throws java.lang.Exception
        Gets the orsiginal WF result key.
        Returns:
        the orsiginal WF result key
        Throws:
        java.lang.Exception - the exception
      • getChartCount

        public int getChartCount()
        Returns the chart count expected by strategy. Returns -1 if chart count cannot be resolved.
        Returns:
        the chart count
      • setLastSettings

        public void setLastSettings​(java.lang.String lastSettingsXml)
                             throws java.lang.Exception
        Sets the last settings.
        Parameters:
        lastSettingsXml - the new last settings
        Throws:
        java.lang.Exception - the exception
      • getLastSettings

        public java.lang.String getLastSettings()
                                         throws java.lang.Exception
        Gets the last settings.
        Returns:
        the last settings
        Throws:
        java.lang.Exception - the exception
      • createPortfolioResult

        public void createPortfolioResult()
                                   throws java.lang.Exception
        Creates the portfolio result.
        Throws:
        java.lang.Exception - the exception
      • createPortfolioResult

        public void createPortfolioResult​(java.lang.String initialBalanceType,
                                          com.strategyquant.tradinglib.project.SQProject project)
                                   throws java.lang.Exception
        if there are multiple results in this group, calling this method will create a portfolio out of them - which means summary result that contains all the other (non-special) results .
        Parameters:
        initialBalanceType - the initial balance type
        project - the project
        Throws:
        java.lang.Exception - the exception
      • recomputeMergedDailyEquity

        public it.unimi.dsi.fastutil.longs.Long2FloatRBTreeMap recomputeMergedDailyEquity()
                                                                                   throws java.lang.Exception
        Recompute merged daily equity.
        Returns:
        the long 2 float RB tree map
        Throws:
        java.lang.Exception - the exception
      • moveResultFrom

        public void moveResultFrom​(java.lang.String resultKey,
                                   ResultsGroup sourceRG,
                                   boolean makeSpecial)
                            throws java.lang.Exception
        Move result from.
        Parameters:
        resultKey - the result key
        sourceRG - the source RG
        makeSpecial - the make special
        Throws:
        java.lang.Exception - the exception
      • removeUnsavableSettings

        public void removeUnsavableSettings()
        go through all saved result settings and remove values that will be not saved to XML This will free memory of unused objects such as strategy or trading options objects that will never be used again.
      • getFitness

        public double getFitness()
        Gets the fitness.
        Returns:
        the fitness
      • getFitness

        public double getFitness​(byte sampleType)
        Gets the fitness.
        Parameters:
        sampleType - the sample type
        Returns:
        the fitness
      • getFingerprint

        public com.strategyquant.tradinglib.results.StrategyFingerprint getFingerprint()
        Gets the fingerprint.
        Returns:
        the fingerprint
      • lockRecord

        public ResultsGroup lockRecord​(java.lang.String lockingTask)
                                throws java.lang.Exception
        locks this ResultsGroup and returns it. If the lock cannot be acquired within 5 seconds it will throw an exception
        Parameters:
        lockingTask - the locking task
        Returns:
        the results group
        Throws:
        java.lang.Exception - the exception
      • lockRecord

        public ResultsGroup lockRecord​(int seconds,
                                       java.lang.String lockingTask)
                                throws java.lang.Exception
        Lock record.
        Parameters:
        seconds - the seconds
        lockingTask - the locking task
        Returns:
        the results group
        Throws:
        java.lang.Exception - the exception
      • releaseLock

        public void releaseLock​(java.lang.String lockingTask)
        Release lock.
        Parameters:
        lockingTask - the locking task
      • clear

        public void clear()
        Clear.
      • clearTempData

        public void clearTempData()
      • destroy

        public void destroy​(boolean removeStockChartsFile)
        Destroy.
        Parameters:
        removeStockChartsFile - the remove stock charts file
      • isFromAlgoWizard

        public boolean isFromAlgoWizard()
        Checks if is from algo wizard.
        Returns:
        true, if is from algo wizard
      • trySaveToFile

        public void trySaveToFile()
        Try save to file.
      • storesChartData

        public boolean storesChartData()
        Stores chart data.
        Returns:
        true, if successful
      • setOptimizationProfile

        public void setOptimizationProfile​(OptimizationProfile optimizationProfile)
        Sets the optimization profile.
        Parameters:
        optimizationProfile - the new optimization profile
      • getOptimizationProfile

        public OptimizationProfile getOptimizationProfile()
        Gets the optimization profile.
        Returns:
        the optimization profile
      • getBestWFResultKey

        public java.lang.String getBestWFResultKey()
        Gets the best WF result key.
        Returns:
        the best WF result key
      • getOOS

        public OutOfSample getOOS()
        Gets the oos.
        Returns:
        the oos
      • setOOSSettings

        public void setOOSSettings​(OutOfSample oos)
        Sets the OOS settings.
        Parameters:
        oos - the new OOS settings
      • getMergedResults

        public java.util.List<ResultsGroup> getMergedResults()
        Gets the merged results.
        Returns:
        the merged results
      • setMergedResults

        public void setMergedResults​(java.util.List<ResultsGroup> results)
        Sets the merged results.
        Parameters:
        results - the new merged results