Giter Club home page Giter Club logo

stock-screener's Introduction

Stock screener

NASDAQ / ASX stocks bullish screener.

Stock shortlisting logic uses the following conditions depending on the method:

MRI (method=mri)

  • Daily higher candle closes above bodies of the previous 5 daily candles and is green
  • Bullish MRI indicator value on the daily timeframe
  • Bullish MRI indicator on the weekly timeframe
  • Moving averages (10, 20, 30 day) Consensio (Guppy MMA)
  • Moving averages (10, 20, 30 day) rising
  • Market is not below MA200 with MA10 declining
  • 2 most recent weekly candles closing above weekly moving averages (10/20/30 week)
  • Close for the last week is not exceeding 300% when compared to 4 weeks ago
  • Volume is significant in the last day compared to the 20-day moving average (defined in the config)
  • The stock has a significant range of movement over the past few weeks (defined in the config)
  • Stochastic RSI is not overextended (>90%)

Alphanumetrix (method=anx)

  • Price above MA200
  • Cross of MA7 and MA30
  • Close for the last week is not exceeding 300% when compared to 4 weeks ago
  • Note: Bullish SAR on weekly scale have to be checked manually as I cannot figure out the correct Lucid SAR calculation

For ASX, the best time to run it is in the evening after market closure to prepare for the next day. For US, that have to be morning (running in Australia) as US stocks data would refresh after a night of trading (per AU time). The shortlist acts as a guide for entering breakout trades which have high probability of success. As a data source, eodhistoricaldata.com is used.

Please note that the shortlist should only be used to guide your own research and should not be interpreted as 'signals'. If you buy the stocks just using the output, you will definitely lose all your money.

Usage

  • Run python scanner.py --h to view context help
  • To update the stocks list, run python scanner.py --update. It is recommended to run this daily prior to scanning. You can use the -date parameter (the format is YYYY-MM-DD).
  • To scan and shortlist, run python scanner.py --scan -method=anx.
    • Use method to specify the method used (mri or anx).
    • Use stock if you want to force check one stock only. E.g. -stock=NVDA.
  • To simulate scanning as of a particular date, use the -date parameter (the format is YYYY-MM-DD). For example, python scanner.py --update -date=2021-01-05.
  • Helper scripts (note: requires configuring Google credentials in order to work). Use -method parameter as this will influence which spreadsheet is used.
    • monitor.py to run daily to check whether the exit condition was hit for active entries.
    • paperfill.py to run daily to fill in the values for paper trade entries automatically.
    • simulator.py simulates outcomes per the spreadsheet.
      • Current experiment: exit price variation if using stop under the formation. Use the argument --exit_variation_a
    • simulator_legacy.py works with the older 21 R&D spreadsheet and also has an optional argument --market which would include market MA200/MA10 conditions when running simulation in the tp mode. You don't need to run this. This argument is there because the rule on using market conditions was already integrated in methodology and used for the stock selection with scanner.
  • The monitor would notify:
    • when the close for a position is below MA10
    • when the market switches to the bearish mode (market below MA200 with MA10 decreasing) as a trigger to close all open positions

Example running a simulator: python simulator.py -mode=main -start=2023-12-10 -end=2024-04-01 -method=mri --show_monthly

Settings

See config.yaml for settings which include:

  • Market to use
  • Price range for stocks considered on scan
  • Minimum volume threshold
  • Overextended threshold
  • Other conditions and rules

Your eodhistoricaldata API key must be placed in .envrc under variable API_KEY

Limitations

  • The scripts were tested on a machine in the Australia/Sydney timezone.
  • Python 3.6+ is required.

Installation

  1. Clone this repo: git clone https://github.com/illi4/asx-screener.git

  2. Install Python 3 and virtualenv if you do not have it installed yet. The easiest way is to download and install from the official website. Instructions to install virtualenv are published on the python packaging website.

  3. Change to the cloned folder, create a python3 venv and activate it.

    Linux / Mac:

    python3 -m venv venv
    . venv/bin/activate
    
  4. Install the required libraries: pip install -r requirements.txt

  5. Run referring to the usage instructions.

Google sheet and Google project configuration

If you want to log your stocks and use monitor and paperfill in addition to the screener, please create a sheet similar to this one and configure API access, then save the credentials under .config\gspread\service_account.json. This is not required if you only want to use the scanner (scanner.py).

There is a warning thrown when using gsheets, which is a known issue and doesn't affect the outcomes.

Note: legacy sheet (R&D 2021) covering 2021 and before is available here.

stock-screener's People

Contributors

illi4 avatar islobodch avatar

Watchers

 avatar  avatar  avatar  avatar

stock-screener's Issues

Try revisiting US and running this in parallel

Try to configure the scripts and run screener / paper trading for a while to compare ASX vs US performance with this approach.

Todos:

  • Add ASX/NASDAQ (market column) to the database
  • Add an updater of stocks for nasdaq. Note that I can add 1d volume straight away
  • Change the ASX stock updater to use http://eoddata.com/ as well
  • Filter volume straight away for ASX when scanning
  • Change get_stock_data to run for NASDAQ and ASX
  • Add support for ASX\NASDAQ for the scan without sectors for NASDAQ
  • Add sectors for NASDAQ

Analytics metrics

This has to be done for multiple systems and variants

Easy metrics:

  • Win rate (% of winning trades from all trades)
  • Number of winning / losing trades
  • Expectency (win rate and % median for winners and losers combined) for a quarter / month
  • Median winning / losing trade % and reward/risk ratio (winning % divided by losing %)
  • Avg/median time in trade
  • One more potential metric: annual/quarterly return to maximum drawdown ratio
  • Equity curve (not sure this is possible with Tableau - do I have to use Python)? Note this won't really be representative prior to simulation implementation.

Dimensions:

  • Splits by Test A/B/C/D. Note that the result in the output for tests should be the same instead of '-'
  • Dimensions by: star rating (individual and grouping 4+5 together), penny/non-penny

Simulations:

  • For analytics, would need to understand # of trades per day for further Monte Carlo analysis / simulation. What is the # of trades if only taking 4-5 starts, or only the best for the day? This would have to be paired with median time in trade because I cannot enter every day. There must be some upper limit on the number of positions. If there is less limit - number of trades should be selected carefully.
  • The simulation would need to run per different tests (A/B/C/D, start ratings, industry ratings etc.). Probably first run with only one limiting criteria and one system. This would have to be its own function.

Entry prices filler

Write a script which fills in prices (entries) for paper trades to save time

Next todos

  • Add info on max negative strikes (done)
  • Add position decrease option after X negative trades in simulator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.