Newbie question for JBookTrader Setup in Eclipse Luna

248 views
Skip to first unread message

Ben

unread,
Aug 9, 2014, 11:59:39 AM8/9/14
to jbook...@googlegroups.com
I followed 2008 setup instructions and set up JBookTrader in Eclipse Luna (java version jre7). I got 12 warnings in Problems and an additional warning message appeared in Console after running the project: "WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5". The JBookTrader started only with one Strategy "SAMPLE" and symbol "ES". 

I read the topics but couldn't find a solution. Any advice would be great appreciated!

Eugene Kononov

unread,
Aug 9, 2014, 12:27:53 PM8/9/14
to JBookTrader
Hi Ben, and welcome to the group. There is a simple fix to this problem:



On Sat, Aug 9, 2014 at 11:59 AM, Ben <bh...@hotmail.com> wrote:
I followed 2008 setup instructions and set up JBookTrader in Eclipse Luna (java version jre7). I got 12 warnings in Problems and an additional warning message appeared in Console after running the project: "WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5". The JBookTrader started only with one Strategy "SAMPLE" and symbol "ES". 

I read the topics but couldn't find a solution. Any advice would be great appreciated!

--
You received this message because you are subscribed to the Google Groups "JBookTrader" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbooktrader...@googlegroups.com.
To post to this group, send email to jbook...@googlegroups.com.
Visit this group at http://groups.google.com/group/jbooktrader.
For more options, visit https://groups.google.com/d/optout.

Ben

unread,
Aug 9, 2014, 1:26:29 PM8/9/14
to jbook...@googlegroups.com
Thanks for the quick response, Eugene! I created the key HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs and it solved the registry issue. Any suggestion on the issue of only one Strategy "SAMPLE" occurred in JBookTrader? 

Many thanks!

Ali Farahani

unread,
Aug 9, 2014, 3:09:03 PM8/9/14
to jbook...@googlegroups.com
Hi Ben,

JBT comes with one Sample strategy. Using this Sample, you can use the Parameters (PERIOD, SCALE, ENTRY, and EXIT) to create your own strategies. This model is based on signals that the "Order Book" data generates using exponential moving averages (Bid and Ask, Volume, and Price). The two indicators are "BalanceVelocity" and "PriceVelocity". You can use the Optimization functionality of JBT to test with historical data; or run JBJ in Forward Test mode.

The User Guide does provide additional information.

Kind regards,

Ali



--

Ben

unread,
Aug 9, 2014, 3:20:52 PM8/9/14
to jbook...@googlegroups.com
Hi Ali,

I ran the sample strategy (Period=3200,Scale=16, Entry=92, Exit=-21) with supplied ES sample data, it works. Thanks for the suggestion. The remaining issue is I can only see SAMPLE strategy, not others like LongDefender 1-4 and ShortDefender 1-4 listed in User Guide. Did I miss any steps in the setup causing this issue?

Thanks,
Benhuai 

Ali Farahani

unread,
Aug 9, 2014, 3:31:44 PM8/9/14
to jbook...@googlegroups.com
The Sample strategy is a Long strategy (goLong). Using this sample you can write code (a few lines) to trade in short positions using different parameters. The Sample Java file has all the pieces you need to write any type of strategy. You may also want go through the Forum discussions to get more familiar with the JBT framework itself.

Ali

Ali Farahani

unread,
Aug 9, 2014, 3:53:54 PM8/9/14
to jbook...@googlegroups.com
LongDefender and ShortDefender strategies all had the same model with different Parameters.

Ben

unread,
Aug 9, 2014, 4:00:27 PM8/9/14
to jbook...@googlegroups.com
Thanks for the detailed explanation, Ali! It is very helpful. I will look into the sample code and modify it as needed.

Ben

On Saturday, August 9, 2014 2:53:54 PM UTC-5, Ali Farahani wrote:
LongDefender and ShortDefender strategies all had the same model with different Parameters.

Ben

unread,
Aug 11, 2014, 8:05:06 PM8/11/14
to jbook...@googlegroups.com
Hi Ali,

