EsperProcessor: use trader open/closePosition()
This commit is contained in:
@ -65,28 +65,17 @@ public class EsperProcessor implements TickProcessor {
|
|||||||
addStatement("select * from LongEntryDistinct",
|
addStatement("select * from LongEntryDistinct",
|
||||||
(newData, oldData) -> {
|
(newData, oldData) -> {
|
||||||
String instrument = (String)newData[0].get("instrument");
|
String instrument = (String)newData[0].get("instrument");
|
||||||
Integer units = (Integer)newData[0].get("units");
|
BigDecimal units = (BigDecimal)newData[0].get("units");
|
||||||
trader.placeOrder(new MarketOrderRequest(instrument, units));
|
|
||||||
|
|
||||||
log.debug("Long entry triggered: {} of {} at price {} at time {}",
|
trader.openPosition(instrument, units);
|
||||||
units,
|
|
||||||
instrument,
|
|
||||||
newData[0].get("current"),
|
|
||||||
newData[0].get("time"));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// respond to long exit events
|
// respond to long exit events
|
||||||
addStatement("select * from LongExitStream",
|
addStatement("select * from LongExitStream",
|
||||||
(newData, oldData) -> {
|
(newData, oldData) -> {
|
||||||
String instrument = (String)newData[0].get("instrument");
|
String orderID = (String)newData[0].get("id");
|
||||||
Integer units = (Integer)newData[0].get("units");
|
|
||||||
trader.placeOrder(new MarketOrderRequest(instrument, units));
|
|
||||||
|
|
||||||
log.debug("Long exit triggered: {} of {} at price {} at time {}",
|
trader.closePosition(orderID);
|
||||||
units,
|
|
||||||
instrument,
|
|
||||||
newData[0].get("current"),
|
|
||||||
newData[0].get("time"));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user