Search in sources :

Example 1 with SmtpSslGmail

use of suite.smtp.SmtpSslGmail 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;
}
Also used : BackAllocator(suite.trade.backalloc.BackAllocator) Read(suite.streamlet.Read) LogUtil(suite.os.LogUtil) SerializedStoreCache(suite.os.SerializedStoreCache) Trade_(suite.trade.Trade_) RunUtil(suite.util.RunUtil) ArrayList(java.util.ArrayList) Bacs(suite.trade.backalloc.BackAllocConfigurations.Bacs) ConfigurationImpl(suite.trade.data.ConfigurationImpl) String_(suite.util.String_) BackAllocatorOld(suite.trade.backalloc.strategy.BackAllocatorOld) Map(java.util.Map) BackAllocTester(suite.trade.backalloc.BackAllocTester) Simulate(suite.trade.backalloc.BackAllocTester.Simulate) Set_(suite.util.Set_) BuySellStrategy(suite.trade.singlealloc.BuySellStrategy) Streamlet2(suite.streamlet.Streamlet2) ExecutableProgram(suite.util.RunUtil.ExecutableProgram) Summarize(suite.trade.analysis.Summarize) Set(java.util.Set) To(suite.util.To) Obj_Dbl(suite.primitive.DblPrimitives.Obj_Dbl) Serialize(suite.util.Serialize) Strategos(suite.trade.singlealloc.Strategos) Pair(suite.adt.pair.Pair) List(java.util.List) Trade(suite.trade.Trade) BackAllocConfiguration(suite.trade.backalloc.BackAllocConfiguration) Streamlet(suite.streamlet.Streamlet) Time(suite.trade.Time) BackAllocConfigurations(suite.trade.backalloc.BackAllocConfigurations) Configuration(suite.trade.data.Configuration) MathUtil(suite.math.MathUtil) Account(suite.trade.Account) DataSource(suite.trade.data.DataSource) Sink(suite.util.FunUtil.Sink) As(suite.streamlet.As) SingleAllocBackTest(suite.trade.singlealloc.SingleAllocBackTest) DblStreamlet(suite.primitive.streamlet.DblStreamlet) Asset(suite.trade.Asset) SmtpSslGmail(suite.smtp.SmtpSslGmail) TimeRange(suite.trade.TimeRange) SummarizeByStrategy(suite.trade.analysis.Summarize.SummarizeByStrategy) Trade(suite.trade.Trade) As(suite.streamlet.As) DblStreamlet(suite.primitive.streamlet.DblStreamlet) SmtpSslGmail(suite.smtp.SmtpSslGmail)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Pair (suite.adt.pair.Pair)1 MathUtil (suite.math.MathUtil)1 LogUtil (suite.os.LogUtil)1 SerializedStoreCache (suite.os.SerializedStoreCache)1 Obj_Dbl (suite.primitive.DblPrimitives.Obj_Dbl)1 DblStreamlet (suite.primitive.streamlet.DblStreamlet)1 SmtpSslGmail (suite.smtp.SmtpSslGmail)1 As (suite.streamlet.As)1 Read (suite.streamlet.Read)1 Streamlet (suite.streamlet.Streamlet)1 Streamlet2 (suite.streamlet.Streamlet2)1 Account (suite.trade.Account)1 Asset (suite.trade.Asset)1 Time (suite.trade.Time)1 TimeRange (suite.trade.TimeRange)1 Trade (suite.trade.Trade)1