I can run the sample strategy with sample data, and get net profit results via optimizer (brute force or conquer &divide).  But when running forward test in the daytime, no live market data were saved in the /marketdata folder. Under that strategy, book and price were blank; the rest were all zeros. In Help/About JbookTrader/API Info, the Server Version is 71, and Client Version is 53 (it was connected to IB, right?). I can't figure out why. Any suggestion? Thanks!

Ben


On Saturday, August 9, 2014 2:53:54 PM UTC-5, Ali Farahani wrote:
LongDefender and ShortDefender strategies all had the same model with different Parameters.

Eugene Kononov

unread,
Aug 11, 2014, 9:22:36 PM8/11/14
to JBookTrader
My guess is that you were using a "demo" IB account. To get real time market data, you need to use either a paper-trading IB account, or a real IB account.


--

Ben

unread,
Aug 11, 2014, 9:38:42 PM8/11/14
to jbook...@googlegroups.com
Hi Eugene,

I used the real IB account. I checked the report and pasted part of the report below. Should the market data be subscribed first?

Thanks,
Ben


08/11/1407:21:39.994JBookTraderRunning mode changed to: Forward Testing
08/11/1407:21:41.117JBookTraderConnecting to TWS
08/11/1407:21:41.127JBookTraderConnected to TWS
08/11/1407:21:41.128IB API2104: Market data farm connection is OK:usfarm.us
08/11/1407:21:41.128IB API2104: Market data farm connection is OK:usfarm
08/11/1407:21:41.129IB API2106: HMDS data farm connection is OK:ushmds
08/11/1407:21:41.131AccountAvailableFunds: 25000.00
08/11/1407:21:41.164IB API2100: API client has been unsubscribed from account data.
08/11/1407:21:41.167JBookTraderMonitoring server started
08/11/1407:21:41.169Sample_NQStrategy started. Trading schedule: 08:00 to 16:30 (America/New_York)
08/11/1407:21:41.169JBookTraderRequested contract details for instrument NQ-NYSE-STK
08/11/1407:21:41.170JBookTraderRequested book data for instrument NQ-NYSE-STK
08/11/1407:21:41.170JBookTraderRequested market data for instrument NQ-NYSE-STK
08/11/1407:21:41.206IB APIContract details:
ID: 2
Trading class: NQ
Exchanges: SMART,NYSE,ISE,CHX,ARCA,ISLAND,IBSX,DRCTEDGE,BEX,BATS,EDGEA,LAVA,CSFBALGO,JEFFALGO,BYX,IEX,PSX
Long name: NQ MOBILE INC - ADR
Market name: NQ
Minimum tick: 0.01
Contract month: null
Time zone id: EST5EDT
Trading hours: 20140811:0930-1600;20140812:0930-1600
Liquid hours: 20140811:0930-1600;20140812:0930-1600
08/11/1407:21:41.348IB API354: Requested market data is not subscribed.NQ NYSE/DEEP (for id 2)




On Monday, August 11, 2014 8:22:36 PM UTC-5, Eugene Kononov wrote:
My guess is that you were using a "demo" IB account. To get real time market data, you need to use either a paper-trading IB account, or a real IB account.

Eugene Kononov

unread,
Aug 11, 2014, 9:48:41 PM8/11/14
to JBookTrader
This line in report explains it:
354: Requested market data is not subscribed.NQ NYSE/DEEP (for id 2)

In TWS, select an instrument, and pop up the "Market Depth" window. If you can' see market depth in TWS, you will not be able to get in JBT.

Ben

unread,
Aug 11, 2014, 10:10:56 PM8/11/14
to jbook...@googlegroups.com
Got it. It seems that I need to subscribe the data. Thanks Eugene!

Ben

Ben

unread,
Aug 14, 2014, 1:45:29 PM8/14/14
to jbook...@googlegroups.com
Hi Eugene and Ali,

With your kind helps, I am able to run and test this great trading platform JBT. One thing I encountered is when I tried to get the market deep data from stocks list on NASDAQ, the book and price values didn't show up, and it was not stored in /MarketData folder and no error in the report file either.  I subscribed the IB's level II data Nasdaq TotalView, which is supposed to cover stocks such as MSFT, TSLA. The code I used in StrategyMSFT.java (take MSFT as an example) is

