Class SQStats

java.lang.Object
com.strategyquant.tradinglib.SQStats
All Implemented Interfaces:
com.strategyquant.lib.settings.IXMLAble, com.strategyquant.lib.utils.ISQCloneable<SQStats>

public class SQStats extends 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 Details

    • Log

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

    • SQStats

      public SQStats()
  • Method Details

    • set

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

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

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

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

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

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

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

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

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

      public double getDouble(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, String key)
      Copy value from.
      Parameters:
      sourceStats - the source stats
      key - the key
    • containsKey

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

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

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

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

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