Screener¶
- class src.boatwright.Screener.Screener(strategy, universe, data_granularity, trade_period=1, debug=False)¶
A Screener applies a strategy (or list of strategies) to a universe of stocks to identify whether any buy or sell orders were generated within a given trade period.
- Parameters:
strategy (Strategy) – The strategy to apply. Also accepts a list of strategies to screen with multiple strategies at once.
universe (list) – list of strings assets to screen, e.g. [“AAPL”, “MSFT”, “GOOG”] or [“BTC/USD”, “ETH/USD”]. Assumes all assets are available from same data source.
data_granularity (str) – the granularity of the data to screen on (e.g. “DAY”, “HOUR”, “MINUTE”)
trade_period (int) – The period over which to evaluate for orders.
debug (bool) – boolean toggle to print out additional information during the screening process.
- calc_total_orders()¶
Calculate the total number of buy and sell orders generated by all strategies for each asset in the screener results.
- Returns:
DataFrame with index of screened assets and columns for the total number of buy/sell orders generated by all strategies
- collect_data(start_date=None, source=None, save_loc=None)¶
Collects historical data for the stocks in the universe.
- Parameters:
start_date (datetime) – optional start date for the historical data collection, which can be nice to have if you decide to take a closer look at the charts after the screening. If None, the minimum necesary data will be collected
source (str) – data source to collect from, defaults to config DEFAULT_DATA_SOURCE
save_loc (str) – directory to save data to, defaults to config DATA_DIR
- classmethod load_strategies(strategies_file)¶
Load strategy info from a file
Parameters: :param strategies_file: json file with strategy files and parameters
strategies_file should be a json file with the following structure: { "strategy1": { "file": "path/to/strategy1.py", "parameters": { "param1": value1, "param2": value2 ... } }, "strategy2": { "file": "path/to/strategy2.py", "parameters": { "param1": value1, "param2": value2 ... } }
- Returns:
List of instantiated Strategy objects
- Parameters:
strategies_file (str)
- classmethod load_universe(universe_file)¶
Load universe of stocks from a file Parameters: :param universe_file: path to the csv file containing the universe of stocks to screen.
- Parameters:
universe_file (str)
- screen(verbose=False)¶
Screen the universe of assets using the strategy (or strategies)
- Returns:
DataFrame with index of screened assets and columns for the number of buy/sell orders generated by each strategy within the trade period
- Parameters:
verbose (bool)