- Github Repo: https://github.com/JudyBui127/stock-trading
- Run npm
npm install
nodemon server.js
- Import this json file to Postman: stock-apis.postman_collection.json (found in this project folder)
- Test API requests and responses as following
- middleware.js
- Check for token in request header 'Authorization' to verify valid login sesson of user before create, update, delete tweets.
-Response:
{
"status": 200,
"message": "Successfully logged in!",
"data": {
"dataUser": {
"id": string,
"username": string
},
"token": string
}
}
{
"status": 201,
"message": "Register successful!",
"data": {
"user": {
"id": string,
"username": string
}
}
}
- Response:
{ status: 200, message: 'Successful!', data: { wallets: { fiat: [{ id: string, currency: string, balance: float }], stocks: [{ id: string, symbol: string, quantity: integer }] } }
- Each wallet should has:
- wallet_type: 'fiat' or 'stock'
- unique currency ('usd', 'cad', 'vnd', 'jpy'...)
- unique stock symbol ('AAPL', 'IBM', 'TSLA' ...)
- Request params:
{ wallet_type: 'fiat', user_id: string, currency: string }
- Successfull response:
{ status: 200, message: "Created fiat wallet successfully!" data: { id: string, wallet_type: 'fiat', owner_id: string, currency: string, balance: float, // default: 0 } }
- Request params:
{ wallet_type: 'stock', user_id: string, symbol: string, }
- Successfull response:
{ status: 200, message: "Created wallet successfully!" data: { id: string, owner_id: string, wallet_type: 'stock', stock: string, symbol: string, quantity: integer, // default: 0 } } }
- Request Params:
{ wallet_type: 'fiat', currency: string, quantity: float }
- Successfull response:
{ status: 200, message: "Deposit successfully!" data: { id: string, owner_id: string, wallet_type: 'fiat', currency: string, balance: float } }
- Request Params:
{ wallet_type: 'stock', stock_id: string, quantity: float }
- Successfull response:
{ status: 200, message: "Deposit successfully!" data: { id: string, owner_id: string, wallet_type: 'stock', stock: string, symbol: string, quantity: integer } } }
-
Request params:
{ wallet_id: string, order_type: string, // 'BUY' | 'SELL' quantity: integer, price: float, fiat_wallet_id: string, }
-
Successful response:
{ status: 200, message: 'Successful!', data: { wallets: { fiat: [{ id: string, currency: string, balance: float }], stocks: [{ id: string, symbol: string, quantity: integer }] } }
Shortcut meaning
o: open price c: close price h: high price l: low price
- Request params:
{ symbol: string, }
- Successful response:
{ status: 200, message: 'Successful!' data: [{ id: string, symbol: string, company_name: string, refreshed_time: string, time_zone: string, interval: string, currency: string, o: float, c: float, h: float, l: float }] } ```` ```
This API should be run by a scheduled cron job INTRADAY INFO will be fetch from this source: alphavantage
- Request:
{ o: float, c: float, h: float, l: float, time: string currency: string }