Class ResultsGroup

java.lang.Object
com.strategyquant.tradinglib.ResultsGroup
All Implemented Interfaces:
com.strategyquant.lib.settings.IXMLAble, Serializable

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

    • Log

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

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

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

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

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

      public boolean updated
      The updated.
    • correlationPeriods

      public TimePeriods correlationPeriods
      Correlation periods.
  • Constructor Details

    • ResultsGroup

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

    • init

      public static void init()
      Inits the.
    • getName

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

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

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

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

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

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

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

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

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

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

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

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

      public boolean hasResult(String resultKey) throws Exception
      Checks for result.
      Parameters:
      resultKey - the result key
      Returns:
      true, if successful
      Throws:
      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:
      Exception - the exception
    • updateResults

      public void updateResults(ResultsGroup newResults, boolean sendEvent) throws 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:
      Exception - the exception
    • orders

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

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

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

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

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

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

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

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

      public void mergeWith(ResultsGroup rg, String[] excludedKeys) throws Exception
      Throws:
      Exception
    • mergeWith

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

      public boolean isPortfolio() throws Exception
      Checks if is portfolio.
      Returns:
      true, if is portfolio
      Throws:
      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 Exception
      Sets the from XML.
      Specified by:
      setFromXML in interface com.strategyquant.lib.settings.IXMLAble
      Parameters:
      element - the new from XML
      Throws:
      Exception - the exception
    • computeAllStats

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

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

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

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

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

      public String getOriginalWFResultKey() throws Exception
      Gets the orsiginal WF result key.
      Returns:
      the orsiginal WF result key
      Throws:
      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(String lastSettingsXml) throws Exception
      Sets the last settings.
      Parameters:
      lastSettingsXml - the new last settings
      Throws:
      Exception - the exception
    • getLastSettings

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

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

      public void createPortfolioResult(String initialBalanceType, SQProject project) throws 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:
      Exception - the exception
    • recomputeMergedDailyEquity

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

      public void moveResultFrom(String resultKey, ResultsGroup sourceRG, boolean makeSpecial) throws Exception
      Move result from.
      Parameters:
      resultKey - the result key
      sourceRG - the source RG
      makeSpecial - the make special
      Throws:
      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 InSample fitness. Note - this method returns InSample fitness, not Full sample! It is used in Databank filters and genetic evolutions.
      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(String lockingTask) throws 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:
      Exception - the exception
    • lockRecord

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

      public void releaseLock(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(com.strategyquant.tradinglib.optimization.OptimizationProfile optimizationProfile)
      Sets the optimization profile.
      Parameters:
      optimizationProfile - the new optimization profile
    • getOptimizationProfile

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

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

      public com.strategyquant.tradinglib.strategy.OutOfSample getOOS()
      Gets the oos.
      Returns:
      the oos
    • setOOSSettings

      public void setOOSSettings(com.strategyquant.tradinglib.strategy.OutOfSample oos)
      Sets the OOS settings.
      Parameters:
      oos - the new OOS settings
    • getMergedResults

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

      public void setMergedResults(List<ResultsGroup> results)
      Sets the merged results.
      Parameters:
      results - the new merged results
    • isStockpickerStrategy

      public boolean isStockpickerStrategy()
    • setNote

      public void setNote(String note)
    • getNote

      public String getNote()
    • getNote

      public String getNote(String defaultNote)