- Node.js v22
- npm
Fetch latest X trades of a specific symbol from Binance API and analyse how many drops and rises where there in prices. Exposes fetched trades and analysis over HTTP api.
- Install dependencies
npm i - Create and fill env file
cp .env.template .env.dev - Running:
- dev mode
npm run dev- fetches data and starts api to listen for queries. Restarts on file changes - tests
npm t- runs tests (PriceService.test.ts)
- Configuration is controlled using environment variables - dev script uses
.env.devfile, update there if necessary.
Given time restrictions and vague requirements I decided to:
- follow simple APIs (fetching historical trades)
- use in memory data storage for simpler code (in real world scenario persistent storage should be used)
- calculate only drops and rises in prices
- expose only two endpoint
/tradesand/analysisto showcase express usage, but keep things simple at the same time - test only prices calculation and data fetching (couldnt get mocking from node test framework to work, but would basically mock
binanceService.fetchHistoricalTradescalls with premade data and assert that it issues more calls than just one etc.)