# 籌碼函數取值邏輯與使用指南

**摘要：** 台灣期貨交易所每日約 14

後公布「前一交易日」三大法人日盤數據；每日約 07\~07後公布「當日夜盤」三大法人數據。

**重點：** GetChip() 依照你在程式中提供的日期與時間，回傳「當時可取得的最新官方公布資料」。跨週、休市或未開盤時，延用上一個有效交易日（或上一個夜盤）的數據。

### 1) 日盤取值邏輯 <a href="#id-1" id="id-1"></a>

1. 交易所約於 14後公布「前一交易日」三大法人進出。
2. 你在程式帶入的 `日期+時間` 將對應到「當下已公布」的最新日盤資料。

#### 範例

現在 2025/08/02 11

，查詢時間也為 2025/08/02 11。回傳資料就是 2025/08/01 14後公布之數據。

若改在 2025/08/02 15

查詢，回傳資料 = 2025/08/02 於 14後公布之數據。

{% hint style="warning" %}
**注意：** 跨週、前一日休假或未開盤時，系統將延用上一個交易日的數據。
{% endhint %}

### 2) 夜盤取值邏輯 <a href="#id-2" id="id-2"></a>

1. 交易所每日早上約 07\~07公布當日夜盤三大法人。
2. 你在程式帶入的 `日期+時間` 將回傳「該日已公布」之夜盤資料。

#### 範例

查詢區間 2025/05/30 08

\~ 2025/05/31 05的夜盤籌碼，回傳結果對應交易所網站 2025/05/30 07後公布之數據。⚠

{% hint style="warning" %}
**注意：** 跨週、前一交易日未開盤時，延用上個夜盤的公布數據。
{% endhint %}

### 3) 實作範例 <a href="#id-3" id="id-3"></a>

#### 3.1 日盤測試程式

```
textinputs:
    FIELD_DATE(D),
    FIELD_TIME(time_s);

vars:
    SYMBOL_NAME("SPF");

value1 = getchip(SYMBOL_NAME, FIELD_DATE, FIELD_TIME, 3, 1, 2, 1);

plot1(value1, "OB");
```

#### 3.2 夜盤測試程式（期權範例）

```
textinputs:
    SYMBOL_NAME("TXO.C"),
    FIELD_DATE(D),
    FIELD_TIME(time_s);

value1 = Getchip(SYMBOL_NAME, FIELD_DATE, FIELD_TIME, 17, 1, 1, 1);
plot1(value1);
```

### 4) 常見疑問 <a href="#id-4" id="id-4"></a>

1. **Q. 為何回傳日期比我查詢的日期早一天？**
   * A. 因為日盤資料於約 14後才會公布；在此之前查詢會回傳上一個交易日。
2. **Q. 夜盤可否查未平倉？**
   * A. 不支援

***

{% hint style="info" %}
本文僅說明取值邏輯，實際更新時點仍以台灣期貨交易所公布為準。
{% 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://touchance-1.gitbook.io/touchance/touchance-jie-mian-1/faq/multicharts-jia-zhi-han-shu/chou-ma-han-shu-qu-zhi-luo-ji-yu-shi-yong-zhi-nan.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.
