This project requires the following:
python3
redis
You can install python3
from the following link. To install redis
follow the following link.
If you've installed python3
& redis
you can begin the project setup by following these steps.
- Clone this repository and move into the root folder.
git clone https://github.com/parthsharma2/bhavcopy-backend.git
cd bhavcopy-backend
- Create a python virtual environment & activate it. (optional, but recommended)
python3 -m venv .venv
source .venv/bin/activate
- Install the required python packages
pip install -r requirements.txt
- Create a
.env
file to configure the environment variables that this app utilizes. Use the following code snippet as the content of the file & set the variable values accordingly.
REDIS_HOST="127.0.0.1"
REDIS_PORT="6379"
REDIS_HOST
: hostname/ip address of the server where your redis instance is running.
REDIS_POR
: port at which your redis instance is running.
- Apply unapplied migrations
python manage.py migrate
- Now you are ready to run the Django dev server
python manage.py runserver
To fetch the Bhavcopy Equity Data run the following bash script available in the root folder. S Note: If you created the python virtual environment mentioned in step 2, make sure your python virtual environment is activated when executing this command.
./fetch_equity_data
I suggest using crontab
to run the fetch_equity_data
command at regular intervals. Example crontab
config
0 18 * * * cd /home/bhavcopy/bhavcopy-backend && source .venv/bin/activate && ./fetch_equity_data
This runs cd /home/bhavcopy/bhavcopy-backend && source .venv/bin/activate && ./fetch_equity_data
command every day at 18:00.
cd /home/bhavcopy/bhavcopy-backend && source .venv/bin/activate && ./fetch_equity_data
command executes in 3 steps:
- Changes directory into
/home/bhavcopy/bhavcopy-backend
, the project root directory in this case. - Then
source .venv/bin/activate
activates the python virtual environment. - Finally,
./fetch_equity_data
is executed.
/api/equity
: This endpoint returns a list of equity records. It accepts a URL paramterq
where you can specify the query string to filter the equity record. For e.g./api/equity?q=reli
will return equity records which contains the query stringreli
in thecode
orname
fields.
Bhavcopy Frontend lives in this repository. Follow the instructions in its README to set it up.