Search in sources :

Example 6 with To

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);
}
Also used : FNode(suite.node.parser.FactorizeResult.FNode) Read(suite.streamlet.Read) Singleton(suite.node.util.Singleton) Fun(suite.util.FunUtil.Fun) Node(suite.node.Node) FTree(suite.node.parser.FactorizeResult.FTree) FileUtil(suite.os.FileUtil) Nodify(suite.util.Nodify) Dict(suite.node.Dict) FPair(suite.node.parser.FactorizeResult.FPair) Reference(suite.node.Reference) Source(suite.util.FunUtil.Source) Assert.assertTrue(org.junit.Assert.assertTrue) TermOp(suite.node.io.TermOp) FTerminal(suite.node.parser.FactorizeResult.FTerminal) Test(org.junit.Test) To(suite.util.To) Tree(suite.node.Tree) Iterate(suite.util.FunUtil.Iterate) List(java.util.List) Rewrite(suite.node.util.Rewrite) Assert.assertFalse(org.junit.Assert.assertFalse) Atom(suite.node.Atom) Operator(suite.node.io.Operator) Assert.assertEquals(org.junit.Assert.assertEquals) Str(suite.node.Str) FNode(suite.node.parser.FactorizeResult.FNode) FTerminal(suite.node.parser.FactorizeResult.FTerminal)

Example 7 with To

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);
}
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) Account(suite.trade.Account)

Aggregations

To (suite.util.To)7 List (java.util.List)5 Read (suite.streamlet.Read)5 Map (java.util.Map)3 Set (java.util.Set)3 Singleton (suite.node.util.Singleton)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 Pair (suite.adt.pair.Pair)2 HttpUtil (suite.http.HttpUtil)2 Vector (suite.math.linalg.Vector)2 Statistic (suite.math.numeric.Statistic)2