Giter VIP home page Giter VIP logo

stock-vcpscreener's Introduction

Stock-vcpscreener

Stock-vcpscreener is a simple stock screener that calculates various market breadth indicators and selects US stocks on a daily basis based on multiple criteria. The criteria are applied to the simple moving averages and price performance of the stocks over the last year. The goal is to look for a volatility contraction pattern in the market, a specific chart pattern that suggests the stock may move into an uptrend in the near future.

This project started off as a code refactoring practice based on a command-line stock screener I saw on an online forum (ref: carlam.net), which in turn seems to be inspired from this medium article after a bit of googling. This project now forms the backbone of a Dash app, which visualizes the selected stocks and compiles a daily US stock market analysis report.

Usage

Everything is done through the StockVCPScreener class. To initate:

svs = StockVCPScreener(selected_date[datetime.date], stock_list[list])

To download the stock data to the directory (currently supports yahoo finance or stooq):

svs.check_stock_database('yfinance', create=True)

To check the output directory and update the directories containing the stock data

svs.check_directory()
svs.check_index_database()
svs.check_stock_database('yfinance')

To run the stock selection:

svs.select_stock()

To generate a report and the csv files necessary for the Dash app:

svs.generate_report()
svs.generate_dash_csv()

Visualization

The Dash app can be accessed at the link below:

https://jeffreyrdcs.pythonanywhere.com

To-do

  • Complete the test cases
  • Add a method to validate and fix the database directories

stock-vcpscreener's People

Contributors

jeffreyrdcs avatar

Stargazers

Jan Šilhan avatar Mark avatar Avinash B R avatar NOK avatar  avatar WebplayHub avatar tcosnr avatar Igor 'Rogi' Ilyinsky avatar  avatar Yun-Chung Chen avatar Louis avatar Jay Cheng avatar  avatar  avatar  avatar  avatar riteshxsharma avatar Balachandra avatar  avatar  avatar  avatar  avatar  avatar  avatar Fangda Qiu avatar  avatar Michael Lam avatar  avatar dalang avatar  avatar  avatar  avatar  avatar  avatar Kevin Wong avatar  avatar coding-and-trading avatar Gavin avatar ticwhang avatar  avatar Seth Hobson avatar  avatar  avatar  avatar mephistophilis avatar  avatar  avatar  avatar aihorse avatar  avatar Moses Wong avatar  avatar  avatar Sean Lau avatar Joseph Sivits avatar  avatar

Watchers

 avatar James Cloos avatar  avatar  avatar  avatar  avatar Kostas Georgiou avatar  avatar  avatar

stock-vcpscreener's Issues

tickets.csv file issue

@jeffreyrdcs Hi, I just updated the tickets.csv file, I found that it stopped when it ran to ticket "NA" - National Bank of Canada.

Also when it ran the ticket with "/" also get the error.
Tickers.csv

Much appreciated if you can fix the issue.

thanks,
Wilson

Issue while running the code

Hey Jeffrey,

First of all this is not exactly issue but when I m trying to replicate your code on my local environment I was stuck, did some changes and was able to run it a bit. Now the last I am totally stuck with this errors:
The selected date is 2022-06-09
Empty DataFrame
Columns: []
Index: []
No update needed
Updating CSV data
No update needed for the database!
2022-06-09 00:00:00
2022-06-10 00:00:00
Working on 2022-06-09
AAPL Empty DataFrame
Columns: [Stock, Index, RS Rating, RS Rating 2, RS Rating 3, 50 Day MA, 150 Day Ma, 200 Day MA, 52 Week Low, 52 week High]
Index: []
Error:
name 'pd' is not defined
Creating PNG plot for:
No JPG found in input dir. Returning a blank PDF

------------------------ Stock Report for today --------------------------------

Advance / Decline = 0 / 1
New High / New Low = 0 / 0
Gauge = -9894565893.66
Stock above its 20-DMA (%): 0.00
Stock above its 50-DMA (%): 0.00
Stock with 20-DMA > 50-DMA (%): 0.00
Stock with 50-DMA > 200-DMA (%): 0.00
Stock with 50 > 150 > 200-DMA (%): 0.00
Stock with rising 200-DMA (%): 100.00
Number of Stock that fit the conditions: 0
Number of Stock that fit the conditions(%): 0.00

