When starting up a strategy in Live Trading Mode, it is often necessary to initialize technical indicators that have a look-back period. This initialization is done by feeding historical market data into the Esper Engine.
A typical pre-feed method will look like this:
@Override protected void onPrefeed(final LifecycleEventVO event) { switch (event.getOperationMode()) { case REAL_TIME: feedMarketData(); break; } } public void feedMarketData() { Date date = DateUtils.addHours(new Date(), -1); Collection<TickVO> ticks = getHistoricalDataService().getTicksByMinDate(securityId, date, 1); getEngine().initCoordination(); getEngine().coordinate(new CollectionInputAdapter(ticks, "dateTime")); getEngine().startCoordination(); }
This method will load all ticks for the security (defined by securityId
) for the last hour. It will then feed all of them sequentially to the local EsperEngine.
For further details on Esper Coordination please visit the Esper documentation
Note
Feeding of live market data only starts in the START
live cycle phase. This prevents mix-up of historical pre-feed data and live market data.
Comments
0 comments
Please sign in to leave a comment.