> For the complete documentation index, see [llms.txt](https://algomaster.gitbook.io/tcore-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algomaster.gitbook.io/tcore-api/python/tcoreapi_mq.py.md).

# TCore Python API 行情

## quote\_connect

行情连线

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

```python
def quote_connect(self,port):
```

| **Parameters** | 说明                   |
| -------------- | -------------------- |
| port           | 连线port，搜寻 ZMQ log取得。 |
| {% endtab %}   |                      |

{% tab title="Return" %}
回复SessionKey
{% endtab %}
{% endtabs %}

## quote\_logout

行情断线

```python
def quote_logout(self,SessionKey):
```

| **Parameters** | 说明                    |
| -------------- | --------------------- |
| SessionKey     | connect时回传的sessionkey |

## subquote

订阅行情

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

```python
def subquote(self,SessionKey,Param):
```

| **Parameters** | 说明                                                                                              |
| -------------- | ----------------------------------------------------------------------------------------------- |
| SessionKey     | connect时回传的sessionkey                                                                           |
| Param          | [行情订阅参数](/tcore-api/python/can-shu-shuo-ming.md#hang-qing-ding-yue-yu-jie-ding-can-shu)，Json格式。 |
| {% endtab %}   |                                                                                                 |

{% tab title="Description" %}
订阅成功，行情会从先前创建的[行情callback线程处理函数](/tcore-api/python/tcore-python-api-kuai-su-an-zhuang-shuo-ming.md#jian-li-hang-qing-callback-xian-cheng-chu-li-han-shu)，推送回来。并借由message\["DataType"]判断资料类型，做对应的函数处理。
{% endtab %}

{% tab title="Response" %}
行情回复资料为Json格式，\
message\["DataType"]="REALTIME"   [实时行情](/tcore-api/python/can-shu-shuo-ming.md#shi-shi-hang-qing-hui-fu)\
message\["DataType"]="GREEKS"   [Greeks](/tcore-api/python/can-shu-shuo-ming.md#shi-shi-greeks-hui-fu)
{% endtab %}
{% endtabs %}

## unsubquote

解阅行情

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

```python
def unsubquote(self,SessionKey,Param):
```

| **Parameters** | 说明                                                                                              |
| -------------- | ----------------------------------------------------------------------------------------------- |
| SessionKey     | connect时回传的sessionkey                                                                           |
| Param          | [行情解订参数](/tcore-api/python/can-shu-shuo-ming.md#hang-qing-ding-yue-yu-jie-ding-can-shu)，Json格式。 |
| {% endtab %}   |                                                                                                 |
| {% endtabs %}  |                                                                                                 |

## sub\_history

回补历史

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

```python
def sub_history(self,SessionKey,Param):
```

| **Parameters** | 说明                                                                                                |
| -------------- | ------------------------------------------------------------------------------------------------- |
| SessionKey     | connect时回传的sessionkey                                                                             |
| Param          | [回补历史资料参数](/tcore-api/python/can-shu-shuo-ming.md#hang-qing-ding-yue-yu-jie-ding-can-shu)，Json格式。 |
| {% endtab %}   |                                                                                                   |

{% tab title="Description" %}
订阅成功，行情会从先前创建的[行情callback线程处理函数](/tcore-api/python/tcore-python-api-kuai-su-an-zhuang-shuo-ming.md#jian-li-hang-qing-callback-xian-cheng-chu-li-han-shu)，推送回来。并借由判断资料类型message\["DataType"]，做对应的函数处理。

message\["DataType"]="TICKS"   历史ticks\
message\["DataType"]="1K"   历史1K\
message\["DataType"]="DK"   历史日K
{% endtab %}

{% tab title="Response" %}
[回补历史资料](/tcore-api/python/can-shu-shuo-ming.md#hui-bu-li-shi-zi-liao-hui-fu) 为Json格式。
{% endtab %}
{% endtabs %}

## get\_history

分页取得历史资料

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

```python
def get_history(self,SessionKey,Param):
```

| **Parameters** | 说明                                                                                               |
| -------------- | ------------------------------------------------------------------------------------------------ |
| SessionKey     | connect时回传的sessionkey                                                                            |
| Param          | [分页取得历史资料参数](/tcore-api/python/can-shu-shuo-ming.md#fen-ye-qu-de-li-shi-zi-liao-can-shu)，Json格式。 |
| {% endtab %}   |                                                                                                  |

{% tab title="Return" %}
[返回分页历史资料](/tcore-api/python/can-shu-shuo-ming.md#gethistory-fen-ye-li-shi-zi-liao-hui-fu)
{% endtab %}

{% tab title="Description" %}
查询需要带入QryIndex(带空则当作0)，每次最多回50笔，拿最后一笔QryIndex资讯继续往下查询，直到回空代表已无资料。
{% endtab %}
{% endtabs %}

## QueryInstrumentInfo

查询合约

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

```python
def QueryInstrumentInfo(self, SessionKey, symbol):
```

| **Parameters** | 说明                    |
| -------------- | --------------------- |
| SessionKey     | connect时回传的sessionkey |
| symbol         | 合约代码                  |
| {% endtab %}   |                       |

{% tab title="Retrun" %}
[返回合约资讯](/tcore-api/python/can-shu-shuo-ming.md#he-yue-zi-xun-hui-fu)
{% endtab %}
{% endtabs %}

## QueryAllInstrumentInfo

查询全部合约

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

```python
def QueryAllInstrumentInfo(self, SessionKey, type):
```

| **Parameters** | 说明                         |
| -------------- | -------------------------- |
| SessionKey     | connect时回传的sessionkey      |
| type           | Future or Options or Stock |
| {% endtab %}   |                            |
| {% endtabs %}  |                            |

## QuotePong

Pong回复以维持连线

```python
def QuotePong(self, SessionKey):
```
