A simple stocks portfolio performance tracker.
Web application for portfolio, tracking stocks, markets, and financial news. Real-Time stock, currencies and crypto information using Finnhub Stock API. The free API allows for access to several features like company news, basic financials, company earnings, crypto exchanges and symbols etc. Visit http://finnhub.io for more information.
https://expressfinance.herokuapp.com/
- Users can login and create a portfolio containing a list of stocks they own and view a snapshot of how their portfolio is perfmorming.
- Users can create a watchlist of stocks they are interested in.
- User can read financial news about the company.
The application uses the following technologies/frameworks :
- axios
- node/express/ejs/express-ejs-layouts
- postgresql
Additional node packages are also needed :
- finnhub.js
- sequelize
- dotenv
Run npm install
to install all dependencies
You will need the following keys in the .env file.
- PORT - describes the port you are using
- SECRET_KEY - for encrypting userid
- API_TOKEN - https://finnhub.io/ API token key. the token can be obtained for free at finnhub.com
- SANDBOX_API_TOKEN - sandbox API token key for testing endpoints. also from finnhub.io
- ALPHAVANTAGE_API_KEY - API token from https://www.alphavantage.co/. This is used for searching stocks.
- STOCKDATA_TOKEN - API token from https://www.stockdata.org/
Database/Models
- The application is using PostgreSQL. Postgresql should be installed. Once installed, create a new database named
express_finance
- Run the sequelize scripts in
createModel.txt
to create models.
A free API key must be obtained from finnhub.io. This API key will be stored in the .env file. (Read Changes
section at the bottom of the page.)
Table definitions :
field name | data type | description |
---|---|---|
id | serial_primary_key | primary key |
username | varchar(255) | user generated user name. unique |
firstname | varchar(25) | user first name |
lastname | varchar(25) | user last name |
varchar(50) | email address | |
password | varchar(255) | user password |
status | varchar(1) | user status. active or disabled |
field name | data type | description |
---|---|---|
id | serial_primary_key | primary key |
userId | foreign_key | linked to user table pk |
portfolioname | varchar(50) | portfolio name |
dateadded | date | creation date of portfolio |
field name | data type | description |
---|---|---|
id | serial_primary_key | primary key |
portfolioId | foreign_key | linked to portfolio table pk |
stockname | varchar(255) | stock name |
symbol | varchar(10) | stock symbol |
stockcount | integer(8) | number of this stock in the portfolio (renamed to stockcount ) |
dateadded | date | date added to portfolio |
field name | data type | description |
---|---|---|
id | serial_primary_key | primary key |
userId | foreign_key | linked to user table pk |
portofliocontentId | foreign_key | linked to portfoliocontentId table pk |
transdate | date | transaction date |
symbol | varchar(10) | stock symbol |
transtype | varchar(1) | transaction type. buy or sell |
stockcount | integer (8) | number of stocks bought or sold in the transaction (renamed to quantity ) |
price | double (changed to decimal(10,2) ) |
purchase price of stock |
field name | data type | description |
---|---|---|
id | serial_primary_key | primary key |
userId | foreign_key | linked to user table pk |
stockname | varchar(255) | stock name |
symbol | varchar(10) | stock symbol |
dateadded | date | date stock added to watchlist |
Method | Path | Description |
---|---|---|
GET | / | Home page |
GET | /register | Registers a new account |
POST | /login | Login page |
GET | /lookup | Search stocks |
GET | /results/:id | Displays results |
POST | /portfolio | create a new portofolio |
POST | /portofolio/:id/usertransactions | Add stocks to portfolio (modified) |
POST | /watchlist/:id | add stock to watchlist |
GET | /company/id | display company profile |
DELETE | /portofolio/:id | remove stock from portfolio (Changed. Deletes portfolio) |
DELETE | /watchlist/:id | remove stock from watchlist |
GET | /logout | logout |
- Displays financial news
- If user has not logged in, a
Login
andRegister
button/link will be displayed. - If user is logged in, a
Logout
button/link will be displayed.
- A
username
andpassword
fields, and a submit button will be displayed. - A successful login will take them to their dashboard.
-
If the user has no account, they will be asked to register one.
-
The following information will be required to create an account :
1. Username (this will be used as for logins) 2. First Name 3. Last Name 4. Email address 5. Password
-
Once an account is successfuly created, they will be redirected to their dashboard.
- The dashboard displays the user's account information, list of porfolios and watchlist.
- Displays the stocks in the portfolio.
- Shows information about how the stocks are performing.
- Displays the stocks in the user's watchlist.
- Shows information about how the stocks are performing.
- This is tied to the search bar in the navigation. Any searches done will be displayed here.
- Buttons to add to
Portfolio
orWatchlist
will diplayed beside the results. - Links to each stock information will be available here.
- This will display the company's financial information as well as stock prices.
- Contains website logo
- Search bar for stock prices
- Menu for navigating the website.
- Menu might inlcude links to the Home page, News page, Portfolio page, Dashboard, Login/Register, and Logout.
- Localized current date and time
- As a user, I would like to be able to log in.
- As a user, I would like to be able to add stocks I currently own in a portfolio to be tracked.
- As a user, I woule like to be able to add stocks I am interested in a watchlist.
- Creation of registration and login page. All data will be stored in PostgresSql.
- Search and save stocks to portfolio and/or watchlist.
- Display stock prices.
- Show performance of stocks in the portfolio.
- Show real-time stock prices in company profile page. (Done)
- Add a crypto portfolio.
- User can now register and login. User can logout and clear session.
- User can create portfolios.
- User can search stocks and add to portfolio.
- News are published when clicking thet NEWS link in the navigation
- Performance of each stock can be viewed in portfolio.
- Watchlist contains current prices of stocks.
- User can edit account details.
- Renamed table/model
portfoliocontent
toportfoliodetail
- Renamed table/model
usertransactions
tousertransaction
- Renamed column
portfoliocontentId
toportfoliodetailsId
inusertransaction
table/model. - Renamed column
stockcount
toquantity
inusertransaction
table/model. - Renamed column
stockcount
toquantity
inportfoliodetail
table/model. - Changed datatype of
price
inusertransaction
table/model frominteger
todecimal(10,2)
- Stocks will not be removed from porfolio. Instead, it will be closed after selling all.
- Majority of the API endpoints are from stockdata.org.
Method | Path | Description |
---|---|---|
POST | /portfolio/add | Adds a portofolio |
GET | /portfolio/details/:id | Renders details.ejs. This is to list stocks in selected portfolio |
GET | /portfolio/to?symbol | Renders addstock.ejs. Displays form for adding stock to a portfolio |
POST | /portfolio/add_stock/?symbol | Adds stocks to portfolio |
GET | /news | Renders news.ejs. Displays finance news |
GET | /watchlist/addstock?symbol | Adds stock to watchlist. Page redirected to /watchlist . This is the page view of watchlist. |
GET | /user | Opens account information with form to edit details. |
PUT | /user | Updates account information. |
DELETE | /portofolio/:id | remove stock from portfolio (Changed. Deletes portfolio) |
POST | /portofolio/:id/usertransactions | Add stocks to portfolio (modified) |
- Create watchlist table/model.
- List stocks of a selected portfolio.
- List stock of watchlist.
- Display portfolio performance.
- Create company profile page. Shows news, stock quotes.
- Added Intra-day chart