undefined

News

API news requires news subscriptions that are specific to the API; most news services in TWS are not also available in the API. Beginning in TWS v966, three API news services are enabled in accounts by default and available from the API. They are:

  • Briefing.com General Market Columns (BRFG)
  • Briefing.com Analyst Actions (BRFUPDN)
  • Dow Jones Newsletters (DJNL) There are also four additional news services available with all TWS versions which require API-specific subscriptions to first be made in Account Management. They have different data fees than the subscription for the same news in TWS-only. As with all subscriptions, they only apply to the specific TWS username under which they were made:
  • Briefing Trader (BRF)
  • Benzinga Pro (BZ)
  • Fly on the Wall (FLY)
  • Midnight Trader (MT) *not currently available from the API The API functions which handle news are able to query available news provides, subscribe to news in real time to receive headlines as they are released, request specific news articles, and return a historical list of news stories that are cached in the system.

Checking Subscribed News Sources

Adding or removing API news subscriptions from an account is accomplished through Account Management. From the API, currently subscribed news sources can be retrieved using the function LYNXApi.EClient.reqNewsProviders . Note this function is only available starting in API v973.02.

** Python **

self.reqNewsProviders()

** Java **

client.reqNewsProviders();

A list of available subscribed news sources is returned to the function LYNXApi.EWrapper.newsProviders

** Python **

def newsProviders(self, newsProviders:     
 ListOfNewsProviders):print("NewsProviders: ")
    for provider in newsProviders: 
        print("NewsProvider.", provider)

** Java **

@Override
public void newsProviders(NewsProvider[] newsProviders) {
    for (NewsProvider np : newsProviders) {
        System.out.print("News Provider. ProviderCode: " + np.providerCode() + ", ProviderName: " + np.providerName() + "\n");
    }
    System.out.println();
}

Contract Specific News

There are two ways to subscribe to real time news headlines through the API. You can request Contract specific News or BroadTape News. See also BroadTape News List

[!WARNING] In order to obtain news feeds via the TWS API you need to acquire the relevant API-specific subscriptions via your Account Management.

When invoking LYNXApi.EClient.reqMktData , for a specific LYNXApi.Contract you will follow the same format convention as any other Basic Contracts. The News Source is identified by the genericTickList.

[!NOTE] The error message "invalid tick type" will be returned if the username has not added the appropriate API news subscription.

** Python **

# Without the API news subscription this will generate an "invalid tick type" error

self.reqMktData(1005, ContractSamples.USStockAtSmart(), "mdoff,292:BRFG", False, False, [])

self.reqMktData(1006, ContractSamples.USStockAtSmart(), "mdoff,292:BRFG+DJNL", False, False, [])

self.reqMktData(1007, ContractSamples.USStockAtSmart(), "mdoff,292:BRFUPDN", False, False, [])

self.reqMktData(1008, ContractSamples.USStockAtSmart(), "mdoff,292:DJ-RT", False, False, [])

** Java **

// Without the API news subscription this will generate an "invalid tick type" error
client.reqMktData(1005, ContractSamples.USStock(), "mdoff,292:BZ", false, false, null);
client.reqMktData(1006, ContractSamples.USStock(), "mdoff,292:BT", false, false, null);
client.reqMktData(1007, ContractSamples.USStock(), "mdoff,292:FLY", false, false, null);
client.reqMktData(1008, ContractSamples.USStock(), "mdoff,292:MT", false, false, null);

BroadTape News

For BroadTape News you specify the LYNXApi.Contract for the specific news source. This is uniquely identified by the symbol and exchange. The symbol of an instrument can easily be obtained via the LYNXApi.EClientSocket.reqContractDetails request.

Examples of news contracts

Briefing Trader

** Python **

contract = Contract()
contract.symbol  = "BRFG:BRFG_ALL"
contract.secType = "NEWS"
contract.exchange = "BRFG"

** Java **

Contract contract = new Contract();
contract.symbol("BRF:BRF_ALL"); //BroadTape All News
contract.secType("NEWS");
contract.exchange("BRF"); //Briefing Trader

Benzinga Pro

** Python **

contract = Contract()
contract.symbol = "DJNL:DJNL_ALL"
contract.secType = "NEWS"
contract.exchange = "DJNL"

