}
@Override
public TradingAgentExecutionHandle createExecution(TradingAgentBindingHandle bindingHandle, ExecutionType type) throws ExecutionCreationException {
TradingAgentBinding binding = retrieveBinding(bindingHandle);
ITradingAgentExecution execution;
ITradingAgent tradingAgent = binding.getConfiguration().newTradingAgent();
if (!isExecutionTypeAvailable(type)) {
throw new ExecutionCreationException(type.name() + " execution service not available");
}
if (type == ExecutionType.LIVE){
execution = new TradingAgentExecution(tradingAgent, liveExecutionService);
} else {
execution = new SimulatedTradingAgentExecution(tradingAgent, simulatedExecutionServiceFactory.createSimulatedExecutionService());
}
String executionOutputSeriesId = "output-" + execution.toString();
LinkedListSeries<Date, Double, ISeriesPoint<Date, Double>> outputSeries = new LinkedListSeries<Date, Double, ISeriesPoint<Date, Double>>(executionOutputSeriesId, false);
execution.wire(binding.getInputSeries(), outputSeries);
TradingAgentExecutionHandle handle = new TradingAgentExecutionHandle(execution.toString());
hierarchyContainer.putTradingAgentExecution(handle, execution, bindingHandle);
return handle;
}