Contract contract = ContractFactory.makeStockContract("MSFT", "ISLAND ");

Could you provide your insight? Thanks!

Ben

Eugene Kononov

unread,
Aug 14, 2014, 1:49:54 PM8/14/14
to JBookTrader
This should work:
Contract contract = ContractFactory.makeStockContract("MSFT", "SMART");

Let us know if it does not.


--

Ben

unread,
Aug 14, 2014, 1:53:42 PM8/14/14
to jbook...@googlegroups.com
Still no luck. This time the report file gave a message indicating no data subsribed for the stock/exchange combination.


On Thursday, August 14, 2014 12:49:54 PM UTC-5, Eugene Kononov wrote:
This should work:
Contract contract = ContractFactory.makeStockContract("MSFT", "SMART");

Let us know if it does not.

Eugene Kononov

unread,
Aug 14, 2014, 1:57:00 PM8/14/14
to JBookTrader
In TWS, add MSFT to the grid. Select that line, then click TradingTools | MarketDepth(Level2)  from the TWS top menu. A window should pop up showing market depth on both bid and ask, multiple levels. Do you see it? If not, you have some issue with the data subscription.


--

Ben

unread,
Aug 14, 2014, 2:01:51 PM8/14/14
to jbook...@googlegroups.com
I can see the market depth level 2 data for MSFT in TWS, similar to ES. Not sure how to proceed?

Eugene Kononov

unread,
Aug 14, 2014, 2:08:07 PM8/14/14
to JBookTrader
Please post your code and EventReport.


Ben

unread,
Aug 14, 2014, 2:17:17 PM8/14/14
to jbook...@googlegroups.com
I was just away from the computer. I will post the code and eventreport when I am back. Thanks for being willing to help, Eugene!

Eugene Kononov

unread,
Aug 14, 2014, 3:15:36 PM8/14/14
to JBookTrader
Ben, when you return, please try one more thing:
Contract contract = ContractFactory.makeStockContract("MSFT", "SMART", "USD");

I don't have the NasdaqTotalView subscription (because I only trade futures), so I can't verify, but I think that will work for you.


Ben

unread,
Aug 14, 2014, 9:57:00 PM8/14/14
to jbook...@googlegroups.com
Hi Eugene,

The code I am using for TSLA is as below:

public abstract class StrategyTSLA extends Strategy {
    protected StrategyTSLA(StrategyParams optimizationParams) throws JBookTraderException {
        super(optimizationParams);
        // Specify the contract to trade
        Contract contract = ContractFactory.makeStockContract("TSLA", "SMART","USD");
        // Define trading schedule
        TradingSchedule tradingSchedule = new TradingSchedule("09:30", "16:30", "America/New_York");
        int multiplier = 100;// contract multiplier
        double bidAskSpread = 0.01; // prevalent spread between best bid and best ask
        Commission commission = CommissionFactory.getBundledNorthAmericaStockCommission();
        setStrategy(contract, tradingSchedule, multiplier, commission, bidAskSpread);
    }
}

Following is what I got from EventReport (please note the error message Deep market data is not supported for this combination of security type/exchange):

08/14/1420:47:39.286JBookTraderMonitoring server started
08/14/1420:47:39.287Sample_TSLAStrategy started. Trading schedule: 09:30 to 16:30 (America/New_York)
08/14/1420:47:39.287JBookTraderRequested contract details for instrument TSLA-USD-SMART-STK
08/14/1420:47:39.288JBookTraderRequested book data for instrument TSLA-USD-SMART-STK
08/14/1420:47:39.288JBookTraderRequested market data for instrument TSLA-USD-SMART-STK
08/14/1420:47:39.327IB APIContract details:
ID: 4
Trading class: NMS
Exchanges: SMART,ISE,CHX,ARCA,ISLAND,IBSX,DRCTEDGE,BEX,BATS,EDGEA,LAVA,CSFBALGO,JEFFALGO,BYX,IEX,PSX
Long name: TESLA MOTORS INC
Market name: NMS

