Receive alerts in real time

A user with FULL API access can receive alerts in real time.

To receive the alerts, the user needs to be logged in and to connect to our Server-Sent Events endpoint.

GET https://api.tradingpartners.ai/api/v1/alerts

Server send event objects

The SSE connection is fairly simple.
The client connects to the endpoint and receives events produced by the server.

An event is always formatted as so :

Bulk Parameters


event - string
The event type.


data - object
The data

Authorization header

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXN0IjoidG9rZW4iLCJmb3IiOiJ1c2VyIiwid2l0aCI6ImdyYWRlIiwiZnVsbCI6dHJ1ZX0.sWNz-Z0oGGWoSwaVlOGyzCQdYCWJQmKSSFvZIJzchZw

Ping event

event: ping,
data: {"ping":"2024-03-27T20:12:11.614599318Z"}

TradingPartners AI produces 5 types of events :

  • ping: to keep the connection alive
  • working: an alert that has just been detected by the algorithm
  • aborted: an alert that has been invalidated by the algorithm
  • onGoing: an alert that has started
  • closed: closure of an alert

Ping

Ping event is used to keep the connection alive.

Attributes


event - string const:ping
Event ping to keep the connection alive.


data - object
JSON data of ping event

ping - string fmt:date-time
Date of the ping

Ping event

event: ping,
data: {"ping":"2024-03-27T20:12:11.614599318Z"}



Working

working event is used to inform the user that an alert has been detected.

Attributes


event - string const:working
Event working to inform an opportunity might have been detected.


data - object
JSON data of working event

id - number fmt:int64
ID of the alert


durationStrategy - string
Type of strategy used to detect the alert (cf. Preferences)


instrument - string enum
Markets of the alert
  • CRYPTOCURRENCIES
  • FOREX
  • INDICES
  • COMMODITIES
  • FUTURES
  • STOCKS
  • ETFS

ticker - string
Ticker concerned by the alert.


start - number fmt:float64
Starting price of the alert.


target - number fmt:float64
Price aimed by the alert.


stop - number fmt:float64
StopLoss price of the alert.


startedAt - string fmt:date-time
Date of alert detection.


token - string fmt:uuid
ID of the credit used for the user to receive the alert.

Note

The credit will be reimburse if the alert is not a winning one.

working event

event: working
data: {"durationStrategy":"short","id":35443,"instrument":"CRYPTOCURRENCIES","start":69002,"startedAt":"2024-03-27T19:50:11.946Z","stop":68997,"target":69872.4,"ticker":"BTC/USD","token":"1d81fe2a-699c-4a90-b182-b0e0d2ea3968"}



Aborted

aborted event is used to inform the user that an alert has been invalidated.

Attributes


event - string const:aborted
Event aborted to inform the user, the alert has been invalidated.


data - object
JSON data of aborted event

id - number fmt:int64
ID of the alert


token - string fmt:uuid
ID of the credit used for the user to receive the alert.


tokenState - string enum
State of the credit used for the user to receive the alert.
  • REIMBURSED
  • CONSUMED

aborted event

event: aborted
data: {"id":35443,"token":"1d81fe2a-699c-4a90-b182-b0e0d2ea3968","tokenState":"REIMBURSED"}



OnGoing

onGoing event is used to inform the user that an alert has reached its starting price.

Attributes


event - string const:onGoing
Event onGoing to inform the user, the alert has started.


data - object
JSON data of onGoing event

id - number fmt:int64
ID of the alert


token - string fmt:uuid
ID of the credit used for the user to receive the alert.

onGoing event

event: onGoing
data: {"id":35443,"token":"1d81fe2a-699c-4a90-b182-b0e0d2ea3968"}



Closed

closed event is used to inform the user that an alert has been closed.
It either has reached its stopLoss price or the algorithm has detected the alert should close now and keep the present profits.

Attributes


event - string const:closed
Event closed to inform the user, the alert has been closed.


data - object
JSON data of aborted event

id - number fmt:int64
ID of the alert


exit - number fmt:float64
Closing price of the alert.


gain - number fmt:float64
Gain realized by the alert.

Note

A negative gain means that the alert was a losing one.

A positive gain does not mean your credit will be consumed.
It will be only if the gain have reached a certain threshold.


closedAt - string fmt:date-time
Date of alert closure.


token - string fmt:uuid
ID of the credit used for the user to receive the alert.

Note

The credit will be reimburse if the alert is not a winning one.


tokenState - string enum
State of the credit used for the user to receive the alert.
  • REIMBURSED
  • CONSUMED

closed event

event: closed
data: {"id":35443,"exit":69870.4,"gain":868.4,"closedAt":"2024-04-06T12:47:51.327Z", "token":"1d81fe2a-699c-4a90-b182-b0e0d2ea3968","tokenState":"REIMBURSED"}