The target of this project is to get data about your stock portfolio and make this viewable in a web application.
To see what's being worked on check out the project board.
The project consists of three repositories:
Name | Notes | Language |
---|---|---|
API | This repo which will be used to gather data | Python |
Frontend | Frontend repo which will create the website | React |
Infrastructure | Code to deploy all resources to Azure | Bicep |
- StockTracker Project - API
This project makes use of the Alpha vantage API and clearbit API.
- Fork this repo and the stocktracker-FrontEnd Repo.
- Get your api keys from Alpha vantage API and clearbit API
- Generate a Github PAT with Repo and workflow permissions.
For the azure environment you can either use the One time deployment or the Pipeline deployment
- Run the deployment by clicking Here.
- I'd recommend not changing any of the default values. But you can if you want to.
- Fork the Stocktracker Repo
- You can remove the
bicep-build.yml
file as this is only used to create a gist for the one time deployment. - Setup the workflow secrets as defined below:
Name | Value |
---|---|
AZURE_CREDENTIALS | I'm not sure anymore but it has something to do with the azure/login@v1 action : ) |
AZURE_SUBSCRIPTION | Your Azure subscription ID |
SWA_REPO_TOKEN | The PAT token you generated |
- Install the azure cosmosDB emulator
- Install Azurite:
npm install -g azurite
- Install static web apps cli:
npm install -g @azure/static-web-apps-cli
- Setup a .env file in the stocktracker root with the values below
Name | Notes | Example |
---|---|---|
COSMOSDB_ENDPOINT | < Link to your database> | https://localhost:8081 |
COSMOSDB_KEY | < CosmosDB Access key > | A1B2C3 |
COSMOSDB_DATABASE | < CosmosDB Database name> | stocktracker |
COSMOSDB_OFFER_THROUGHPUT | < CosmosDB Throughput > | 1000 |
- Startup the API running the task
func host start
- run the command
swa start http://localhost:8080 --run "yarn run dev" --api-location http://localhost:7071
to start the website and SWA endpoint. - Go to the website http://localhost:4280/ and Login to the website. make sure you give yourself the admin role.
- Go to /authenticated/settings Account page and add your api keys.
- Add data in /authenticated/actions
- Refresh the data by going to /authenticated/settings and clicking the refresh data button.
- After it has finished you can view the data
All Azure functions available in the api.
Method | URL | Usage |
---|---|---|
POST | {{base_url}}/orchestrator/start | Function will start an orchestrator |
Param | Allowed values | Required |
---|---|---|
functionName | stocktracker_orchestrator | true |
daysToUpdate | all | int |
true |
Method | URL | Usage |
---|---|---|
GET | {{base_url}}/orchestrator/list | Function will list orchestrators |
Param | Allowed values | Required |
---|---|---|
days | int |
true |
Method | URL | Usage |
---|---|---|
DELETE | {{base_url}}/orchestrator/purge | Function will purge orchestrator |
Param | Allowed values | Required |
---|---|---|
instanceId | string |
true |
Method | URL | Usage |
---|---|---|
POST | {{base_url}}/orchestrator/terminate | Function will terminate orchestrator |
Param | Allowed values | Required |
---|---|---|
instanceId | string |
true |
Method | URL | Usage |
---|---|---|
GET | {{base_url}}/chart/bar | Function will get data for barcharts |
Param | Allowed values | Required |
---|---|---|
allData | boolean |
false |
startDate | yyyy-mm-dd | false |
endDate | yyyy-mm-dd | false |
dataType | dividend | transaction_cost | true |
If allData is true then startDate and endDate can not be set. If allData is false then startDate and endDate must be set.
Method | URL | Usage |
---|---|---|
GET | {{base_url}}/chart/line | Function will get data for linecharts |
Param | Allowed values | Required |
---|---|---|
allData | boolean |
false |
startDate | yyyy-mm-dd | false |
endDate | yyyy-mm-dd | false |
dataType | invested_and_value | total_gains | true |
If allData is true then startDate and endDate can not be set. If allData is false then startDate and endDate must be set.
Method | URL | Usage |
---|---|---|
GET | {{base_url}}/chart/pie | Function will get data for piecharts |
Param | Allowed values | Required |
---|---|---|
dataType | stocks | currency | country | sector | true |
Method | URL | Usage |
---|---|---|
POST | {{base_url}}/input/delete | Function will delete a list of items in the input containers |
Body needs to confirm to the stock_input or transaction_input in the schema file.
Method | URL | content-type | Usage |
---|---|---|---|
POST | {{base_url}}/input/add | json | Function will add item to input |
Body needs to confirm to the stock_input or transaction_input in the schema file.
Method | URL | Usage |
---|---|---|
GET | {{base_url}}/table/basic | Function will get data used by tables |
Param | Allowed values | Required |
---|---|---|
containerName | input_invested | input_transactions | stocks_held" | true |
andOr | and | or | false |
fullyRealized | Boolean |
false |
partialRealized | Boolean |
false |
symbol | string |
false |
Method | URL | Usage |
---|---|---|
GET | {{base_url}}/table/performance | Function will get data used by tables |
Param | Allowed values | Required |
---|---|---|
allData | boolean |
false |
startDate | yyyy-mm-dd | false |
endDate | yyyy-mm-dd | false |
containerName | stocks_held | totals | true |
If allData is true then startDate and endDate can not be set. If allData is false then startDate and endDate must be set.
Method | URL | Usage |
---|---|---|
POST | {{base_url}}/user/add | Function will update user data |
Body needs to confirm to the user_data schema in the schema file.
Method | URL | Usage |
---|---|---|
GET | {{base_url}}/user/get | Function will get user data |
Function | Usage | Link and options |
---|---|---|
stocktracker_orchestrator | Function will get all the data from the input tables and use this to create the output data. This will then be outputted to the CosmosDB. | /api/orchestrators/stocktracker_orchestrator/{days_to_update} |
Function will get all the data from the input tables and use this to create the output data. This will then be outputted to the CosmosDB.
graph generated by az-func-as-a-graph