public Observable<OrderEvent> observeClose(final ClosePositionParams closePositionParams) { return Observable.defer( () -> { final Collection<IOrder> ordersToClose = ordersForPositionClose.forMode(closePositionParams); return ordersToClose.size() > 0 ? batchChangeTask.close(ordersToClose, closePositionParams) : Observable.empty(); }); }
private Observable<OrderEvent> observeMergeForFilledOrders( final ClosePositionParams closePositionParams) { return Observable.defer( () -> { final Collection<IOrder> filledOrders = ordersForPositionClose.filled(closePositionParams.instrument()); return filledOrders.size() > 1 ? mergePositionTask.merge(filledOrders, closePositionParams.mergePositionParams()) : Observable.empty(); }); }
public Observable<OrderEvent> observeMerge(final ClosePositionParams closePositionParams) { return closePositionParams.closeExecutionMode() == CloseExecutionMode.CloseOpened ? Observable.empty() : observeMergeForFilledOrders(closePositionParams); }