FinanceQuery is a simple API to query financial data. It provides endpoints to get quotes, historical prices, indices, market movers, similar stocks, finance news, indicators, search, and sectors. Data is acquired through web scraping and third party libraries. It is the successor to the GoogleFinanceAPI.
Clone the project
git clone https://github.com/Verdenroz/FinanceQuery.git
Go to the project directory
cd finance-query
Install dependencies
pip install -r requirements.txt
Start the server
python.exe -m uvicorn src.main:app --reload
- Follow the AWS Lambda Deployment Guide
- Remember to add the environment variables to the Lambda function
- Alternatively use the AWS Deployment Workflow, providing repository secrets for
AWS_SECRET_ID
andAWS_SECRET_KEY
.- Also edit the
AWS_REGION
,ECR_REPOSITORY
, andFUNCTION_NAME
in the workflow file
- Also edit the
- Follow the Render Deployment Guide
- The deployment should use the
Dockerfile
file in the repository - Be sure to override the CMD in the Dockerfile in your Render project settings to
python -m uvicorn src.main:app --host 0.0.0.0 --port $PORT
- Alternatively use the Render Deployment Workflow, providing repository secrets for
RENDER_DEPLOY_HOOK_URL
.- The deploy hook url can be found in the settings of your Render project
The exposed endpoints to the API is
There are two workflows that will automatically deploy to render and AWS, but they will require repository secrets for AWS_SECRET_ID
, AWS_SECRET_KEY
, and RENDER_DEPLOY_HOOK_URL
. Quite frankly, render is easier to work with since it enables the websockets, but will require the paid Starter Plan as this API requires extensive memory. If you are tight on cash, consider Lambda.
An x-api-key
header can be added if you have enabled security and rate limiting. If a key is not provided, or an invalid key is used, a rate limit of 2000 requests/day is applied to the request's ip address.
If you are deploying this for yourself, you can create your own admin key which will not be rate limited. See the .env template. Again, remember the websockets above are not available through Lambda. If you deploy to Render instead, you will be able to connect to the websockets through a request that looks like
wss://finance-query.onrender.com/...
# Get detailed quote for NVIDIA stock
curl -X GET 'https://finance-query.onrender.com/v1/quotes?symbols=nvda' \
-H 'x-api-key: your-api-key'
[
{
"symbol": "NVDA",
"name": "NVIDIA Corporation",
"price": "137.71",
"change": "+4.14",
"percentChange": "+3.10%",
"open": "136.21",
"high": "138.50",
"low": "135.47",
"yearHigh": "153.13",
"yearLow": "57.22",
"volume": 199339142,
"avgVolume": 212602686,
"marketCap": "3.373T",
"beta": "1.66",
"pe": "54.22",
"eps": "2.54",
"dividend": "0.04",
"yield": "0.03%",
"exDividend": "Sep 12, 2024",
"earningsDate": "Feb 26, 2025",
"sector": "Technology",
"industry": "Semiconductors",
"about": "NVIDIA Corporation provides graphics and compute and networking solutions in the United States, Taiwan, China, Hong Kong, and internationally. The Graphics segment offers GeForce GPUs for gaming and PCs, the GeForce NOW game streaming service and related infrastructure, and solutions for gaming platforms; Quadro/NVIDIA RTX GPUs for enterprise workstation graphics; virtual GPU or vGPU software for cloud-based visual and virtual computing; automotive platforms for infotainment systems; and Omniverse software for building and operating metaverse and 3D internet applications. The Compute & Networking segment comprises Data Center computing platforms and end-to-end networking platforms, including Quantum for InfiniBand and Spectrum for Ethernet; NVIDIA DRIVE automated-driving platform and automotive development agreements; Jetson robotics and other embedded platforms; NVIDIA AI Enterprise and other software; and DGX Cloud software and services. The company's products are used in gaming, professional visualization, data center, and automotive markets. It sells its products to original equipment manufacturers, original device manufacturers, system integrators and distributors, independent software vendors, cloud service providers, consumer internet companies, add-in board manufacturers, distributors, automotive manufacturers and tier-1 automotive suppliers, and other ecosystem participants. NVIDIA Corporation was incorporated in 1993 and is headquartered in Santa Clara, California.",
"employees": "29,600",
"logo": "https://logo.clearbit.com/https://www.nvidia.com"
}
]
// Connect to WebSocket and subscribe to Tesla stock updates
const ws = new WebSocket('wss://finance-query.onrender.com/quotes');
ws.onopen = () => {
console.log('Connected to WebSocket');
// Send symbol to subscribe to updates
ws.send('TSLA');
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received update:', data);
};
[
{
"symbol": "TSLA",
"name": "Tesla, Inc.",
"price": "398.09",
"change": "+0.94",
"percentChange": "+0.24%",
"logo": "https://logo.clearbit.com/https://www.tesla.com"
}
]
As most data is scraped, some endpoints may break
If something is not working or if you have any suggestions, contact me at harveytseng2@gmail.com