# Compositedge

## Compositedge (XTS) Broker Integration

Compositedge is a Bangalore-based discount broker that provides API access via the XTS (Symphony Fintech) platform. This guide will help you integrate Compositedge with OpenAlgo.

***

### Step 1: Enable TOTP (Two-Factor Authentication)

1. Login to [Compositedge XTS](https://xts.compositedge.com/#!/app).

<figure><img src="https://17901342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBwEhITzgv0O0fEGIIRN%2Fuploads%2F8sNeS8vbN8JqYWDjBVKv%2Fimage.png?alt=media&#x26;token=aaede65f-1990-4c1f-8ff3-32b3f7583934" alt=""><figcaption></figcaption></figure>

Go to `My Profile` from the top-right menu.

<figure><img src="https://17901342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBwEhITzgv0O0fEGIIRN%2Fuploads%2FYIhYxVfs4a8imfm22De4%2Fimage.png?alt=media&#x26;token=4841f911-fae9-48e4-914e-5b465f7e8120" alt=""><figcaption></figcaption></figure>

Scan the **QR Code** shown using Google Authenticator.

<figure><img src="https://17901342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBwEhITzgv0O0fEGIIRN%2Fuploads%2FbZ7w2sg576g7FTEtRuYn%2Fimage.png?alt=media&#x26;token=9157f0fd-2ab4-47f5-9460-57f9729c8d64" alt=""><figcaption></figcaption></figure>

Save the **Secret Key** and enable **TOTP**.

> This is required for secure API login during authentication.

***

### Step 2: Create API Applications

Login to [XTS Developer Portal](https://xts.compositedge.com/dashboard#!/login).

Once logged in:

1. Go to `My App` > `Create New Application`

<figure><img src="https://17901342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBwEhITzgv0O0fEGIIRN%2Fuploads%2F9nwrLvACtUDamQsMokhD%2Fimage.png?alt=media&#x26;token=24ad67e2-add7-4c69-bbaf-f39712b71934" alt=""><figcaption></figcaption></figure>

1. Create two separate apps:
   * **Interactive Order API**
   * **Market Data API**

<figure><img src="https://17901342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBwEhITzgv0O0fEGIIRN%2Fuploads%2F3I7O10Ff3C2tAPX1hj6O%2Fimage.png?alt=media&#x26;token=9de37937-9be4-4e95-bb2e-e1109cf4c57f" alt=""><figcaption></figcaption></figure>

#### Details to Fill:

* **App Name**: OpenAlgo
* **App Description**: OpenAlgo
* **Redirect URL(required only for Interactive Order API)**: `http://127.0.0.1:5000/compositedge/callback`
* **Company Name**: OpenAlgo (or your own)
* Choose the correct **API Package** depending on the app (Order or Market Data).

<figure><img src="https://17901342-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBwEhITzgv0O0fEGIIRN%2Fuploads%2FQ69zM07gqrzNWRV0djTy%2Fimage.png?alt=media&#x26;token=6f66d835-869d-462b-af27-5ef1e29d11e4" alt=""><figcaption></figcaption></figure>

Once submitted, wait for approval from the broker. After approval, the status will turn **Active**.

***

### Step 3: Setup Environment Variables

Refer to the `.sample.env` file in your OpenAlgo folder and prepare your `.env` as follows:

```bash
# Broker Configuration
BROKER_API_KEY = 'YOUR_BROKER_ORDER_API_KEY'
BROKER_API_SECRET = 'YOUR_ORDER_API_SECRET'

BROKER_API_KEY_MARKET = 'YOUR_BROKER_MARKET_API_KEY'
BROKER_API_SECRET_MARKET = 'YOUR_BROKER_MARKET_API_SECRET'

REDIRECT_URL = 'http://127.0.0.1:5000/compositedge/callback'
```

Replace the values with actual credentials shown on your developer dashboard once approved.

***

### Step 4: Start OpenAlgo

Once all environment variables are set and your apps are **Active**, you can now start OpenAlgo.

> Ensure you have installed dependencies and set up the broker configuration properly. OpenAlgo will now be able to place orders and fetch market data through Compositedge's XTS API.

***

This completes the integration process for Compositedge broker with OpenAlgo.

Integrating OpenAlgo with Compositedge’s XTS API empowers traders and developers to automate and streamline their trading workflows with precision and speed. By leveraging both order execution and market data APIs, users can build robust trading systems capable of reacting to market conditions in real time. Always ensure secure handling of API credentials, implement proper error handling, and monitor your integration to maintain reliability and compliance.
