Raspberry pi Stock data collection

I made a stock collection program on my raspberry pi that web scrapes data from a website to give me stock updates every 5 minutes. All the details are stored as a file system and it is managed solely by a python program and crontab.

The script is in python 3 and it is used to track down prices of BSE (Bombay stock exchange) in India.

The whole script is available on my GitHub repository. Link:

To run it just place the script in a folder and add the cron entry as stated in the README.md

python3 stock.py ^BSESN

The data is first extracted via BeautifulSoup and the following tags are

title = ['h1', {'data-reactid': '7'}]
quote_header = ['div', {'id': 'quote-header-info'}]
present_price = ['span', {'class': 'Trsdu(0.3s)'}]
opening_price = ['td', {'data-test': 'OPEN-value'}]
previous_close_price = ['td', {'data-test': 'PREV_CLOSE-value'}]
day_range_price = ['td', {'data-test': 'DAYS_RANGE-value'}]
price_change = ['span', {'data-reactid': '17'}]

title : gives the title of the Quote
quote_header : It is complicated to extract present_price at once, so this is used
present_price : The current price of the stock
opening_price : The price at which the stock had opened on that day
previous_close : The price at which the market was shut
day_range : It give the range of maximum and minimum on that day
price_change : the percent rise or fall of the stock rate

The following directory tree is produced by the code

├── 10_11_2017
│   ├── graph_output.txt
│   ├── logfile.txt
│   └── output.txt
├── 10_1_2018
│   ├── graph_output.txt
│   ├── logfile.txt
│   └── output.txt

graph_output.txt : contains time series data which can be used for plotting
logfile.txt : contains the appication log for that day
output.txt : contains the latest extracted data

I've put the code to run automatically by using a crontab entry :

cron : */5 8-16 * * 1-5 python3 stock.py ^BSESN

This makes it run every 5 minutes from Monday to Friday

You can find my code on my github link:
https://github.com/divyaksh-shukla/Yahoo_stock_data_scraper

Comments


  1. Very Nice Article:
    Hi Readers, If you wanna track your expenses and save money online or offline, Just Download Timelybills.app. It will show you all the ways to manage your expenditure without consuming your whole day. Please feel free to check out here. Thank you!

    Timelybills.app

    ReplyDelete

Post a Comment

Popular posts from this blog

Running Oracle Outsidein Technology (OIT) in Docker

Arduino with 7-Segment Display (LT542)

NAS (National Achivement Survey) data extraction