use of suite.util.To in project suite by stupidsing.
the class RecursiveFactorizerTest method transform.
private FNode transform(FNode fn0) {
FTerminal from = new FTerminal(To.chars("ic-compile-better-option"));
FTerminal to = new FTerminal(To.chars("ic-new-compile-better-option"));
Iterate<FNode> fun = fn_ -> fn_.equals(from) ? to : null;
return transform(fn0, fun);
}
use of suite.util.To in project suite by stupidsing.
the class DailyMain method sellForEarn.
// some orders caused by stupid bugs. need to sell those at suitable times.
private Result sellForEarn(String tag) {
Streamlet<Trade> history = cfg.queryHistory().filter(r -> String_.equals(r.strategy, tag));
Account account = Account.ofPortfolio(history);
Map<String, Float> faceValueBySymbol = //
history.groupBy(record -> record.symbol, //
rs -> (float) Read.from(rs).toDouble(Obj_Dbl.sum(Trade::amount))).toMap();
List<Trade> trades = //
account.portfolio().map((symbol, sell) -> {
double targetPrice = (1d + 3 * Trade_.riskFreeInterestRate) * faceValueBySymbol.get(symbol) / sell;
return Trade.of(-sell, symbol, (float) targetPrice);
}).toList();
return new Result(tag, trades);
}
Aggregations