# How to integrate TradeLocker

This instruction describes how to create a connection, platforms and products that are required for enabling TradeLocker functionalities via the the B2CORE Back Office.

For managing live and demo trading accounts, you need to create one connection to TradeLocker, but configure two separate platforms and products.

{% hint style="warning" %}
After creating user groups in TradeLocker, they aren't automatically available to systems where TradeLocker is integrated. To make them visible, please contact TradeLocker support with a corresponding request.
{% endhint %}

## How to configure a connection to TradeLocker

To configure a connection to TradeLocker in the B2CORE Back Office:

{% stepper %}
{% step %}
Navigate to **System** > **External connections**.
{% endstep %}

{% step %}
Click **+Create** in the upper-right page corner.
{% endstep %}

{% step %}
On the **Create connection** page, fill in the following fields:

* In the **Name** field, enter a name for the connection. The name must be unique.
* In the **Caption** field, enter a caption that will be applied to the connection in the Back Office.
* In the **Provider** dropdown, select **TradeLocker**.
  {% endstep %}

{% step %}
Click **Save** to create the connection.

The **TradeLocker** connection will appear in the list of external connections.
{% endstep %}

{% step %}
Click **Edit** to enter the connection details and complete the following fields:

* In the **API Base URL** field, specify `https://api.tradelocker.com`.
* In the **API Key** field, specify your API key provided by TradeLocker. This key is used to authenticate requests to the API.
* The **Trading Terminals** section displays the URLs of the TradeLocker live and demo terminals. In the B2CORE UI, when clients click the **Trade** button on the account card, they are redirected to the corresponding terminal, enabling them to start trading in one click.
  {% endstep %}

{% step %}
Check the connection status.

If the connection is inactive (**No** is displayed in the **Enabled** field), activate it by setting the **Enabled** dropdown to **Yes**.
{% endstep %}

{% step %}
Click **Save** to apply the changes.
{% endstep %}
{% endstepper %}

## How to create a platform for TradeLocker

To manage live and demo trading accounts, create two separate platforms for TradeLocker in the B2CORE Back Office.

To create a platform for TradeLocker:

{% stepper %}
{% step %}
Navigate to **Products** > **Platforms**.
{% endstep %}

{% step %}
Click **Create** in the upper-right page corner, and then select **TradeLocker** in the dropdown.
{% endstep %}

{% step %}
In the **Create platform** popup, fill in the following fields:

