Earnings Calendar Streaming

The Trading Economics API streaming endpoint can be used to receive live earnings calendar data utilizing a persistent web socket connection. Streaming data from the API consists of making an authorization request and leaving the socket open to continually receive data. You can authorize using your API client credentials (key/secret). Then you will be able to subscribe to our streaming channel.

Get live earnings

import tradingeconomics as te
import json
te.login('you_private_key')

def on_message(ws, message):
    print(json.loads(message))

te.subscribe('earnings')
te.run(on_message)

Clone the repository

git clone https://github.com/tradingeconomics/tradingeconomics-js

Access the folder

cd tradingeconomics-js/Examples/stream-nodejs/

Install dependencies

npm install

In app.js file, set-up your client key and secret. Then subscribe to earnings calendar.

Client = new te_client({
    url: 'wss://stream.tradingeconomics.com/',
    key: 'API_CLIENT_KEY', // <--
    secret: 'API_CLIENT_SECRET' // <--
    //reconnect: true
});

Client.subscribe('earnings')
using System.Net.WebSockets;
using System.Text;

try
{
    using (var cws = new ClientWebSocket())
    {
        await cws.ConnectAsync(new Uri($"wss://stream.tradingeconomics.com/?client='your_private_key'"), CancellationToken.None);

        if (cws.State == WebSocketState.Open)
        {
            var buffer = new ArraySegment<byte>(Encoding.UTF8.GetBytes(@"{""topic"": ""subscribe"", ""to"": """ + "earnings" + @""" }"));
            await cws.SendAsync(buffer, WebSocketMessageType.Binary, true, CancellationToken.None);
        }

        await Task.Delay(1024);

        while (cws.State == WebSocketState.Open)
        {
            var buffer = new ArraySegment<byte>(new byte[1024]);
            var result = await cws.ReceiveAsync(buffer, CancellationToken.None);
            if (result.MessageType == WebSocketMessageType.Close)
            {
                await cws.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None);
            }

            Console.WriteLine($"Receiving: {Encoding.UTF8.GetString(buffer.Array, 0, result.Count).Trim()}");
        }
    }
}
catch (Exception e)
{
    Console.WriteLine($"Error with message: {e.Message}");
}
{'event': 'Inflation Rate MoM', 'country': 'United States', 'category': 'Earnings', 'actual': '51.3', 'previous': '50.6', 'date': '2023-04-14T12:30:00', 'fiscalTag': 'FY2023Q1', 'FiscalReference': 'Q1', 'CalendarReference': '2022-12-31', 'importance': 1, 'teforecast': '51.4', 'consensus ': '50.5', 'currency': 'C$', 'symbol': 'IDT:US'}

Response fields

FieldTypeDescriptionExample
eventstringSpecific event name in the earnings calendar“Inflation Rate MoM”
countrystringCountry name“United States”
categorystringCategory of release“Earnings”
actualstringLatest released value“51.3”
previousstringValue for the previous period after the revision (if revision is applicable)“50.6”
datestringRelease time and date in UTC“2023-04-14T12:30:00”
FiscalTagstringFiscal year and quarter“FY2023Q1”
FiscalReferencestringFiscal year and quarter in different format“Q1”
CalendarReferencestringCalendar quarter for the release“2022-12-31”
importancenumber1 = low, 2 = medium, 3 = high1
teforecaststringTE own projections“51.4”
consensusstringConsensus forecast“50.5”
currencystringCurrency of the data“C$”
symbolstringUnique symbol used by Trading Economics“IDT:US”