# Interactive Brokers

要将 **ATAS** 连接至 **Interactive Brokers (IB)**，您需要在 [**TWS**](https://www.interactivebrokers.com/en/index.php?f=14099#tws-softwaretarget=)**（Trader Workstation）** 中进行一些设置修改，并下载并安装其最新版本。

***

{% hint style="warning" %}
由于连接机制的特性，**Interactive Brokers 的行情数据可能与其他数据提供商存在显著差异**。在使用此经纪商连接进行分析或交易时，请务必考虑这一点。
{% endhint %}

{% hint style="warning" %}
此外，**Interactive Brokers 的模拟账户不提供股票的实时数据**。
{% endhint %}

{% hint style="danger" %}
该连接仅适用于**西方市场**，无法通过 Interactive Brokers 接收俄罗斯市场的行情数据
{% endhint %}

#### 配置步骤

1. 在 TWS 主菜单中选择 **File → Global Configuration**。
2. 在打开的窗口中选择 **Configuration → API → Settings**。
3. 启用 **Enable ActiveX and Socket Clients（允许 ActiveX 和 Socket 客户端）**。
4. 启用 **Download open orders on connection（连接时下载未完成订单）**。
5. 检查并记下端口号。\
   如果该端口已被其他程序使用，请输入另一个端口号（可使用本地端口范围内的任意数字）。
6. 点击 **OK** 以保存设置并关闭窗口。

<figure><img src="/files/geyTtn2NT8mwBEf0Qbys" alt=""><figcaption></figcaption></figure>

完成上述设置后，即可在 ATAS 中连接 TWS。\
在 ATAS 主界面中执行以下步骤：

1. 打开主菜单 → **Settings（设置） → Connection to DataFeed（行情连接）**。
2. 点击主窗口中的 **Connections（连接）**。

<figure><img src="/files/ZEeurnWM4JgWann0AgaE" alt=""><figcaption></figcaption></figure>

在弹出的窗口中选择 **Add（添加）**，然后在下一个窗口中选择 **Interactive Brokers**，点击 **Next（下一步）**。

<figure><img src="/files/Xq4hLHo8wG0TTzpSZ60Z" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/G8PODM55klDX5dc1mv66" alt=""><figcaption></figcaption></figure>

现在我们进入 **IB 连接设置窗口**：

<figure><img src="/files/Sl3xkyR91YElg6bY6m3n" alt=""><figcaption></figcaption></figure>

1. **Host（主机）** – 输入安装了 TWS 的计算机的 IP 地址和端口号。
   * 如果 TWS 与 ATAS 运行在同一台计算机上，IP 地址应为 **127.0.0.1**。
   * 端口号应与 TWS 设置中的 Socket 端口一致。
2. **Client ID（客户端 ID）** – 为连接程序设置一个大于 0 的唯一编号。\
   如果您仅使用 ATAS 进行连接，可保留默认值 **1**，或输入其他数字。
3. 点击 **Next（下一步）**。

配置完成后，新的连接将在连接源列表中显示为单独一行。

<figure><img src="/files/6gLQEhrOhDnKx2JLTsSo" alt=""><figcaption></figcaption></figure>

点击 **Connect（连接）** 以建立连接。

连接配置完成后，将以单独一行的形式出现在连接窗口中：

<figure><img src="/files/CWopw0oOFtGiUPOngptu" alt=""><figcaption></figcaption></figure>

1. **Add（添加）** – 添加新连接。
2. **Type（类型）** – 连接来源。
3. **Name（名称）** – 您可自行设置的连接名称。
4. **Status（状态）** – 当前连接状态。
5. **Quote Provider（行情提供商）** – 选择行情数据提供商（此连接将作为行情源）。
6. **Auto-Connect（自动连接）** – 若希望平台启动时自动连接，请启用此选项。
7. **Connection settings button（连接设置按钮）**。
8. **Remove connection from the list button（从列表中删除连接按钮）**。
9. **Connect/Disconnect（连接/断开）** – 连接或断开该连接器。

{% hint style="info" %}
您可以通过以下链接了解此窗口的详细设置：[**连接设置窗口**](https://help.atas.net/en/support/solutions/articles/72000612212)。
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://start.atas.net/cn/di-si-bu-zi-zhu-lian-jie-jiao-yi-zhang-hu/qi-huo/interactive-brokers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
