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
Modifier and TypeFieldDescriptionstatic String
The Constant ACTION_CLEARED.static String
The Constant ACTION_RESULT_ADDED.static String
The Constant ACTION_RESULT_REMOVED.static String
The Constant ACTION_UPDATED.static String
The Constant DefaultMainViewName.static String
The Constant DefaultPortfolioViewName.static org.slf4j.Logger
The Constant Log.static int
The Constant TIMER_TICKS_FREQUENCY. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add(ResultsGroup resultsGroup, boolean refreshGrid)
Add ResultsGroup to the databank.boolean
add(ResultsGroup resultsGroup, boolean refreshGrid, boolean cleanupOptimizations)
Adds the.void
add(StrategyBase strategy)
create a ResultsGroup, add strategy into it and add it to the databank.void
addExtraDatabankChange(String type, String extraValue)
Adds the extra databank change.void
addListener(com.strategyquant.tradinglib.databank.IDatabankListener listener)
Adds the listener.void
applyFilter(com.strategyquant.tradinglib.databank.IDatabankFilter filter)
Apply filter.void
applyFilter(com.strategyquant.tradinglib.databank.IDatabankFilter filter, com.strategyquant.tradinglib.databank.IProgressListener maxRecordsListener)
Apply filter.void
clearRecords(boolean freeMemory, boolean sync, String triggerInfo)
Clears the list of strategies and frees memory.void
Clear results data.void
clearResultsData(ArrayList<String> strategies)
Clear results data.boolean
Contains.void
deleteResultsFile(ResultsGroup resultsGroup)
Delete results file.void
Destroy timers.void
Disable synchronization.void
Enable synchronization.getBufferData(boolean first1000)
Gets the buffer data.org.json.JSONArray
Gets the changes.org.jdom2.Element
Gets the config.Gets the databank folder.static org.jdom2.Element
Gets the default config.static String
Gets the default sync type.com.strategyquant.tradinglib.databank.IDatabankFilter
Gets the filter.com.strategyquant.tradinglib.gp.FitnessCollectionData
Gets the fitness data.long
Gets the last change time.Gets the locked.getName()
Gets the name.double
Gets the percent loaded.int
Gets the position.Gets the project.Gets the record keys.getRecordKeys(String baseName)
Gets the record keys no lock.getRecordKeysNoLock(String baseName)
Gets the records.int
Gets the records size no lock.com.strategyquant.tradinglib.project.StrategySaver
Gets the report saver.getResultsFilePath(ResultsGroup resultsGroup)
Gets the results file path.Gets the sync type.Gets the top results.com.strategyquant.tradinglib.databank.DatabankTableView
getView()
Gets the view.double
Gets the worst fitness.boolean
Checks if is default.static boolean
Checks if is default.boolean
Checks if is file based.boolean
isLoaded()
Checks if is loaded.boolean
Checks if is loading.void
loadStrategies(com.strategyquant.tradinglib.databank.IProgressListener listener)
Load strategies.boolean
No action running.void
notifyListeners(String action)
Notify listeners.void
onResultChange(ResultsGroup resultsGroup)
On result change.void
Refresh grid.void
remove(String resultsName, boolean freeMemory, boolean notifyListeners, boolean sendUIEvent, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)
Removes the.void
remove(String resultsName, boolean freeMemory, boolean notifyListeners, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)
Removes the.void
removes all records from this databank and deletes files.void
Removes the filter.void
removeListener(com.strategyquant.tradinglib.databank.IDatabankListener listener)
Removes the listener.void
removeNoLock(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)
Removes the no lock.void
removeNoLockNoException(String resultsName, boolean freeMemory, boolean refreshGrid, boolean removeStockChartsFile, String lockingTask)
Removes the no lock no exception.void
Rename.void
setPosition(int position)
Sets the position.void
setProjectName(String projectName)
Sets the project name.void
setSyncType(String type)
Sets the sync type.void
setView(com.strategyquant.tradinglib.databank.DatabankTableView view)
Sets the view.boolean
setViewByName(String viewName)
Sets the view by name.int
size()
Size.void
synchronizeNow(boolean waitUntilFinished, String triggerInfo)
void
synchronizeNow(String triggerInfo)
Synchronize now.void
update(String resultsName, ResultsGroup resultsGroup, boolean refreshGrid, String lockingTask)
Update.void
Update all results.void
Update best results.void
Update 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
-