Class Databank

java.lang.Object
com.strategyquant.tradinglib.Databank
All Implemented Interfaces:
Serializable

public class Databank extends Object implements Serializable
Databank is an object that stores generated strategies. This class provides databank management interface - methods to add/get strategies to/from databank,
See Also:
Serialized Form
  • Field Details

    • Log

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

      public static final String ACTION_RESULT_ADDED
      The Constant ACTION_RESULT_ADDED.
      See Also:
      Constant Field Values
    • ACTION_RESULT_REMOVED

      public static final String ACTION_RESULT_REMOVED
      The Constant ACTION_RESULT_REMOVED.
      See Also:
      Constant Field Values
    • ACTION_CLEARED

      public static final String ACTION_CLEARED
      The Constant ACTION_CLEARED.
      See Also:
      Constant Field Values
    • ACTION_UPDATED

      public static final String ACTION_UPDATED
      The Constant ACTION_UPDATED.
      See Also:
      Constant Field Values
    • DefaultMainViewName

      public static final String DefaultMainViewName
      The Constant DefaultMainViewName.
      See Also:
      Constant Field Values
    • DefaultPortfolioViewName

      public static final String DefaultPortfolioViewName
      The Constant DefaultPortfolioViewName.
      See Also:
      Constant Field Values
    • TIMER_TICKS_FREQUENCY

      public static final int TIMER_TICKS_FREQUENCY
      The Constant TIMER_TICKS_FREQUENCY.
      See Also:
      Constant Field Values
  • Constructor Details

    • Databank

      public Databank(String projectName, String databankName, String databanksFilePath)
      Instantiates a new databank.
      Parameters:
      projectName - the project name
      databankName - the databank name
      databanksFilePath - the databanks file path
  • Method Details

    • getProject

      public String getProject()
      Gets the project.
      Returns:
      the project
    • addListener

      public void addListener(com.strategyquant.tradinglib.databank.IDatabankListener listener)
      Adds the listener.
      Parameters:
      listener - the listener
    • removeListener

      public void removeListener(com.strategyquant.tradinglib.databank.IDatabankListener listener)
      Removes the listener.
      Parameters:
      listener - the listener
    • loadStrategies

      public void loadStrategies(com.strategyquant.tradinglib.databank.IProgressListener listener) throws Exception
      Load strategies.
      Parameters:
      listener - the listener
      Throws:
      Exception - the exception
    • add

      public void add(StrategyBase strategy) throws Exception
      create a ResultsGroup, add strategy into it and add it to the databank.
      Parameters:
      strategy - the strategy
      Throws:
      Exception - the exception
    • add

      public boolean add(ResultsGroup resultsGroup, boolean refreshGrid) throws Exception
      Add ResultsGroup to the databank. If max records count is set, ResultsGroup is added only if its rank value is better than the worst result's rank value.
      Parameters:
      resultsGroup - the results group
      refreshGrid - the refresh grid
      Returns:
      true if ResultsGroup was added
      Throws:
      Exception - the exception
    • add

      public boolean add(ResultsGroup resultsGroup, boolean refreshGrid, boolean cleanupOptimizations) throws Exception
      Adds the.
      Parameters:
      resultsGroup - the results group
      refreshGrid - the refresh grid
      cleanupOptimizations - the cleanup optimizations
      Returns:
      true, if successful
      Throws:
      Exception - the exception
    • remove

      public void remove(String resultsName, boolean freeMemory, boolean notifyListeners, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask) throws Exception
      Removes the.
      Parameters:
      resultsName - the results name
      freeMemory - the free memory
      notifyListeners - the notify listeners
      refreshGrid - the refresh grid
      removeStockChartsFile - the remove stock charts file
      lockingTask - the locking task
      Throws:
      Exception - the exception
    • remove

      public void remove(String resultsName, boolean freeMemory, boolean notifyListeners, boolean sendUIEvent, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask) throws Exception
      Removes the.
      Parameters:
      resultsName - the results name
      freeMemory - the free memory
      notifyListeners - the notify listeners
      sendUIEvent - the send UI event
      refreshGrid - the refresh grid
      removeStockChartsFile - the remove stock charts file
      lockingTask - the locking task
      Throws:
      Exception - the exception
    • removeNoLock

      public void removeNoLock(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask) throws Exception
      Removes the no lock.
      Parameters:
      resultsName - the results name
      freeMemory - the free memory
      refreshGrid - the refresh grid
      removeStockChartsFile - the remove stock charts file
      lockingTask - the locking task
      Throws:
      Exception - the exception
    • removeNoLockNoException

      public void removeNoLockNoException(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask) throws Exception
      Removes the no lock no exception.
      Parameters:
      resultsName - the results name
      freeMemory - the free memory
      refreshGrid - the refresh grid
      removeStockChartsFile - the remove stock charts file
      lockingTask - the locking task
      Throws:
      Exception - the exception
    • update

      public void update(String resultsName, ResultsGroup resultsGroup, boolean refreshGrid, String lockingTask) throws Exception
      Update.
      Parameters:
      resultsName - the results name
      resultsGroup - the results group
      refreshGrid - the refresh grid
      lockingTask - the locking task
      Throws:
      Exception - the exception
    • updateAllResults

      public void updateAllResults() throws Exception
      Update all results.
      Throws:
      Exception - the exception
    • updateBestResults

      public void updateBestResults()
      Update best results.
    • updateBestResults

      public void updateBestResults(ResultsGroup rg)
      Update best results.
      Parameters:
      rg - the rg
    • getLocked

      public ResultsGroup getLocked(String resultsName, String lockingTask) throws Exception
      Gets the locked.
      Parameters:
      resultsName - the results name
      lockingTask - the locking task
      Returns:
      the locked
      Throws:
      Exception - the exception
    • contains

      public boolean contains(String resultsName)
      Contains.
      Parameters:
      resultsName - the results name
      Returns:
      true, if successful
    • getRecords

      public ArrayList<ResultsGroup> getRecords()
      Gets the records.
      Returns:
      the records
    • getRecordsSizeNoLock

      public int getRecordsSizeNoLock()
      Gets the records size no lock.
      Returns:
      the records size no lock
    • getRecordKeys

      public ArrayList<String> getRecordKeys()
      Gets the record keys.
      Returns:
      the record keys
    • getRecordKeysNoLock

      public ArrayList<String> getRecordKeysNoLock()
      Gets the record keys no lock.
      Returns:
      the record keys no lock
    • getRecordKeysNoLock

      public ArrayList<String> getRecordKeysNoLock(String baseName)
    • getRecordKeys

      public ArrayList<String> getRecordKeys(String baseName)
    • onResultChange

      public void onResultChange(ResultsGroup resultsGroup) throws Exception
      On result change.
      Parameters:
      resultsGroup - the results group
      Throws:
      Exception - the exception
    • getResultsFilePath

      public String getResultsFilePath(ResultsGroup resultsGroup)
      Gets the results file path.
      Parameters:
      resultsGroup - the results group
      Returns:
      the results file path
    • deleteResultsFile

      public void deleteResultsFile(ResultsGroup resultsGroup) throws Exception
      Delete results file.
      Parameters:
      resultsGroup - the results group
      Throws:
      Exception - the exception
    • getConfig

      public org.jdom2.Element getConfig()
      Gets the config.
      Returns:
      the config
    • getDefaultConfig

      public static org.jdom2.Element getDefaultConfig()
      Gets the default config.
      Returns:
      the default config
    • setView

      public void setView(com.strategyquant.tradinglib.databank.DatabankTableView view)
      Sets the view.
      Parameters:
      view - the new view
    • getView

      public com.strategyquant.tradinglib.databank.DatabankTableView getView()
      Gets the view.
      Returns:
      the view
    • getBufferData

      public ArrayList<Object[]> getBufferData(boolean first1000)
      Gets the buffer data.
      Parameters:
      first1000 - the first 1000
      Returns:
      the buffer data
    • removeAll

      public void removeAll(boolean freeMemory, String triggerInfo) throws Exception
      removes all records from this databank and deletes files.
      Parameters:
      freeMemory - the free memory
      triggerInfo - the info about what triggered the action
      Throws:
      Exception - the exception
    • clearRecords

      public void clearRecords(boolean freeMemory, boolean sync, String triggerInfo) throws Exception
      Clears the list of strategies and frees memory. Strategy files remain in databank folder if databank type is set to file-based.
      Parameters:
      freeMemory - the free memory
      Throws:
      Exception - the exception
    • setViewByName

      public boolean setViewByName(String viewName)
      Sets the view by name.
      Parameters:
      viewName - the view name
      Returns:
      true, if successful
    • noActionRunning

      public boolean noActionRunning()
      No action running.
      Returns:
      true, if successful
    • getName

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

      public boolean isLoading()
      Checks if is loading.
      Returns:
      the loading
    • isLoaded

      public boolean isLoaded()
      Checks if is loaded.
      Returns:
      true, if is loaded
    • size

      public int size()
      Size.
      Returns:
      the int
    • getPercentLoaded

      public double getPercentLoaded()
      Gets the percent loaded.
      Returns:
      the percent loaded
    • notifyListeners

      public void notifyListeners(String action)
      Notify listeners.
      Parameters:
      action - the action
    • applyFilter

      public void applyFilter(com.strategyquant.tradinglib.databank.IDatabankFilter filter) throws Exception
      Apply filter.
      Parameters:
      filter - the filter
      Throws:
      Exception - the exception
    • applyFilter

      public void applyFilter(com.strategyquant.tradinglib.databank.IDatabankFilter filter, com.strategyquant.tradinglib.databank.IProgressListener maxRecordsListener) throws Exception
      Apply filter.
      Parameters:
      filter - the filter
      maxRecordsListener - the max records listener
      Throws:
      Exception - the exception
    • removeFilter

      public void removeFilter()
      Removes the filter.
    • getFilter

      public com.strategyquant.tradinglib.databank.IDatabankFilter getFilter()
      Gets the filter.
      Returns:
      the filter
    • getWorstFitness

      public double getWorstFitness()
      Gets the worst fitness.
      Returns:
      the worst fitness
    • getChanges

      public org.json.JSONArray getChanges()
      Gets the changes.
      Returns:
      the changes
    • getReportSaver

      public com.strategyquant.tradinglib.project.StrategySaver getReportSaver()
      Gets the report saver.
      Returns:
      the report saver
    • getDatabankFolder

      public String getDatabankFolder()
      Gets the databank folder.
      Returns:
      the databank folder
    • addExtraDatabankChange

      public void addExtraDatabankChange(String type, String extraValue)
      Adds the extra databank change.
      Parameters:
      type - the type
      extraValue - the extra value
    • getTopResults

      public ResultsGroup[] getTopResults()
      Gets the top results.
      Returns:
      the top results
    • getFitnessData

      public com.strategyquant.tradinglib.gp.FitnessCollectionData getFitnessData()
      Gets the fitness data.
      Returns:
      the fitness data
    • isFileBased

      public boolean isFileBased()
      Checks if is file based.
      Returns:
      true, if is file based
    • getSyncType

      public String getSyncType()
      Gets the sync type.
      Returns:
      the sync type
    • setSyncType

      public void setSyncType(String type)
      Sets the sync type.
      Parameters:
      type - the new sync type
    • synchronizeNow

      public void synchronizeNow(String triggerInfo)
      Synchronize now.
    • synchronizeNow

      public void synchronizeNow(boolean waitUntilFinished, String triggerInfo)
    • getDefaultSyncType

      public static String getDefaultSyncType()
      Gets the default sync type.
      Returns:
      the default sync type
    • refreshGrid

      public void refreshGrid()
      Refresh grid.
    • setProjectName

      public void setProjectName(String projectName)
      Sets the project name.
      Parameters:
      projectName - the new project name
    • getPosition

      public int getPosition()
      Gets the position.
      Returns:
      the position
    • setPosition

      public void setPosition(int position)
      Sets the position.
      Parameters:
      position - the new position
    • isDefault

      public boolean isDefault()
      Checks if is default.
      Returns:
      true, if is default
    • isDefault

      public static boolean isDefault(String databankName)
      Checks if is default.
      Parameters:
      databankName - the databank name
      Returns:
      true, if is default
    • rename

      public void rename(String newName)
      Rename.
      Parameters:
      newName - the new name
    • destroyTimers

      public void destroyTimers()
      Destroy timers.
    • getLastChangeTime

      public long getLastChangeTime()
      Gets the last change time.
      Returns:
      the last change time
    • disableSynchronization

      public void disableSynchronization()
      Disable synchronization.
    • enableSynchronization

      public void enableSynchronization()
      Enable synchronization.
    • clearResultsData

      public void clearResultsData()
      Clear results data.
    • clearResultsData

      public void clearResultsData(ArrayList<String> strategies)
      Clear results data.
      Parameters:
      strategies - the strategies