This project integrates the Massive (formerly Polygon) market data provider with the existing ExchangePoller infrastructure. The ExchangePoller's role is to poll new updates from different exchanges, and we've added support for fetching aggregate bar data from Massive.
The ExchangePoller (in services/market/exchange-poller.go) polls configured data sources at regular intervals (currently every 1 second). It iterates over the provided feed.Datasource implementations and calls Pull() on each.
The feed.Datasource interface (in core/feed/feed.go) defines:
type Datasource interface {
Pull(query DatasourceQueryRequest) ([]FeedEntry, error)
}The new MassiveDatasource (in core/feed/massive.go) implements this interface to fetch aggregate bar data from the Massive API (formerly Polygon.io).
Key features:
- Fetches recent aggregate bars for a given symbol and time interval
- Converts Massive's response format to the internal
TradeDatastructure - Implements the
feed.Datasourceinterface seamlessly - Configurable request timeout via
MassiveConfig
The MassiveDatasource queries the Massive API endpoint:
https://api.polygon.io/v2/aggs/ticker/{symbol}/range/{multiplier}/{timespan}/{from}/{to}?apiKey={apikey}
Supported parameters:
symbol: Trading symbol (e.g., "AAPL")interval: Time range interval (5min, 30min, 60min, daily, weekly, monthly)from/to: Date range in YYYY-MM-DD format
Response fields converted to TradeData:
- Open, High, Low, Close prices
- Volume
The following environment variable is required (already present in app/cmd/.env):
MASSIVE_API_KEY=k2ZDg6YupZ45k7Wh8DtMpvplzwvm1cuD
The integration is configured in app/cmd/ioc.go:
if err := ioc.Factory(func(h *market.ExchangeHub, l *slog.Logger) *market.ExchangePoller {
return market.NewExchangePoller(l.With("service", "exchange-poller"), h, []feed.Datasource{
feed.NewMassiveDatasource(os.Getenv("MASSIVE_API_KEY"), feed.MassiveConfig{RequestTimeout: 10 * time.Second}),
})
}, true); err != nil {
return err
}The project builds successfully with:
cd I:/mogtrade-engine/app && go build ./...- Created
core/feed/massive.go- New MassiveDatasource implementing the feed.Datasource interface - Updated
app/cmd/ioc.go- Integrated MassiveDatasource into the ExchangePoller via DI container - Verified compilation - All Go code compiles without errors
- Leveraged existing infrastructure - Uses the same
.envpattern as AlphaVantage and other APIs
- Implement symbol scheduling/management for the Massive datasource
- Add proper error handling and rate limiting
- Support additional Massive API endpoints (crypto, futures, etc.)
- Integrate with the ExchangeHub broadcasting mechanism