Minimum tick: 0.01
Contract month: null
Time zone id: EST5EDT
Trading hours: 20140814:0400-2000;20140815:0400-2000
Liquid hours: 20140814:0930-1600;20140815:0930-1600
08/14/1420:47:39.409IB API10092: Deep market data is not supported for this combination of security type/exchange (for id 4)
08/14/1420:47:40.390JBookTraderorg.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:465 at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1401) at org.apache.commons.mail.Email.send(Email.java:1428) at com.jbooktrader.platform.email.Notifier.send(Notifier.java:61) at com.jbooktrader.platform.email.Notifier.send(Notifier.java:41) at com.jbooktrader.platform.trader.Trader.error(Trader.java:212) at com.ib.client.EClientSocket.error(EClientSocket.java:1890) at com.ib.client.EReader.processMsg(EReader.java:331) at com.ib.client.EReader.run(EReader.java:69) Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 z4sm503580igm.2 - gsmtp at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826) at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685) at javax.mail.Service.connect(Service.java:317) at javax.mail.Service.connect(Service.java:176) at javax.mail.Service.connect(Service.java:125) at javax.mail.Transport.send0(Transport.java:194) at javax.mail.Transport.send(Transport.java:124) at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1391) ... 7 more

When using  Contract contract = ContractFactory.makeStockContract("TSLA", "ISLAND","USD");
I got the EventReport as below (no error message but still not able to see the deep data in JBT):

08/14/1420:53:43.299JBookTraderMonitoring server started
08/14/1420:53:43.300Sample_TSLAStrategy started. Trading schedule: 09:30 to 16:30 (America/New_York)
08/14/1420:53:43.301JBookTraderRequested contract details for instrument TSLA-USD-ISLAND-STK
08/14/1420:53:43.301JBookTraderRequested book data for instrument TSLA-USD-ISLAND-STK
08/14/1420:53:43.302JBookTraderRequested market data for instrument TSLA-USD-ISLAND-STK
08/14/1420:53:41.337IB APIContract details:
ID: 4
Trading class: NMS
Exchanges: SMART,ISE,CHX,ARCA,ISLAND,IBSX,DRCTEDGE,BEX,BATS,EDGEA,LAVA,CSFBALGO,JEFFALGO,BYX,IEX,PSX
Long name: TESLA MOTORS INC
Market name: NMS

Minimum tick: 0.01
Contract month: null
Time zone id: EST5EDT
Trading hours: 20140814:0400-2000;20140815:0400-2000
Liquid hours: 20140814:0930-1600;20140815:0930-1600

Eugene Kononov

