DebugTradingManager: use event-based notification

This commit is contained in:
2019-02-12 10:05:42 -08:00
parent a92a3e4788
commit 6cd5f18f5c

View File

@ -1,6 +1,7 @@
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,6 +17,9 @@ public class DebugTradingManager implements TradingManager {
private EsperProcessor processor;
/**
* Create a new trading manager.
*/
public DebugTradingManager() {
}
@ -27,10 +31,32 @@ public class DebugTradingManager implements TradingManager {
}
/**
* Place an order request.
* Place an order request to open a new position.
*/
@Override
public OrderReply openPosition(String instrument, BigDecimal units) {
String orderName = String.format("order_%04d", orderID++);
Map<String,Object> values = new HashMap<String,Object>();
values.put("id", orderName);
values.put("instrument", instrument);
values.put("price", new BigDecimal(12));
values.put("units", units);
processor.sendEvent("OpenOrderStream", values);
// return orderReply;
return null; // TODO
}
/**
* Place an order request to close an existing position.
*/
@Override
public void placeOrder(OrderRequest order) {
log.info("Place order: {}", order);
}
public void closePosition(String orderID) {
Map<String,String> values = new HashMap<String,String>();
values.put("id", orderID);
processor.sendEvent("CloseOrderStream", values);
}
}