* In the **Name** field, enter a name that you want to use for the platform.
* In the **Caption** field, enter a caption that will be applied to the platform in the Back Office (such as **TradeLocker** or **TradeLocker Demo**).
* In the **Available connection providers** dropdown, select **TradeLocker**.
* In the **Connection** dropdown, select the previously configured [TradeLocker connection](#configure-a-connection-to-tradelocker).
  {% endstep %}

{% step %}
Click **Save** to proceed.
{% endstep %}

{% step %}
On the **Edit platform** page, specify the following settings:

* In the **Short caption** field, you can optionally specify a short platform name.
* If you configure a demo platform for TradeLocker, select **Yes** in the **Demo** dropdown; otherwise, make sure that **No** is selected.
* In the **Status** dropdown, select **Enabled**.
* In the **Settings** section, specify the name of your TradeLocker server in the **Trading Server name** field.
  {% endstep %}

{% step %}
Click **Test connection** to validate the connection settings.

The checkmark displayed on the **Test connection** button indicates that the connection has been configured properly.
{% endstep %}

{% step %}
After the connection settings have been successfully validated, click **Save**.
{% endstep %}
{% endstepper %}

## How to create a product group for TradeLocker

To create a product group for TradeLocker in the B2CORE Back Office:

{% stepper %}
{% step %}
Navigate to **Products** > **Groups**.
{% endstep %}

{% step %}
Click **+Create** in the upper-right page corner.
{% endstep %}

{% step %}
On the **Create group** page, fill in the following fields:

* In the **Caption** field, enter a caption for the product group. This caption will be assigned to the product group in the Back Office and will be visible to clients in the B2CORE UI.
* In the **Description** field, enter a group description.
* In the **Type** dropdown, select **Default**.
  {% endstep %}

{% step %}
Click **Save** to create the product group.
{% endstep %}
{% endstepper %}

## How to create a product for TradeLocker

To manage live and demo trading accounts, create two separate products for TradeLocker in the B2CORE Back Office.

To create a product for TradeLocker:

{% stepper %}
{% step %}
Navigate to **Products** > **Products**.
{% endstep %}

{% step %}
Click the **Create** in the upper-right page corner, and then select:

* **TradeLocker** — if you create a product for managing live accounts
* **TradeLocker Demo** — if you create a product for managing demo accounts
  {% endstep %}

{% step %}
In the **Create product** popup, fill in the following fields:

* In the **Platform Group** dropdown, select the appropriate group existing on your TradeLocker server. TradeLocker accounts created based on this product via B2CORE will be assigned to this group.
* In the **Currency** dropdown, select one or more currencies that you want to enable for the product.
* In the **Name** field, enter a name that you want to use for the product.
* In the **Group** dropdown, select the previously configured [TradeLocker product group](#how-to-create-a-product-group-for-tradelocker).
* In the **Type** dropdown, select:
  * **Trade** — if you create a product for managing live accounts
  * **Demo** — if you create a product for managing demo accounts
    {% endstep %}

{% step %}
Click **Save** to proceed.
{% endstep %}

{% step %}
On the **Edit product** page, specify the following product settings:

* In the **Name** field, you can modify the product name. The name must be unique.
* In the **Caption** field, enter a caption for the product. This caption will be assigned to the product in the Back Office and will be visible to clients in the B2CORE UI.
* Leave the **Leverage** and **Default leverage** fields empty. The leverage parameter isn't applied directly to accounts on the TradeLocker platform. Instead, leverage is configured per instrument within the platform.
* In the **Rights** and **Default account rights** dropdowns, select the required permissions that will be applied to the product (such as `Enabled`, `Visible`, `Trade enabled`, `Transfer deposit`, and `Transfer withdraw`).

  The default rights will be assigned to TradeLocker accounts created automatically when the **Auto creation on login** option is triggered.

  For a list of possible permissions, refer to [Product permissions](https://docs.b2core.b2broker.com/back-office-guide/references/product-permissions).
* In the **Max accounts** field, enter an integer value to define the maximum number of TradeLocker accounts that a client can create for each currency added to the product.

  For example, if `USD` and `EUR` are added as currencies to the product and the **Max accounts** option is set to `1`, the client can create one account in `USD` and one account in `EUR` based on this product.

  * To set no limit on the number of accounts, specify **-1**.
  * To forbid clients to create accounts, specify **0**.
* In the **Mail** dropdown, select **Don't send**. This option is required to ensure that email notifications in B2CORE work correctly using the designated `TradeLockerUserCreated` email template.
* In the **Start amount** field, specify the amount that will be automatically deposited to *demo* TradeLocker accounts upon their creation.
* In the **Min deposit amount (USD)** field, you can optionally specify the minimum deposit, in USD, required to create a TradeLocker account based on this product.
* In the **Auto creation on login** dropdown, select:
  * **Yes** — to automatically create TradeLocker accounts based on the product settings when clients first sign in to the B2CORE UI.
  * **No** — to create TradeLocker accounts based on this product manually.
* In the **Agreement link** field, specify a link to the document to which clients must consent in order to open TradeLocker accounts via the B2CORE UI.
* In the **Link info** field, specify a link to a resource with additional product information, which clients can access when creating TradeLocker accounts via the B2CORE UI.
* On the **Currencies** tab, you can review the currency associated with the product and add more currencies if necessary.
* After configuring the product settings, activate it by selecting **Enabled** in the **Status** dropdown.
  {% endstep %}

{% step %}
Click **Save** to create the product.
{% endstep %}
{% endstepper %}

TradeLocker accounts can now be created based on the product via the Back Office or B2CORE UI. Any changes to product settings will directly impact how the product is displayed and functions for clients in the B2CORE UI.
