package info.bitrich.xchangestream.bitmex;


import info.bitrich.xchangestream.bitmex.dto.BitmexOrder;
import io.reactivex.Observable;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;

import java.util.Arrays;
import java.util.stream.Collectors;


/**
 * Created by Declan
 */
public class BitmexStreamingTradeService {

    private final BitmexStreamingService streamingService;

    public BitmexStreamingTradeService(BitmexStreamingService streamingService) {
        this.streamingService = streamingService;
    }

    public Observable<Order> getOrders(CurrencyPair currencyPair, Object... args) {
        String channelName = "order";
        String instrument = currencyPair.base.toString() + currencyPair.counter.toString();
        return streamingService.subscribeBitmexChannel(channelName).flatMapIterable(s -> {
            BitmexOrder[] bitmexOrders = s.toBitmexOrders();
            return Arrays.stream(bitmexOrders)
                    .filter(bitmexOrder -> bitmexOrder.getSymbol().equals(instrument))
                    .filter(BitmexOrder::isNotWorkingIndicator)
                    .map(BitmexOrder::toOrder).collect(Collectors.toList());
        });
    }

    public void submitOrder(Order order, CurrencyPair var1, Object... var2) {
        throw new NotYetImplementedForExchangeException();
    }
}

@@ -1285,151 +1285,7 @@
    %7D
-%0A%0A    public void submitOrder(Order order, CurrencyPair var1, Object... var2) %7B%0A        throw new NotYetImplementedForExchangeException();%0A    %7D
 %0A%7D%0A

Delete submit order