omsfeed
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.
Demo
JSON sample
Building blocks, Credits
- Typescript
- Express
- MongoDB Node.JS Driver
- RxJS
- rx-http-request
- TSLint
- commander.js
- Moment.js
- morgan-mongo
API
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,asset
andendDate
are optional- TODO: normalized buy/sell (spread is increased on non-working days and hours).
Examples:
/quotes/?date=2018-08-01
all asset quotes for Aug, 1/quotes/au?date=2018-08-01
gold quotes for Aug, 1/quotes/?startDate=2018-08-01&endDate=2018-08-10
gold quotes from Aug, 1 to Aug, 10/quotes/?startDate=2018-12-01
all asset quotes for Dec, 1 till now
Tools
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
)
Configuration
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
)
Running locally
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
Contribution
Feel free to contribute by opening issues with any questions, ideas or feature requests.