unread,
Aug 14, 2014, 10:41:55 PM8/14/14
to JBookTrader
1. The contract multiplier should be set to 1 for stocks (it's only applicable to futures)

2. The EmailException is thrown because you have not configured the email user name and password. You can simply turn off the email notification service from preferences.

3. In your second try, the error was swallowed. To enable the error reporting, replace this:
   // 200: bad contract
            if (errorCode == 200) {
                traderAssistant.volumeResponse(id, -1);
            }
with this
   // 200: bad contract
            if (errorCode == 200) {
                eventReport.report(JBookTrader.APP_NAME, errorMsg);
                traderAssistant.volumeResponse(id, -1);
            }

4.  How does your market data subscription age looks like. Do you have both the "US Securities Bundle" and "Nasdaq TotalView" checked? I've attached mine for reference.

5. I've always used JBT with futures, and it's been a long time since I tested it with stocks, so perhaps I missed something.




marketDataSubscription.png

Ben

unread,
Aug 15, 2014, 12:08:02 AM8/15/14
to jbook...@googlegroups.com


On Thursday, August 14, 2014 9:41:55 PM UTC-5, Eugene Kononov wrote:
1. The contract multiplier should be set to 1 for stocks (it's only applicable to futures)

OK, I will reset it to 1 
2. The EmailException is thrown because you have not configured the email user name and password. You can simply turn off the email notification service from preferences.
Thanks

3. In your second try, the error was swallowed. To enable the error reporting, replace this:
   // 200: bad contract
            if (errorCode == 200) {
                traderAssistant.volumeResponse(id, -1);
            }
with this
   // 200: bad contract
            if (errorCode == 200) {
                eventReport.report(JBookTrader.APP_NAME, errorMsg);
                traderAssistant.volumeResponse(id, -1);
            }
I couldn't find this in JBT 9.0.1, instead in Trader.java I got
            // 200: bad contract
            
            // 309: market depth requested for more than 3 symbols
            boolean isInvalidRequest = (errorCode == 200 || errorCode == 309);
            if (isInvalidRequest) {
            eventReport.report(JBookTrader.APP_NAME, errorMsg); //add one line for error message
                Dispatcher.getInstance().fireModelChanged(Event.Error, "IB reported: " + errorMsg);
            }
With new code, it seems no error message for Contract contract = ContractFactory.makeStockContract("TSLA", "ISLAND","USD");  
The EventReport is same as before and one more line occurred:
08/14/1422:49:22.049
IB API2104: Market data farm connection is OK:usfarm.us
4.  How does your market data subscription age looks like. Do you have both the "US Securities Bundle" and "Nasdaq TotalView" checked? I've attached mine for reference.
Thanks for the reference! I selected both  "US Securities Bundle" and "Nasdaq TotalView" . The only difference between ES and TSLA I see in TWS Market Depth Window is that there is one footnote (additional sources available:ARCA,BEX, and an option for subscribe  ) at the bottom of TSLA window. Maybe this is the key to the issue. Will check with IB tomorrow.

Ben

unread,
Aug 15, 2014, 8:04:49 AM8/15/14
to jbook...@googlegroups.com
I noticed that there is a slight difference of Tading class and Market Name in EventReport for TWTR (NYSE) and TSLA(NASAQ).  I can get access to NYSE, not NASDAQ, market depth data in JBT

08/15/1406:59:03.765Sample_TWTRStrategy started. Trading schedule: 05:00 to 16:30 (America/New_York)
08/15/1406:59:03.765JBookTraderRequested contract details for instrument TWTR-USD-NYSE-STK
08/15/1406:59:03.766JBookTraderRequested book data for instrument TWTR-USD-NYSE-STK
08/15/1406:59:03.767JBookTraderRequested market data for instrument TWTR-USD-NYSE-STK
08/15/1406:59:03.805IB APIContract details:
ID: 5
Trading class: TWTR
Exchanges: SMART,NYSE,ISE,CHX,ARCA,ISLAND,IBSX,DRCTEDGE,BEX,BATS,EDGEA,LAVA,CSFBALGO,JEFFALGO,BYX,IEX,PSX
Long name: TWITTER INC
Market name: TWTR

Minimum tick: 0.01
Contract month: null
Time zone id: EST5EDT
Trading hours: 20140815:0930-1600;20140818:0930-1600
Liquid hours: 20140815:0930-1600;20140818:0930-1600
08/15/1406:59:04.745
IB API2104: Market data farm connection is OK:usfarm.us
08/15/1406:59:22.936
Sample_TSLAStrategy started. Trading schedule: 09:30 to 16:30 (America/New_York)
08/15/1406:59:22.936
JBookTraderRequested contract details for instrument TSLA-USD-ISLAND-STK
08/15/1406:59:22.937
JBookTraderRequested book data for instrument TSLA-USD-ISLAND-STK
08/15/1406:59:22.938
JBookTraderRequested market data for instrument TSLA-USD-ISLAND-STK
08/15/1406:59:22.974IB API
Contract details:
ID: 4
Trading class: NMS
Exchanges: SMART,ISE,CHX,ARCA,ISLAND,IBSX,DRCTEDGE,BEX,BATS,EDGEA,LAVA,CSFBALGO,JEFFALGO,BYX,IEX,PSX
Long name: TESLA MOTORS INC
Market name: NMS
Minimum tick: 0.01
Contract month: null
Time zone id: EST5EDT
Trading hours: 20140815:0400-2000;20140818:0400-2000
Liquid hours: 20140815:0930-1600;20140818:0930-1600
Reply all
Reply to author
Forward
0 new messages