** Java **

Contract contract = new Contract();
contract.symbol("BZ:BZ_ALL"); //BroadTape All News
contract.secType("NEWS");
contract.exchange("BZ"); //Benzinga Pro

Fly on the Wall

** Python **

contract = Contract()
contract.symbol  = "DJTOP:ASIAPAC"
contract.secType = "NEWS"
contract.exchange = "DJTOP"

** Java **

Contract contract = new Contract();
contract.symbol("FLY:FLY_ALL"); //BroadTape All News
contract.secType("NEWS");
contract.exchange("FLY"); //Fly on the Wall

Midnight Trader

** Python **

contract = Contract()
contract.symbol = "BRFUPDN:BRF_ALL"
contract.secType = "NEWS"
contract.exchange = "BRFUPDN"

** Java **

Contract contract = new Contract();
contract.symbol("MT:MT_ALL"); //BroadTape All News
contract.secType("NEWS");
contract.exchange("MT"); //Midnight Trader

Then you can invoke LYNXApi.EClient.reqMktData for the broad tape news feed.

** Python **

self.reqMktData(1009, ContractSamples.BRFGbroadtapeNewsFeed(), "mdoff,292", False, False, [])

self.reqMktData(1010, ContractSamples.DJNLbroadtapeNewsFeed(), "mdoff,292", False, False, [])

self.reqMktData(1011, ContractSamples.DJTOPbroadtapeNewsFeed(), "mdoff,292", False, False, [])

self.reqMktData(1012, ContractSamples.BRFUPDNbroadtapeNewsFeed(), "mdoff,292", False, False, [])

** Java **

client.reqMktData(1009, ContractSamples.BTbroadtapeNewsFeed(), "mdoff,292", false, false, null);
client.reqMktData(1010, ContractSamples.BZbroadtapeNewsFeed(), "mdoff,292", false, false, null);
client.reqMktData(1011, ContractSamples.FLYbroadtapeNewsFeed(), "mdoff,292", false, false, null);
client.reqMktData(1012, ContractSamples.MTbroadtapeNewsFeed(), "mdoff,292", false, false, null);

[!WARNING] For Briefing Trader live head lines via the API is only offered on a case-by-case basis directly from Briefing.com offers Briefing Trader subscribers access to the subscription live head lines via the API. For more information and to submit an API entitlement application, please contact Briefing.com directly at dbeasley@briefing.com.

The resulting news headlines are returned to the function LYNXApi.EWrapper.tickNews with the news headline, timestamp, and article ID. The article ID can be used to retrieve the body of the news article using the function LYNXApi.EClient.reqNewsArticle below.

** Python **

def tickNews(self, tickerId: int, timeStamp: int, providerCode: str,
articleId: str, headline: str, extraData: str):
print("TickNews. TickerId:", tickerId, "TimeStamp:", timeStamp,
"ProviderCode:", providerCode, "ArticleId:", articleId,
"Headline:", headline, "ExtraData:", extraData)

** Java **

@Override
public void tickNews(int tickerId, long timeStamp, String providerCode, String articleId, String headline, String extraData) {
    System.out.println("Tick News. TickerId: " + tickerId + ", TimeStamp: " + timeStamp + ", ProviderCode: " + providerCode + ", ArticleId: " + articleId + ", Headline: " + headline + ", ExtraData: " + extraData + "\n");
}

Historical News Headlines

With the appropriate API news subscription, historical news headlines can be requested from the API using the function LYNXApi.EClient.reqHistoricalNews starting in API v973.02. The resulting headlines are returned to LYNXApi.EWrapper.historicalNews.

** Python **

self.reqHistoricalNews(10003, 8314, "BRFG", "", "", 10, [])

** Java **

client.reqHistoricalNews(10003, 8314, "BZ+FLY", "", "", 10, null);

Requesting News Articles

After requesting news headlines using one of the above functions, the body of a news article can be requested with the article ID returned by invoking the function LYNXApi.EClient.reqNewsArticle starting in API v973.02. The body of the news article is returned to the function LYNXApi.EWrapper.newsArticle.

** Python **

self.reqNewsArticle(10002,"BRFG", "BRFG$04fb9da2", [])

** Java **

client.reqNewsArticle(10002, "BZ", "BZ$04507322", null);