# Excel VBA functions

## 引用TCExcelLib

![](https://lh4.googleusercontent.com/m19cZefKxW8yMWDE7Ja1FSx8p8PAFVn3g0-E1aiCAQG9gxsBJCcKxLFUt-BlqoxN-e9xAIGZ_N_a5vqTdBfKIJJVFKFSZS8fJqei-V64wajI_CWQBChaiPKjURmoHQxx5zWsvHYi)

![](https://lh4.googleusercontent.com/PSkG7VL4aE_iaGpFpTHbfVNE3C5HpRYf3I3U8aKLqI2BwLDQfp5WLYSb4I8Yrz4IbNCvf63hpGNLcyHUvPP34uLdnXNQUtw1aKAtY0ee6W_klITJOFn-wuZV3iaUJwOT5TwqDamT)

## Initial TCExcelLib

```java
Public WithEvents m_eventSourceMain As TCExcelLib.TCExcelLibCom

Set m_eventSourceMain = New TCExcelLib.TCExcelLibCom
```

## Connect

连接

{% tabs %}
{% tab title="Request" %}

```csharp
int Connect(string SystemName);
```

| **Parameters** |           |
| -------------- | --------- |
| SystemName     | TCore系统名称 |
| {% endtab %}   |           |

{% tab title="Retrun" %}
大于0为成功，否则失败
{% endtab %}

{% tab title="Description" %}
Connect呼叫成功后，于callback [OnConnectionStatus](/tcore-api/excel-rtd-yu-vba/excellib-callbacks.md#onconnectionstatus)推送目前连线状态。
{% endtab %}
{% endtabs %}

## Logout

断开

```csharp
void Logout(string SystemName);
```

| **Parameters** |           |
| -------------- | --------- |
| SystemName     | TCore系统名称 |

## SendOrder

下单

{% tabs %}
{% tab title="Request" %}

```csharp
int SendOrder(string SystemName, string OrderInfo);
```

| **Parameters** |                                                                                                               |
| -------------- | ------------------------------------------------------------------------------------------------------------- |
| SystemName     | TCore系统名称                                                                                                     |
| OrderInfo      | [OrderInfo](/tcore-api/excel-rtd-yu-vba/excellib-can-shu-yu-hui-fu.md#can-shu-orderinfo-xia-dan-zi-liao)下单资料。 |
| {% endtab %}   |                                                                                                               |

{% tab title="Retrun" %}
成功为1，否则失败
{% endtab %}

{% tab title="Description" %}
SendOrder呼叫成功后，于callback OnExecutionReport推送主推回报。
{% endtab %}
{% endtabs %}

## DeleteOrder

删单

```csharp
void DeleteOrder(string SystemName, string reportID);
```

| **Parameters** |           |
| -------------- | --------- |
| SystemName     | TCore系统名称 |
| reportID       | 回报编号      |

## ReplaceOrder

改单

```csharp
void ReplaceOrder(string SystemName, string ReplaceInfo);
```

| **Parameters** |                                                                                                                   |
| -------------- | ----------------------------------------------------------------------------------------------------------------- |
| SystemName     | TCore系统名称                                                                                                         |
| ReplaceInfo    | [ReplaceInfo](/tcore-api/excel-rtd-yu-vba/excellib-can-shu-yu-hui-fu.md#can-shu-replaceinfo-gai-dan-zi-liao)改单资料。 |

## QueryAllInstrument <a href="#queryallinstrument" id="queryallinstrument"></a>

‌

查询全部合约列表Return

```
string QueryAllInstrumentInfo(string SystemName, string type);
```

| **Parameters** | ​Title                     |
| -------------- | -------------------------- |
| SystemName     | TCore系统名称                  |
| type           | Future or Options or Stock |

‌

## QueryInstrumentInfo <a href="#queryinstrumentinfo" id="queryinstrumentinfo"></a>

‌

查询合约资讯Return

```
string QueryInstrumentInfo(string SystemName, string symbol):
```

| **Parameters** | ​Title    |
| -------------- | --------- |
| SystemName     | TCore系统名称 |
| symbol         | 合约代码      |


---

# 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://algomaster.gitbook.io/tcore-api/excel-rtd-yu-vba/excel-vba-functions.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.
