Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

How to get news messages?
 Post subject: How to get news messages? Post rating: 0   New post Posted: Tue 17 Nov, 2009, 09:53 

User rating: 0
Joined: Tue 27 Oct, 2009, 09:05
Posts: 10
Hello. Does anybody know how to get news messages? I'm using the following code,but no one news message comes in:

DateTime dt = DateTime.UtcNow;//current time
java.util.Date d = new java.util.Date(dt.Year - 1900, dt.Month - 1, dt.Day, dt.Hour, dt.Minute, dt.Second);

NewsFilter nf = new NewsFilter();
nf.setFrom(d);
nf.setTimeFrame(NewsFilter.TimeFrame.TODAY);
FClient.addNewsFilter(nf);

When I want to request today news and subscribe for real-time news should I use two filters (TODAY+ONLINE)? How can I specify keywords, symbols for searching news (the latest api 2.4.2 isn't allowed to create a new filter from the custom INewsFilter implementation)?


 
 Post subject: Re: How to get news messages? Post rating: 0   New post Posted: Thu 19 Nov, 2009, 16:01 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Thank you for the question. We have found a bug in the latest API. Fix will be available in a next release.
Quote:
When I want to request today news and subscribe for real-time news should I use two filters (TODAY+ONLINE)? How can I specify keywords, symbols for searching news?

No, just one. Please consider this example:
      NewsFilter filter = new NewsFilter();        
      filter.setTimeFrame(NewsFilter.TimeFrame.TODAY);
      
      //set keywords
      Set<String> keywords = filter.getKeywords();
      keywords.add("MARKET TALK");
       
      client.addNewsFilter(filter);
      LOGGER.info("Subscribed : " + filter);

When you are subscribing for some specific historical messages, after you get them, the newest live messages will keep coming. So you don't need to create any additional filter.


 
 Post subject: Re: How to get news messages? Post rating: 0   New post Posted: Fri 20 Nov, 2009, 09:43 

User rating: 0
Joined: Tue 27 Oct, 2009, 09:05
Posts: 10
Thank you for reply. I'll try again after new release.


 
 Post subject: Re: How to get news messages? Post rating: 0   New post Posted: Wed 05 May, 2010, 15:22 

User rating: 0
Joined: Tue 27 Oct, 2009, 09:05
Posts: 10
Hello. I'm starting to use 2.6.1 but I see the same problem: I cannot get any news/calendar messgae (I expect they in onMessage(IMessage im) function) using code that was posted above. Could you post a simple workable example?


 
 Post subject: Re: How to get news messages? Post rating: 0   New post Posted: Tue 11 May, 2010, 09:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
previously posted code snippet need to be added in the main class main function. Consider please this:
      
                      . . . 
        LOGGER.info("Connecting...");
        //connect to the server using jnlp, user name and password
        client.connect(jnlpUrl, userName, password);

        //wait for it to connect
        int i = 10; //wait max ten seconds
        while (i > 0 && !client.isConnected()) {
            Thread.sleep(1000);
            i--;
        }
        if (!client.isConnected()) {
            LOGGER.error("Failed to connect Dukascopy servers");
            System.exit(1);
        }

        //subscribe to the instruments
        Set<Instrument> instruments = new HashSet<Instrument>();
        instruments.add(Instrument.EURUSD);
        LOGGER.info("Subscribing instruments...");
        client.setSubscribedInstruments(instruments);

        //=======================================
        NewsFilter filter = new NewsFilter();
        filter.setTimeFrame(NewsFilter.TimeFrame.TODAY);
        
        Set<String> keywords = filter.getKeywords();
        keywords.add("MARKET TALK");
      
        client.addNewsFilter(filter);
        LOGGER.info("Subscribed : " + filter);
        //=======================================

        //start the strategy
        LOGGER.info("Starting strategy");
        client.startStrategy(new NewsMessageStrategy());
        //now it's running
    }


 
 Post subject: Re: How to get news messages? Post rating: 0   New post Posted: Wed 12 May, 2010, 08:23 

User rating: 0
Joined: Tue 27 Oct, 2009, 09:05
Posts: 10
Thanks!


 
 Post subject: Re: How to get news messages? Post rating: 0   New post Posted: Mon 14 Mar, 2011, 23:02 

User rating: -
I added this code to the main class. And what should I do next to receive news? Is there any events that fires when news comes?
Can you provide code sample for receiving and logging values from this list? https://www.dukascopy.com/swiss/english/ ... ccalendar/


 
 Post subject: Re: How to get news messages? Post rating: 0   New post Posted: Mon 21 Mar, 2011, 14:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please have a look at the following JForex Wiki article: https://www.dukascopy.com/wiki/index.php ... de_on_news


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com