PermissionError Traceback (most recent call last)
C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_832/749149736.py in
431
432 # Generate report
--> 433 svs.generate_report()
434 svs.generate_dash_csv()
435

C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_832/749149736.py in generate_report(self)
353 out_msg = gen_report_front_page(self.report_dict, stock_namelist, self.cdir_path)
354 out_status = gen_report_breadth_page(self.report_dict, self.date_study, self.cdir_path)
--> 355 out_status = gen_report_combine(self.cdir_path, self.output_path, self.date_study)
356
357 # Convert report dict to df and update self.dsel_info_name

~\stock-vcpscreener-main\vcp_util\util.py in gen_report_combine(input_dir, output_dir, daily_file_name)
165 comb.write(outpdf)
166
--> 167 os.remove(input_dir+'report_frontpage.pdf')
168 os.remove(input_dir+'report_breadthpage.pdf')
169 os.remove(input_dir+'report_outputpage.pdf')

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'stock_vcpscreener//report_frontpage.pdf'

My last goal is to replicate it for Indian Market, I will be grateful for your help and guidance.

[Resolved!] cannot run it, would you please help me!

I got the error as below:


ModuleNotFoundError Traceback (most recent call last)
Cell In[16], line 15
12 import sys
13 import os
---> 15 from stock_vcpscreener.vcp_util.util import gen_report_front_page, gen_report_output_page, gen_report_combine,
16 gen_report_breadth_page,
17 convert_report_dict_to_df, convert_png_jpg, cleanup_dir_jpg_png,
18 get_last_trade_day
19 from stock_vcpscreener.vcp_util.stat import compute_rs_rank, compute_rs_rating
20 from stock_vcpscreener.vcp_util.db import create_index_database, update_index_database,
21 create_stock_database, update_stock_database,
22 get_index_lastday, get_stock_data_specific_date

File ~\OneDrive - W\VCP\stock-vcpscreener-main\stock_vcpscreener.py:15
12 import sys
13 import os
---> 15 from stock_vcpscreener.vcp_util.util import gen_report_front_page, gen_report_output_page, gen_report_combine,
16 gen_report_breadth_page,
17 convert_report_dict_to_df, convert_png_jpg, cleanup_dir_jpg_png,
18 get_last_trade_day
19 from stock_vcpscreener.vcp_util.stat import compute_rs_rank, compute_rs_rating
20 from stock_vcpscreener.vcp_util.db import create_index_database, update_index_database,
21 create_stock_database, update_stock_database,
22 get_index_lastday, get_stock_data_specific_date

ModuleNotFoundError: No module named 'stock_vcpscreener.vcp_util'; 'stock_vcpscreener' is not a package

Would anyone can help me?

thanks,
Wilson

please check if this new error

image

The output file for 21 March is empty
selected_stock_2024-03-21.csv

Also the updates the ticker file in folder db_yfinance for March 21st (row) was missing for all tickers.

AAMC_.csv
AACQ_.txt
Not sure why the date in this folder is showing 2024.03.23. The run was done on 22nd March at 0100am CST USA

What changed from yesterday to today ?
The only change I did was to upgrade the numpy version from what is given in the requirements.txt to numpy==1.22.4 as the old version numpy==1.19.5 had dependencies issues while running dash app app.py. The errors in that was cleared when I upgraded it to 1.22.4, the command message indicated me to upgrade to a version equal or higher to 1.22.4

Date handling is very confusion

I'm running the screener after Monday market close (~after 11PM EST).

I forced the yahoo ohlcv download for the index and all tickers. Upon inspection, OHLCV data is present for both 2023-02-24 or 2023-02-27.

Now trying to running the stock selection and report/files for the dash app:
python stock_vcpscreener.py
No update needed
Updating CSV data
No update needed for the database!
Working on 2023-02-26
This is not a valid trade day

No selected_stock files for 2023-02-24 or 2023-02-27 generated.

The date handling and logic seems flawed. Will you please explain?

Thank-you,
--Rajeev

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.