Utility
ImportCommand
Dynamically imports a list of modules at runtime and returns a dictionary of the imported modules.
Constructor Parameters:
*modules (str)
: A variable number of module names to be imported.
Methods:
execute(self, data_provider=None)
: Attempts to import each module inself.modules
. If successful, adds the module toself.imported_modules
and returns this dictionary. Prints a success message for each imported module, and an error message if a module cannot be imported.
Returns: A dictionary with module names as keys and the corresponding imported module objects as values.
Example Usage:
SMACrossCommand
Checks for a crossover between a short-period SMA and a long-period SMA over a specified time range.
Constructor Parameters:
start (str)
: The start date for the calculation.end (str)
: The end date for the calculation.short_period (int)
: The number of periods for the short-term SMA. Default is 50.long_period (int)
: The number of periods for the long-term SMA. Default is 200.
Methods:
execute(self, data_provider)
: Calculates the SMA for the short and long periods and identifies crossovers.
Returns: A series indicating where crossovers occur.
Example Usage:
PriceLevelCheckCommand
Checks whether the closing prices of a security cross a specified price level during a given time range.
Constructor Parameters:
level (float)
: The price level to check against.start (str)
: The start date for the calculation.end (str)
: The end date for the calculation.
Methods:
execute(self, data_provider)
: Retrieves the closing prices and checks where they cross the specified price level.
Returns: A series indicating where price level crossings occur.
Example Usage:
TimeBasedCommand
Description: Executes a given command at a specified time.
Constructor Parameters:
command (Command)
: The command to be executed.execution_time (datetime.time)
: The time at which the command should be executed.
Methods:
execute(self, data_provider)
: Checks the current time and executes the command if the current time is greater than or equal to the specifiedexecution_time
.
Returns: The result of the command execution, or
None
if the time condition is not met.
Example Usage:
Last updated