> For the complete documentation index, see [llms.txt](https://ats-doc.gitbook.io/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ats-doc.gitbook.io/v1/basics/exchange-configs.md).

# Exchange Configs

## Top Level Config Parameters

Exchange configurations define how to connect to an exchange for trading. Both back trading (back testing) and live trading modes require a connection to an exchange. For back trading (back testing), the connection is established with a BackTrading exchange object, while for live trading, it connects to a live exchange object, such as the BinanceSpot exchange connector. In the ATS framework, you can create custom exchange classes by extending the BaseExchange class. This allows you to implement your own back-trading or live-trading exchange classes. Any object extending from BaseExchange must include certain parameters while also allowing you to pass custom parameters specific to your exchange. (Please refer to [Sample Trading Configs](/v1/getting-started/sample-trading-configs.md) section to read more about how to upload Exchange Configs via the trading UI or refer to our API guide.)

The following JSON structure outlines the required parameters.

```json
"exchange": {
    "config": {
      "extra": {...},
      "plot_data_max_len": -1,
      "symbol": {
        "base": "BTC",
        "quote": "USDT"
      }
    },
    "namespace": "exchanges:back_trading"
  }
```

<table><thead><tr><th width="379">Property</th><th>Description</th></tr></thead><tbody><tr><td><code>exchange.config</code></td><td>Configuration</td></tr><tr><td><code>exchange.config.extra</code></td><td>Custom parameters passed to the <code>Exchange</code> object</td></tr><tr><td><code>exchange.config.plot_data_max_len</code></td><td>The BaseExchange object tracks data necessary for generating plots, including trade history, price history, wallet balances, and more. This parameter specifies the maximum amount of plotting data to retain in memory, measured in terms of the number of price candles.<br>The value -1 indicates that there is no limit. Otherwise it has to be a positive integer.</td></tr><tr><td><code>exchange.config.symbol</code></td><td>The symbol parameter specifies the trading instrument pair.</td></tr><tr><td><code>exchange.config.symbol.base</code></td><td>This is the first asset in the trading pair and represents the asset being bought or sold. For example, in the trading pair BTC/USDT, BTC (Bitcoin) is the base asset. When trading, you buy or sell units of the base asset.</td></tr><tr><td><code>exchange.config.symbol.quote</code></td><td>This is the second asset in the trading pair and represents the value of the base asset in terms of this currency. Continuing with the BTC/USDT example, USDT (Tether) is the quote asset. It indicates how much of the quote asset is needed to purchase one unit of the base asset. For instance, if BTC/USDT = 30,000, it means 1 BTC is worth 30,000 USDT.</td></tr><tr><td><code>namespace</code></td><td><p>The <code>namespace</code> parameter specifies the location of the exchange class in canonical format. For example, the value <code>"exchanges:back_trading"</code> indicates that the exchange class is located at the following path:</p><p><code>src/exchanges/exchanges/back_trading/exchange.py</code></p><p>It is important to note that each class must have a file named <code>exchange.py</code> containing an <code>Exchange</code> class.</p></td></tr></tbody></table>

***

## Back Trading Specific Configs

In this section we are going discuss about the custom parameters received by the standard BackTrading class. (These parameters are configured at `"exchange.config.extra"` level as mentioned in the previous section.). The standard BackTrading class is specifically designed for Spot Trading, so the parameters are limited accordingly.

Following is a sample config in JSON format.

```json
{
  "data_source": "/Users/isururajakaruna/ATS_V3/trader/data/BTC_USDT_short.csv",
  "fees": {
    "config": {
      "limit": {
              "buy": {
                "base": 0,
                "quote": 0
              },
              "sell": {
                "base": 0,
                "quote": 0
              }
            },
            "market": {
              "buy": {
                "base": 0.1,
                "quote": 0
              },
              "sell": {
                "base": 0,
                "quote": 0.1
              }
            }
    },
    "namespace": "fees:generic"
  },
  "min_trading_size": 0.0001,
  "wallet": {
    "assets": {
      "BTC": 0.344,
      "ETH": 10.1,
      "USDT": 10000
    }
  }
}
```

| Property           | Description                                                                                                                                       |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data_source`      | Location for the back trading dataset (Only CSV format is supported)                                                                              |
| `fees`             | Fee structure and the fee calculation class                                                                                                       |
| `fees.config`      | Fee structure for limit and market orders                                                                                                         |
| `fees.namespace`   | Canonical namespace of the standard fee calculation class (only used in backtrading since the live trading fees are connected by live exchanges). |
| `min_trading_size` | Minimum trading volume expressed in base asset.                                                                                                   |
| `wallet`           | Wallet configuration                                                                                                                              |
| `wallet.assets`    | Initial size of each asset.                                                                                                                       |
