use of suite.primitive.streamlet.DblStreamlet in project suite by stupidsing.
the class DailyMain method run.
@Override
protected boolean run(String[] args) {
Trade_.blackList = Set_.union(Trade_.blackList, blackList);
String sellPool = "sellpool";
String ymd = Time.now().ymd();
String td = ymd + "#";
// perform systematic trading
List<Result> results = //
List.of(//
alloc(bacs.pair_bb, 66666f), //
alloc("bug", bacs.bac_sell, 0f), //
alloc(bacs.pair_donchian, 100000f), //
alloc(bacs.pair_ema, 0f), //
mamr(50000f), //
alloc(bacs.pair_pmamr, 150000f), //
alloc(bacs.pair_pmamr2, 366666f), //
alloc(bacs.pair_pmmmr, 80000f), //
alloc(bacs.pair_revco, 0f), //
alloc(bacs.pair_tma, 0f), alloc(sellPool, bacs.bac_sell, 0f));
// unused strategies
if (Boolean.FALSE) {
alloc(bacs.pair_donchian, 100000f);
pairs(0f, "0341.HK", "0052.HK");
sellForEarn(sellPool);
}
SummarizeByStrategy<Object> sbs = Summarize.of(cfg).summarize();
Streamlet2<String, Trade> strategyTrades = //
Read.from(//
results).concatMap2(//
result -> Read.from(result.trades).map2(trade -> result.strategy, trade -> trade)).filterValue(//
trade -> trade.buySell != 0).collect(As::streamlet2);
Streamlet2<String, Trade> requestTrades = strategyTrades.filterKey(strategy -> !String_.equals(strategy, sellPool));
DblStreamlet amounts = strategyTrades.values().collect(Obj_Dbl.lift(Trade::amount));
double buys_ = amounts.filter(amount -> 0d < amount).sum();
double sells = amounts.filter(amount -> amount < 0d).sum();
sb.append(//
sbs.log + "\n" + //
sbs.pnlByKey + "\n" + //
strategyTrades.sortBy(//
(strategy, trade) -> trade.amount()).map((strategy, trade) -> //
"\n" + //
(0 <= trade.buySell ? "BUY^" : "SELL") + " SIGNAL(" + strategy + ")" + //
trade + " = " + //
To.string(trade.amount())).collect(//
As::joined) + //
"\n" + //
"\nBUY REQUESTS" + //
requestTrades.filterValue(//
trade -> 0 < trade.buySell).map((strategy, t) -> //
"" + "\n" + //
Trade.of(td, -t.buySell, t.symbol, t.price, sellPool).record() + "\n" + //
Trade.of(td, +t.buySell, t.symbol, t.price, strategy).record()).collect(//
As::joined) + //
"\n" + //
"\nSELL REQUESTS" + //
requestTrades.filterValue(//
trade -> trade.buySell < 0).map((strategy, t) -> //
"" + "\n" + //
Trade.of(td, +t.buySell, t.symbol, t.price, strategy).record() + "\n" + //
Trade.of(td, -t.buySell, t.symbol, t.price, sellPool).record()).collect(//
As::joined) + //
"\n" + "\nTOTAL BUYS_ = " + //
To.string(buys_) + "\nTOTAL SELLS = " + //
To.string(sells) + //
"\n" + //
"\nSUGGESTIONS" + //
"\n- check your balance" + //
"\n- sort the orders and get away the small ones" + //
"\n- get away the stocks after ex-date" + "\n- sell mamr and " + //
sellPool + //
"\n- for mamr, check actual execution using SingleAllocBackTestTest.testBackTestHkexDetails()" + "\n");
String result = sb.toString();
LogUtil.info(result);
SmtpSslGmail smtp = new SmtpSslGmail();
smtp.send(null, getClass().getName(), result);
return true;
}
Aggregations