timolson / cointrader

Coin Trader is a Java-based backend for algorithmically trading cryptocurrencies. It provides data collection and export, complex event processing and triggering, and backtesting - paper trading - live trading.
Other
450 stars 166 forks source link

Exception during resetDatabase #134

Closed buffxz closed 8 years ago

buffxz commented 8 years ago
2016-02-26 19:34:23 [main] ERROR org.cryptocoinpartners.bin.Main - Uncaught error while running ResetDatabaseRunMode
java.lang.Error: Could not initialize db
        at org.cryptocoinpartners.util.PersistUtil.init(PersistUtil.java:808) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.util.PersistUtil.resetDatabase(PersistUtil.java:703) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.bin.ResetDatabaseRunMode.run(ResetDatabaseRunMode.java:18) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.bin.Main.main(Main.java:129) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
Caused by: java.lang.ExceptionInInitializerError: null
        at org.cryptocoinpartners.util.PersistUtil.ensureSingletonsExist(PersistUtil.java:823) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.util.PersistUtil.init(PersistUtil.java:801) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        ... 3 common frames omitted
Caused by: javax.persistence.NoResultException: No entity found for query
        at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:498) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.util.EM.sqlQueryOne(EM.java:334) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.util.EM.queryOne(EM.java:314) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.schema.Currency.forSymbol(Currency.java:41) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.schema.Prompt.forSymbolOrCreate(Prompt.java:162) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.schema.Prompts.prompt(Prompts.java:18) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.cryptocoinpartners.schema.Prompts.<clinit>(Prompts.java:7) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
        ... 5 common frames omitted
buffxz commented 8 years ago
 [main] DEBUG o.cryptocoinpartners.module.Context - no module file found for XchangeData.epl on classpath. Please ensure XchangeData.epl is in the resources directory.
buffxz commented 8 years ago
2016-02-26 19:38:07 [main] ERROR org.cryptocoinpartners.bin.Main - Uncaught error while running ConsoleRunMode
javax.persistence.NoResultException: No entity found for query
    at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:498) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.util.EM.sqlQueryOne(EM.java:334) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.util.EM.queryOne(EM.java:314) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.schema.Currency.forSymbol(Currency.java:41) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.schema.Asset.forSymbol(Asset.java:22) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.schema.BaseStrategy.setPortfolio(BaseStrategy.java:30) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.schema.StrategyInstance.afterAttach(StrategyInstance.java:134) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.module.Context.attach(Context.java:166) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.module.Context.attachInstance(Context.java:192) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.bin.ConsoleRunMode.init(ConsoleRunMode.java:127) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.bin.ConsoleRunMode.run(ConsoleRunMode.java:53) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
    at org.cryptocoinpartners.bin.Main.main(Main.java:129) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na]
2016-02-26 19:38:07 [pool-3-thread-1] DEBUG org.cryptocoinpartners.persist -  PortfolioJpaDao$$EnhancerByGuice$$90733a76:merge. Succefully merged Portfolio ConsoleStrategy
douggie commented 8 years ago

Hi,

I have replicated this, seems like when it is persisting via a static injection, the transaction is not getting committed to DB. I will hopefully get a chance to fix it in the next 48 hours.

Regards

Douggie

buffxz commented 8 years ago

Cool thanks. Could you also help to verify all the other command is OK? This project is great. However, this seems unusable to me now due to these issues. I always run into issue like complie, build, or start the shell script.

Could you help to clean this up? I can start contribute to this repo once I get this set up.

douggie commented 8 years ago

Hi,

I certainly will, I have checked all the other commands and the look good, my apologies for the incomplete code, just limited time and mainly focused on getting all the accounting and back testing working.

Regards

Douggie

On Sun, Feb 28, 2016 at 10:50 AM, Xu Zhuo Joshua notifications@github.com wrote:

Cool thanks. Could you also help to verify all the other command is OK? This project is great. However, this seems unusable to me now due to these issues. I always run into issue like complie, build, or start the shell script.

Could you help to clean this up? I can start contribute to this repo once I get this set up.

— Reply to this email directly or view it on GitHub https://github.com/timolson/cointrader/issues/134#issuecomment-189832475 .

douggie commented 8 years ago

Hi Xu,

Checked in a fix for this, basically the persistence now works by putting messages on a queue, then reading them off, this is to allow rapid algo performance without having to wait for the db persistence, which can be slow when running on VPS such as AWS or DigitialOcean. The issue was the application was exiting before the queue was drained, I have but a quick fix in, but we should look to add a shutdown hook that only shutdown the JVM once the persistence queue is empty.

https://github.com/timolson/cointrader/issues/135

On Sat, Feb 27, 2016 at 3:38 AM, Xu Zhuo Joshua notifications@github.com wrote:

2016-02-26 19:38:07 [main] ERROR org.cryptocoinpartners.bin.Main - Uncaught error while running ConsoleRunMode javax.persistence.NoResultException: No entity found for query at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:498) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.util.EM.sqlQueryOne(EM.java:334) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.util.EM.queryOne(EM.java:314) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.schema.Currency.forSymbol(Currency.java:41) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.schema.Asset.forSymbol(Asset.java:22) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.schema.BaseStrategy.setPortfolio(BaseStrategy.java:30) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.schema.StrategyInstance.afterAttach(StrategyInstance.java:134) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.module.Context.attach(Context.java:166) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.module.Context.attachInstance(Context.java:192) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.bin.ConsoleRunMode.init(ConsoleRunMode.java:127) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.bin.ConsoleRunMode.run(ConsoleRunMode.java:53) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] at org.cryptocoinpartners.bin.Main.main(Main.java:129) ~[cointrader-0.3.0-SNAPSHOT-jar-with-dependencies.jar:na] 2016-02-26 19:38:07 [pool-3-thread-1] DEBUG org.cryptocoinpartners.persist - PortfolioJpaDao$$EnhancerByGuice$$90733a76:merge. Succefully merged Portfolio ConsoleStrategy

— Reply to this email directly or view it on GitHub https://github.com/timolson/cointrader/issues/134#issuecomment-189571393 .