Skip to main content
Version: latest

Authentication

Trading Platform provides trading capabilities. Users can have accounts to trade, manage orders, track positions, monitor their potential profits and losses, and more.

info

Creating broker accounts, handling authentication and authorization processes should be implemented on your backend side. Your backend server should also process users' trades and provide the library with users' data through the Broker API. The library only displays users' trading data and notifies your Broker API implementation about user actions.

You can design the authentication and authorization processes to fit your needs. This article outlines possible approaches and describes how the library handles users logging into their broker accounts.

Authentication approaches

Before accessing the app

One approach is to handle authentication and authorization before users access your app. This ensures that only authenticated users can enter the app and interact with their trading data.

Through the top toolbar button

Another approach is to integrate authentication through a button in the top toolbar of the chart. You can add this button using the createButton or createDropdown methods. Such a button can trigger the authentication process, allowing users to access their trading data once authenticated.

Through Account Manager

The Account Manager is designed to display the trading data of a particular user account. Users can manage multiple accounts and switch between them using the drop-down menu in the Account Manager. Authentication and authorization can be implemented when users select an account from the drop-down menu, ensuring that each selected account is properly authenticated before data access is granted.

Drop-down menu for selecting multiple accounts

How the library handles login

On startup, the library calls accountsMetainfo to get the information about accounts of a particular user. This method should return an array that contains an ID and name for each account.

In general, the user login process looks as follows:

  1. A user logs into their broker account. Note that the library does not provide any login dialogs, you should implement them on your side.
  2. Your backend server prepares the user's data and provides a response to your Broker API implementation with updated information.
  3. Your Broker API implementation calls the currentAccountUpdate method to notify the library about changes in account details.
  4. The library calls the accountsMetainfo and currentAccount methods.