This project combines a stock screener for NASDAQ/ASX stocks with a trading simulator, allowing users to identify potential trades and test various trading strategies using historical data.
- Clone this repo:
git clone https://github.com/illi4/asx-screener.git
- Install Python 3 (3.6+) and virtualenv if not already installed.
- Change to the cloned folder, create and activate a Python 3 venv:
python3 -m venv venv . venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install required libraries:
pip install -r requirements.txt
- Place your eodhistoricaldata API key in
.envrc
under variableAPI_KEY
The stock screener helps identify potential bullish trading opportunities based on various technical indicators and market data.
Run python scanner.py --h
to view context help
- Update stocks list:
python scanner.py --update [-date=YYYY-MM-DD]
- Scan and shortlist:
python scanner.py --scan -method=anx [-stocks=STOCK1,STOCK2,...] [-num=100] [--use_existing_price_data]
Note that new prices must be fetched on a new day to get the most recent OHLC data. However, if you are running the scanner again and want to reuse the fetched data, you can run the scanner with the parameter --use_existing_price_data
. This will keep the prices table untouched.
Helper scripts (requires Google credentials):
- Monitor exit conditions:
python monitor.py -method=anx
- Auto-fill paper trade entries:
python paperfill.py -method=anx
- Daily routine:
python paperfill.py -method=anx python monitor.py -method=anx python scanner.py --update python scanner.py --scan -method=anx
See config.yaml
for settings including:
- Market selection
- Price range for stocks
- Minimum volume threshold
- Overextended threshold
- Other conditions and rules
- Tested on Australia/Sydney timezone
- Requires Python 3.6+
- The shortlist should only guide your research, not be interpreted as 'signals'
The trading simulator uses historical data to test various trading strategies and parameters.
To run the simulator:
python simulator.py -start=YYYY-MM-DD -end=YYYY-MM-DD -method=anx [options]
Example:
python simulator.py -start=2023-12-10 -end=2024-04-01 -method=mri --plot
-start=YYYY-MM-DD
: Start date for the simulation-end=YYYY-MM-DD
: End date for the simulation-method=anx|mri|earnings
: Method of shortlisting
--plot
: Generate and include plots in the output Excel file--forced_price_update
: Force update of price data in the database-stock=STOCK_CODE
: Specify a single stock to simulate--sampling
: Enable sampling mode for multiple simulation runs and averaging the results--rnd
: Use to run the simulation on the RND sheet which has a structure different from the post-RND one
The config.yaml
file contains important simulation parameters:
capital
: Initial capitalcommission
: Commission fee per tradesimultaneous_positions
: List of maximum simultaneous positions to simulatenumerical_filters
: Filters for technical indicators (e.g., Fisher, Coppock)take_profit_variants
: Different take-profit strategies to simulate
Example take_profit_variant:
take_profit_values:
- level: 5%
exit_proportion: 25%
move_stop_price: False
- level: 10%
exit_proportion: 25%
move_stop_price: True
move_stop_from_tp_level: 5%
Results are saved in sim_summary.xlsx
, containing:
- Summary of performance metrics for each variant
- Monthly breakdown of capital values
- Plots of capital over time (if
--plot
is used)
To log stocks and use monitor and paperfill features:
- Create a sheet similar to this example
- Configure API access
- Save credentials under
.config\gspread\service_account.json
Note: This is not required for using only the scanner (scanner.py)
- There's a known warning when using gsheets, which doesn't affect outcomes. See this issue
- For other issues, ensure all required Python packages are installed and up to date
- Check that your Google Sheets is properly formatted and accessible if using related features