Stock prices processing components:
-
service.ApiStockService
: Stateful service. On each call, we get a batch of pseudo-random-generated stock prices. Each call also moves forward the current time. -
message.StockTickSupplierConfig
: Using a mock APIservice.ApiStockService
, it generates an infinite sequence of stock prices with astock-update.frequency.seconds
frequency and pushes these prices into the testtock Kafka topic. -
message.StockTickConsumerConfig
: Consumes the stock prices from the testtock Kafka topic and stores them in a raw format in thestockTick
Mongodb collection usingservice.StockTickService
-
message.CandleStickConsumerConfig
: Consumes the stock prices from the testtock Kafka topic and callsservice.CandleStickService
to update the day-based and hour-based CandleSticks
API endpoints:
Company
endpoints:- GET
/api/v1/companies
: list all companies with stock prices. It is defined statically ininitializer.MasterDataLoader
, instead of being defined by the incoming stock prices. It is a coroutine-based reactive endpoint.
- GET
StockTick
endpoints:- GET
/api/v1/ticks/changelog
: Server pushes new stock prices being stored in MongoDB using Server-sent events. Only for debugging purposes. - GET
/api/v1/ticks
: retrieves all stock prices. Just for debugging in non-prod envs. due to the scale of data. - POST
/api/v1/ticks/delete-all
: deletes all stock prices from database. Only for debugging purposes.
- GET
CandleStick
endpoints:- GET
/api/v1/candles/changelog
: Server pushes candle updates being stored in MongoDB using Server-sent events. Only for debugging purposes. - GET
/api/v1/candles
: retrieves all candles, optionally filtered by query params ticker and type. Valid values for ticker: AMZN,AAPL,GOOG,META. Valid values for type: DAY,ONE_HOUR. - POST
/api/v1/candles/delete-all
: deletes all candles from database. Only for debugging purposes.
- GET
- Install docker and docker-compose
- JVM
- Run
docker-compose up
mvn spring-boot:run
- curl http://localhost:8080/api/v1/candles/?ticker=META&type=ONE_HOUR
[
{
"id": "63849bcad4c41217e8e109e5",
"type": "ONE_HOUR",
"ticker": "META",
"timestamp": "2022-11-28T15:00:00",
"high": 180,
"low": 105
},
...
]
- Introduce tests. Refactor app code as needed for testability.
- Split code into modules: API, Stock API Consumer, Prices Processor(s)
- Implement Weekly Candlesticks.
- Better input handling and validation.
- Add Open and Close prices for Candlesticks.