Package com.strategyquant.tradinglib
Class Databank
java.lang.Object
com.strategyquant.tradinglib.Databank
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic StringThe Constant ACTION_CLEARED.static StringThe Constant ACTION_RESULT_ADDED.static StringThe Constant ACTION_RESULT_REMOVED.static StringThe Constant ACTION_UPDATED.static StringThe Constant DefaultMainViewName.static StringThe Constant DefaultPortfolioViewName.static org.slf4j.LoggerThe Constant Log.static intThe Constant TIMER_TICKS_FREQUENCY. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(ResultsGroup resultsGroup, boolean refreshGrid)Add ResultsGroup to the databank.booleanadd(ResultsGroup resultsGroup, boolean refreshGrid, boolean cleanupOptimizations)Adds the.voidadd(StrategyBase strategy)create a ResultsGroup, add strategy into it and add it to the databank.voidaddExtraDatabankChange(String type, String extraValue)Adds the extra databank change.voidaddListener(com.strategyquant.tradinglib.databank.IDatabankListener listener)Adds the listener.voidapplyFilter(com.strategyquant.tradinglib.databank.IDatabankFilter filter)Apply filter.voidapplyFilter(com.strategyquant.tradinglib.databank.IDatabankFilter filter, com.strategyquant.tradinglib.databank.IProgressListener maxRecordsListener)Apply filter.voidclearRecords(boolean freeMemory, boolean sync, String triggerInfo)Clears the list of strategies and frees memory.voidClear results data.voidclearResultsData(ArrayList<String> strategies)Clear results data.booleanContains.voiddeleteResultsFile(ResultsGroup resultsGroup)Delete results file.voidDestroy timers.voidDisable synchronization.voidEnable synchronization.getBufferData(boolean first1000)Gets the buffer data.org.json.JSONArrayGets the changes.org.jdom2.ElementGets the config.Gets the databank folder.static org.jdom2.ElementGets the default config.static StringGets the default sync type.com.strategyquant.tradinglib.databank.IDatabankFilterGets the filter.com.strategyquant.tradinglib.gp.FitnessCollectionDataGets the fitness data.longGets the last change time.Gets the locked.getName()Gets the name.doubleGets the percent loaded.intGets the position.Gets the project.Gets the record keys.getRecordKeys(String baseName)Gets the record keys no lock.getRecordKeysNoLock(String baseName)Gets the records.intGets the records size no lock.com.strategyquant.tradinglib.project.StrategySaverGets the report saver.getResultsFilePath(ResultsGroup resultsGroup)Gets the results file path.Gets the sync type.Gets the top results.com.strategyquant.tradinglib.databank.DatabankTableViewgetView()Gets the view.doubleGets the worst fitness.booleanChecks if is default.static booleanChecks if is default.booleanChecks if is file based.booleanisLoaded()Checks if is loaded.booleanChecks if is loading.voidloadStrategies(com.strategyquant.tradinglib.databank.IProgressListener listener)Load strategies.booleanNo action running.voidnotifyListeners(String action)Notify listeners.voidonResultChange(ResultsGroup resultsGroup)On result change.voidRefresh grid.voidremove(String resultsName, boolean freeMemory, boolean notifyListeners, boolean sendUIEvent, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)Removes the.voidremove(String resultsName, boolean freeMemory, boolean notifyListeners, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)Removes the.voidremoves all records from this databank and deletes files.voidRemoves the filter.voidremoveListener(com.strategyquant.tradinglib.databank.IDatabankListener listener)Removes the listener.voidremoveNoLock(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)Removes the no lock.voidremoveNoLockNoException(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)Removes the no lock no exception.voidRename.voidsetPosition(int position)Sets the position.voidsetProjectName(String projectName)Sets the project name.voidsetSyncType(String type)Sets the sync type.voidsetView(com.strategyquant.tradinglib.databank.DatabankTableView view)Sets the view.booleansetViewByName(String viewName)Sets the view by name.intsize()Size.voidsynchronizeNow(boolean waitUntilFinished, String triggerInfo)voidsynchronizeNow(String triggerInfo)Synchronize now.voidupdate(String resultsName, ResultsGroup resultsGroup, boolean refreshGrid, String lockingTask)Update.voidUpdate all results.voidUpdate best results.voidUpdate best results.
-
Field Details
-
Log
public static final org.slf4j.Logger LogThe Constant Log. -
ACTION_RESULT_ADDED
The Constant ACTION_RESULT_ADDED.- See Also:
- Constant Field Values
-
ACTION_RESULT_REMOVED
The Constant ACTION_RESULT_REMOVED.- See Also:
- Constant Field Values
-
ACTION_CLEARED
The Constant ACTION_CLEARED.- See Also:
- Constant Field Values
-
ACTION_UPDATED
The Constant ACTION_UPDATED.- See Also:
- Constant Field Values
-
DefaultMainViewName
The Constant DefaultMainViewName.- See Also:
- Constant Field Values
-
DefaultPortfolioViewName
The Constant DefaultPortfolioViewName.- See Also:
- Constant Field Values
-
TIMER_TICKS_FREQUENCY
public static final int TIMER_TICKS_FREQUENCYThe Constant TIMER_TICKS_FREQUENCY.- See Also:
- Constant Field Values
-
-
Constructor Details
-
Databank
Instantiates a new databank.- Parameters:
projectName- the project namedatabankName- the databank namedatabanksFilePath- the databanks file path
-
-
Method Details
-
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 ExceptionLoad strategies.- Parameters:
listener- the listener- Throws:
Exception- the exception
-
add
create a ResultsGroup, add strategy into it and add it to the databank.- Parameters:
strategy- the strategy- Throws:
Exception- the exception
-
add
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 grouprefreshGrid- the refresh grid- Returns:
- true if ResultsGroup was added
- Throws:
Exception- the exception
-
add
public boolean add(ResultsGroup resultsGroup, boolean refreshGrid, boolean cleanupOptimizations) throws ExceptionAdds the.- Parameters:
resultsGroup- the results grouprefreshGrid- the refresh gridcleanupOptimizations- 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 ExceptionRemoves the.- Parameters:
resultsName- the results namefreeMemory- the free memorynotifyListeners- the notify listenersrefreshGrid- the refresh gridremoveStockChartsFile- the remove stock charts filelockingTask- 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 ExceptionRemoves the.- Parameters:
resultsName- the results namefreeMemory- the free memorynotifyListeners- the notify listenerssendUIEvent- the send UI eventrefreshGrid- the refresh gridremoveStockChartsFile- the remove stock charts filelockingTask- the locking task- Throws:
Exception- the exception
-
removeNoLock
public void removeNoLock(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask) throws ExceptionRemoves the no lock.- Parameters:
resultsName- the results namefreeMemory- the free memoryrefreshGrid- the refresh gridremoveStockChartsFile- the remove stock charts filelockingTask- the locking task- Throws:
Exception- the exception
-
removeNoLockNoException
public void removeNoLockNoException(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask) throws ExceptionRemoves the no lock no exception.- Parameters:
resultsName- the results namefreeMemory- the free memoryrefreshGrid- the refresh gridremoveStockChartsFile- the remove stock charts filelockingTask- the locking task- Throws:
Exception- the exception
-
update
public void update(String resultsName, ResultsGroup resultsGroup, boolean refreshGrid, String lockingTask) throws ExceptionUpdate.- Parameters:
resultsName- the results nameresultsGroup- the results grouprefreshGrid- the refresh gridlockingTask- the locking task- Throws:
Exception- the exception
-
updateAllResults
Update all results.- Throws:
Exception- the exception
-
updateBestResults
public void updateBestResults()Update best results. -
updateBestResults
Update best results.- Parameters:
rg- the rg
-
getLocked
Gets the locked.- Parameters:
resultsName- the results namelockingTask- the locking task- Returns:
- the locked
- Throws:
Exception- the exception
-
contains
Contains.- Parameters:
resultsName- the results name- Returns:
- true, if successful
-
getRecords
Gets the records.- Returns:
- the records
-
getRecordsSizeNoLock
public int getRecordsSizeNoLock()Gets the records size no lock.- Returns:
- the records size no lock
-
getRecordKeys
Gets the record keys.- Returns:
- the record keys
-
getRecordKeysNoLock
Gets the record keys no lock.- Returns:
- the record keys no lock
-
getRecordKeysNoLock
-
getRecordKeys
-
onResultChange
On result change.- Parameters:
resultsGroup- the results group- Throws:
Exception- the exception
-
getResultsFilePath
Gets the results file path.- Parameters:
resultsGroup- the results group- Returns:
- the results file path
-
deleteResultsFile
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
Gets the buffer data.- Parameters:
first1000- the first 1000- Returns:
- the buffer data
-
removeAll
removes all records from this databank and deletes files.- Parameters:
freeMemory- the free memorytriggerInfo- the info about what triggered the action- Throws:
Exception- the exception
-
clearRecords
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
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
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
Notify listeners.- Parameters:
action- the action
-
applyFilter
public void applyFilter(com.strategyquant.tradinglib.databank.IDatabankFilter filter) throws ExceptionApply 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 ExceptionApply filter.- Parameters:
filter- the filtermaxRecordsListener- 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
Gets the databank folder.- Returns:
- the databank folder
-
addExtraDatabankChange
Adds the extra databank change.- Parameters:
type- the typeextraValue- the extra value
-
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
Gets the sync type.- Returns:
- the sync type
-
setSyncType
Sets the sync type.- Parameters:
type- the new sync type
-
synchronizeNow
Synchronize now. -
synchronizeNow
-
getDefaultSyncType
Gets the default sync type.- Returns:
- the default sync type
-
refreshGrid
public void refreshGrid()Refresh grid. -
setProjectName
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
Checks if is default.- Parameters:
databankName- the databank name- Returns:
- true, if is default
-
rename
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
Clear results data.- Parameters:
strategies- the strategies
-