This guide explains the core components at the heart of our TradingView integration solution.
TradingView integration is made possible by a special adapter that is responsible for ensuring steady and smooth communications between TradingView and the cTrader backend.
This adapter has been developed by Spotware and tested in cooperation with TradingView. This documentation does not go into detail on how the adapter functions - its deployment is handled entirely by Spotware, and brokers do not need to adjust any fundamental architecture to ensure that it functions correctly. The deployment of the adapter typically takes between 1-5 working days.
When a user first links a trading account to TradingView, the broker’s client area must request the TradingView adapter to generate a special token required for subsequent communications between the TradingView client and the cTrader backend. The API call for token generation is described below.
This token is later appended to all requests made by the TradingView client to the cTrader backend. These requests are sent whenever a user performs a trading operation or any other operation that can only be completed with participation from the cTrader backend.
The URL of the token generation request is relative to the HOST:PORT
of the deployed TradingView adapter.
HTTP Method | URL |
---|---|
POST |
/generate/token |
Generates and returns a token necessary for communications between the TradingView client and the cTrader backend.
Parameters
No parameters.
Request Body
Key | Required? | Data Type | Description |
---|---|---|---|
userId |
Yes | integer | The unique identifier of the cTID (‘user’) attempting to trade via TradingView. |
brokerNames |
Yes | array<string> | An array containing the names of brokers with which the user has cTrader accounts. If your brokerage has several jurisdictions and/or White Labels (each of which has its own unique brokerName ), you can specify them here so that a user is only able to link account(s) registered under these jurisdictions/White Labels. |
ctidTraderAccountIds |
No | array<integer> | An array containing the identifiers of the trading accounts linked to the specified userId .Specify only the brokerNames array if you want TradingView to receive access to all accounts linked to a certain userId and registered with one or more jurisdiction/White Label. If you specify any account numbers in the ctidTraderAccountId list, the TradingView clients will only receive access to these accounts. |
isVerified |
No | bool | The flag that determines whether the user is verified. Only verified users can leave ratings for brokers inside the TradingView client. |
The structure of the request body allows for establishing granular solutions that grant the TradingView client access to certain accounts registered under specific jurisdictions/White Labels.
Using any suitable solution, you can detect cases in which traders have specifically requested the creation of a ‘cTrader/TradingView’ account in your client area and provide the TradingView client with access only to these accounts.
Note that, owing to the characteristics of the TradingView backend, all accounts linked to TradingView must receive quotes from a single pre-defined price stream (you can decide what this price stream is). This can be managed at the group level in the cTrader backend
If you want to allow users to link both demo and live accounts to TradingView, you must ensure that the accounts of these two types also receive quotes the same price stream despite existing in different environments.
Output
Key | Data Type | Description |
---|---|---|
s |
string | The response status. The value of this key will always be ok for successful requests and error for unsuccessful ones. |
d |
string | The token generated by the TradingView adapter. As shown below, your client area will need to pass this token to the TradingView client after its generation. |
errmsg |
string | The description of the error that has occured when making the request. This key is only returned for unsuccessful requests. |
Request Example
curl -X POST 'http://HOST:PORT/generate/token' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer wrYl_zl_8dLXaZul7GcfpqmDqr7jEnli7or_zct_ETxJnOa4ddaEzftNXbuvNSB-CkZss7TdsTVHRHfqBMq_HqQUxBGCTgWj8loHzi27gJTO1xTqTd9SkJGYP8rYlNQn' -d '{"userId":14601,"brokerNames":["BESTBROKER"],"ctidTraderAccountId":[137780091, 137792301], "isVerified": true}'
Note that the bearer token in the
Authorization
header is provided by Spotware following the deployment of the TradingView adapter.
Response Example
{
"s": "ok",
"d": "aSDf09SFd_asdXC01009mbH_BjMql4980154_asdlDQDq"
}
The figure below summarizes the entire TradingView integration flow. Note that there exist three possible cases in which a user wants to trade via the TradingView client.
The figure accounts for all three cases.
The TradingView integration flow passes through the following stages.