Server-side of pet project for private needs.
Express app to retrieve precious metals (au, ag, pt, pd) daily quotes (from local bank), store them in MongoDB and provide API on top.
JSON sample
[
{
"date": "2018-12-03T00:00:00.000Z",
"code": 959,
"asset": "au",
"sellByn": 86.9253,
"buyByn": 81.8772,
"sellUsd": 40.81,
"buyUsd": 38.44
},
{
"date": "2018-12-03T00:00:00.000Z",
"code": 961,
"asset": "ag",
"sellByn": 1.0309,
"buyByn": 0.9521,
"sellUsd": 0.484,
"buyUsd": 0.447
},
{
"date": "2018-12-03T00:00:00.000Z",
"code": 962,
"asset": "pt",
"sellByn": 57.6591,
"buyByn": 53.2287,
"sellUsd": 27.07,
"buyUsd": 24.99
},
{
"date": "2018-12-03T00:00:00.000Z",
"code": 964,
"asset": "pd",
"sellByn": 86.4993,
"buyByn": 78.2775,
"sellUsd": 40.61,
"buyUsd": 36.75
}
]- Typescript
- Express
- MongoDB Node.JS Driver
- RxJS
- rx-http-request
- TSLint
- commander.js
- Moment.js
- morgan-mongo
Endpoints:
/quotes/<asset>?date=[YYYY-MM-DD]- single date quotes,asset(au,ag,pt,pd) is optional/quotes/<asset>?startDate=[YYYY-MM-DD]- date range quotes,assetandendDateare optional- TODO: normalized buy/sell (spread is increased on non-working days and hours).
Examples:
/quotes/?date=2018-08-01all asset quotes for Aug, 1/quotes/au?date=2018-08-01gold quotes for Aug, 1/quotes/?startDate=2018-08-01&endDate=2018-08-10gold quotes from Aug, 1 to Aug, 10/quotes/?startDate=2018-12-01all asset quotes for Dec, 1 till now
Available as npm scripts:
- Fetch quotes from remote feed to JSON (
npm run @tools/fetch) - Load quotes from JSON to MongoDB (
npm run @tools/db-import)
Default MongoDB connection options that could be overridden with environment variables:
- connection string:
mongodb://localhost:27017(envMONGO_OMS_URI) - database name:
oms(envMONGO_OMS_DB) - collection name:
asset-quotes(envMONGO_OMS_COLLECTION) - logs collection name:
request-logs(envMONGO_OMS_COLLECTION_LOGS)
git clone https://github.com/pmstss/omsfeed
cd omsfeed
npm install
npm run build
npm run start
or
npm install omsfeed
node node_modules/omsfeed/dist/server.js
Feel free to contribute by opening issues with any questions, ideas or feature requests.