Class SQStats

  • All Implemented Interfaces:
    com.strategyquant.lib.settings.IXMLAble, com.strategyquant.lib.utils.ISQCloneable<SQStats>

    public class SQStats
    extends java.lang.Object
    implements com.strategyquant.lib.settings.IXMLAble, com.strategyquant.lib.utils.ISQCloneable<SQStats>
    Class holding computed strategy stats and metrics in an efficient hash map. It contains methods set(key, value) and get(key), where key is the reference to the computed metrics - it is a name of the class snippet, for example "NetProfit". See class StatsKey for an (incomplete) list of possible keys.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.slf4j.Logger Log
      The Constant Log.
    • Constructor Summary

      Constructors 
      Constructor Description
      SQStats()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearData()
      Clear data.
      boolean containsKey​(java.lang.String key)
      Contains key.
      void copyValueFrom​(SQStats sourceStats, java.lang.String key)
      Copy value from.
      void copyValuesFrom​(SQStats sourceStats)
      Copy values from.
      void deserialize​(java.io.ObjectInput dis)
      Deserialize.
      SQStats getClone()
      Gets the clone.
      double getDouble​(java.lang.String key)
      Gets the double.
      double getDouble​(java.lang.String key, double valueIfNotFound)
      Gets the double.
      int getInt​(java.lang.String key)
      Gets the int.
      int getInt​(java.lang.String key, int valueIfNotFound)
      Gets the int.
      long getLong​(java.lang.String key)
      Gets the long.
      long getLong​(java.lang.String key, long valueIfNotFound)
      Gets the long.
      org.jdom2.Element getXML()
      Gets the xml.
      org.jdom2.Element getXMLOptimizedFormat()
      Gets the XML optimized format.
      void serialize​(java.io.ObjectOutput dos)
      Serialize.
      void set​(java.lang.String key, double value)
      Sets the.
      void set​(java.lang.String key, int value)
      Sets the.
      void set​(java.lang.String key, long value)
      Sets the.
      void set​(java.lang.String key, java.lang.Object value)
      Sets the.
      void setFromXML​(org.jdom2.Element element)
      Sets the from XML.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • Log

        public static final org.slf4j.Logger Log
        The Constant Log.
    • Constructor Detail

      • SQStats

        public SQStats()
    • Method Detail

      • set

        public void set​(java.lang.String key,
                        int value)
        Sets the.
        Parameters:
        key - the key
        value - the value
      • set

        public void set​(java.lang.String key,
                        java.lang.Object value)
        Sets the.
        Parameters:
        key - the key
        value - the value
      • set

        public void set​(java.lang.String key,
                        long value)
        Sets the.
        Parameters:
        key - the key
        value - the value
      • set

        public void set​(java.lang.String key,
                        double value)
        Sets the.
        Parameters:
        key - the key
        value - the value
      • getInt

        public int getInt​(java.lang.String key)
        Gets the int.
        Parameters:
        key - the key
        Returns:
        the int
      • getInt

        public int getInt​(java.lang.String key,
                          int valueIfNotFound)
        Gets the int.
        Parameters:
        key - the key
        valueIfNotFound - the value if not found
        Returns:
        the int
      • getLong

        public long getLong​(java.lang.String key)
        Gets the long.
        Parameters:
        key - the key
        Returns:
        the long
      • getLong

        public long getLong​(java.lang.String key,
                            long valueIfNotFound)
        Gets the long.
        Parameters:
        key - the key
        valueIfNotFound - the value if not found
        Returns:
        the long
      • getDouble

        public double getDouble​(java.lang.String key)
        Gets the double.
        Parameters:
        key - the key
        Returns:
        the double
      • getDouble

        public double getDouble​(java.lang.String key,
                                double valueIfNotFound)
        Gets the double.
        Parameters:
        key - the key
        valueIfNotFound - the value if not found
        Returns:
        the double
      • 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)
        Sets the from XML.
        Specified by:
        setFromXML in interface com.strategyquant.lib.settings.IXMLAble
        Parameters:
        element - the new from XML
      • clearData

        public void clearData()
        Clear data.
      • copyValuesFrom

        public void copyValuesFrom​(SQStats sourceStats)
        Copy values from.
        Parameters:
        sourceStats - the source stats
      • copyValueFrom

        public void copyValueFrom​(SQStats sourceStats,
                                  java.lang.String key)
        Copy value from.
        Parameters:
        sourceStats - the source stats
        key - the key
      • containsKey

        public boolean containsKey​(java.lang.String key)
        Contains key.
        Parameters:
        key - the key
        Returns:
        true, if successful
      • getClone

        public SQStats getClone()
                         throws java.lang.Exception
        Gets the clone.
        Specified by:
        getClone in interface com.strategyquant.lib.utils.ISQCloneable<SQStats>
        Returns:
        the clone
        Throws:
        java.lang.Exception - the exception
      • getXMLOptimizedFormat

        public org.jdom2.Element getXMLOptimizedFormat()
                                                throws java.io.IOException
        Gets the XML optimized format.
        Returns:
        the XML optimized format
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • serialize

        public void serialize​(java.io.ObjectOutput dos)
                       throws java.io.IOException
        Serialize.
        Parameters:
        dos - the dos
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • deserialize

        public void deserialize​(java.io.ObjectInput dis)
                         throws java.io.IOException
        Deserialize.
        Parameters:
        dis - the dis
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.