use of suite.primitive.IntIntSink in project suite by stupidsing.
the class Trade_ method collectBrokeredTrades.
public static Streamlet<Trade> collectBrokeredTrades(Outlet<Trade> outlet) {
Trade[] trades0 = outlet.toArray(Trade.class);
List<Trade> trades1 = new ArrayList<>();
int length0 = trades0.length;
int i0 = 0;
IntIntSink tx = (i0_, i1_) -> {
if (Ints_.range(i0_, i1_).mapInt(i -> trades0[i].buySell).sum() != 0)
while (i0_ < i1_) {
Trade trade0 = trades0[i0_++];
if (!String_.equals(trade0.remark, "#"))
trades1.add(trade0);
}
};
for (int i = 1; i < length0; i++) {
Trade trade0 = trades0[i0];
Trade trade1 = trades0[i];
boolean isGroup = //
true && //
String_.equals(trade0.date, trade1.date) && //
String_.equals(trade0.symbol, trade1.symbol) && trade0.price == trade1.price;
if (!isGroup) {
tx.sink2(i0, i);
i0 = i;
}
}
tx.sink2(i0, length0);
return Read.from(trades1);
}
Aggregations