Search in sources :

Example 1 with SmtpSsl

use of suite.smtp.SmtpSsl in project suite by stupidsing.

the class DailyMain method run.

private boolean run() {
    Trade_.blackList = Union.of(Trade_.blackList, blackList);
    var sellPool = "sellpool";
    var ymd = HkexUtil.getCloseTimeBefore(Time.now()).ymd();
    var td = ymd + "#";
    // perform systematic trading
    var results = // 
    Read.each(// 
    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);
    }
    var sbs = Summarize.of(cfg).summarize(trade -> trade.strategy);
    var strategyTrades = // 
    results.concatMap2(// 
    result -> Read.from(result.trades).map2(trade -> result.strategy, trade -> trade)).filterValue(// 
    trade -> trade.buySell != 0).collect();
    var requestTrades = strategyTrades.filterKey(strategy -> !Equals.string(strategy, sellPool));
    var amounts = strategyTrades.values().collect(LiftDbl.of(Trade::amount));
    var buys_ = amounts.filter(amount -> 0d < amount).sum();
    var sells = amounts.filter(amount -> amount < 0d).sum();
    sb.append(// 
    sbs.log + "\n" + // 
    sbs.pnlByKey + // 
    "\nBUY REQUESTS" + // 
    requestTrades.filterValue(// 
    trade -> 0 < trade.buySell).sortByValue(// 
    Trade::compare).map((strategy, t) -> // 
    "" + Trade.of(td, -t.buySell, t.symbol, t.price, sellPool).record() + // 
    "\n" + // 
    Trade.of(td, +t.buySell, t.symbol, t.price, strategy).record()) + // 
    "\n" + // 
    "\nSELL REQUESTS" + // 
    requestTrades.filterValue(// 
    trade -> trade.buySell < 0).sortByValue(// 
    Trade::compare).map((strategy, t) -> // 
    "" + Trade.of(td, +t.buySell, t.symbol, t.price, strategy).record() + // 
    "\n" + // 
    Trade.of(td, -t.buySell, t.symbol, t.price, sellPool).record()) + // 
    "\n" + "\nTOTAL BUYS_ = " + // 
    To.string(buys_) + "\nTOTAL SELLS = " + // 
    To.string(sells) + // 
    "\n" + // 
    "\nSUGGESTIONS" + // 
    "\n- check your balance" + "\n- sell mamr and " + // 
    sellPool + "\n");
    var result = sb.toString().replace(".0\t", "\t");
    Log_.info(result);
    new SmtpSsl().send(null, getClass().getName(), result);
    return true;
}
Also used : BackAllocator(suite.trade.backalloc.BackAllocator) Union(primal.Verbs.Union) Singleton(suite.node.util.Singleton) SerializedStoreCache(suite.os.SerializedStoreCache) Trade_(suite.trade.Trade_) Math_(suite.math.Math_) Sink(primal.fp.Funs.Sink) RunUtil(suite.util.RunUtil) ArrayList(java.util.ArrayList) Bacs(suite.trade.backalloc.BackAllocConfigurations.Bacs) Instrument(suite.trade.Instrument) Streamlet(primal.streamlet.Streamlet) Math.round(java.lang.Math.round) BackAllocatorOld(suite.trade.backalloc.strategy.BackAllocatorOld) TradeCfg(suite.trade.data.TradeCfg) LiftDbl(primal.primitive.DblMoreVerbs.LiftDbl) SmtpSsl(suite.smtp.SmtpSsl) BackAllocTester(suite.trade.backalloc.BackAllocTester) Serialize(suite.serialize.Serialize) Pair(primal.adt.Pair) TradeCfgImpl(suite.trade.data.TradeCfgImpl) HkexUtil(suite.trade.data.HkexUtil) Summarize(suite.trade.analysis.Summarize) Set(java.util.Set) To(suite.util.To) Log_(primal.os.Log_) Read(primal.MoreVerbs.Read) Strategos(suite.trade.singlealloc.Strategos) List(java.util.List) Trade(suite.trade.Trade) BackAllocConfiguration(suite.trade.backalloc.BackAllocConfiguration) Time(suite.trade.Time) BackAllocConfigurations(suite.trade.backalloc.BackAllocConfigurations) AsDbl(primal.primitive.fp.AsDbl) Account(suite.trade.Account) SingleAllocBackTest(suite.trade.singlealloc.SingleAllocBackTest) Equals(primal.Verbs.Equals) TimeRange(suite.trade.TimeRange) Trade(suite.trade.Trade) SmtpSsl(suite.smtp.SmtpSsl)

Aggregations

Math.round (java.lang.Math.round)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Read (primal.MoreVerbs.Read)1 Equals (primal.Verbs.Equals)1 Union (primal.Verbs.Union)1 Pair (primal.adt.Pair)1 Sink (primal.fp.Funs.Sink)1 Log_ (primal.os.Log_)1 LiftDbl (primal.primitive.DblMoreVerbs.LiftDbl)1 AsDbl (primal.primitive.fp.AsDbl)1 Streamlet (primal.streamlet.Streamlet)1 Math_ (suite.math.Math_)1 Singleton (suite.node.util.Singleton)1 SerializedStoreCache (suite.os.SerializedStoreCache)1 Serialize (suite.serialize.Serialize)1 SmtpSsl (suite.smtp.SmtpSsl)1 Account (suite.trade.Account)1 Instrument (suite.trade.Instrument)1