庫存查詢
Inventories
輸入參數
| 參數 | 類別 | 說明 |
|---|---|---|
| account | Account | 帳號 |
Result 回傳
| 參數 | 類別 | 說明 |
|---|---|---|
| IsSuccess | bool | 是否成功 |
| Data | *[]Inventory | 回傳庫存資訊列表 |
| Message | *string | 當 IsSuccess = false 回傳錯誤訊息 |
庫存資訊 Inventory 欄位
Return type : Object
| 參數 | 類別 | 說明 |
|---|---|---|
| Date | *string | 交易日期 |
| Account | *string | 帳號 |
| BranchNo | *string | 分公司代號 |
| StockNo | *string | 股票代號 |
| OrderType | OrderType | 委託單類型 : OrderTypeStock 現股 、 OrderTypeMargin 融資 、 OrderTypeShort 融券 、 OrderTypeDayTrade 現股當沖、OrderTypeSbl 借券 |
| LastdayQty | *int64 | 昨日庫存餘額 |
| BuyQty | *int64 | 今日委買股數 |
| BuyFilledQty | *int64 | 今日買進成交股數 |
| BuyValue | *int64 | 買進價金 |
| TodayQty | *int64 | 今日庫存餘額 |
| TradableQty | *int64 | 可委託股數 |
| SellQty | *int64 | 今日委賣股數 |
| SellFilledQty | *int64 | 今日賣出成交股數 |
| SellValue | *int64 | 賣出價金 |
| Odd | *InventoryOdd | 零股庫存資訊 |
| >> LastdayQty | *int64 | 昨日庫存餘額 |
| >> BuyQty | *int64 | 今日委買股數 |
| >> BuyFilledQty | *int64 | 今日買進成交股數 |
| >> BuyValue | *int64 | 買進價金 |
| >> TodayQty | *int64 | 今日庫存餘額 |
| >> TradableQty | *int64 | 可委託股數 |
| >> SellQty | *int64 | 今日委賣股數 |
| >> SellFilledQty | *int64 | 今日賣出成交股數 |
| >> SellValue | *int64 | 賣出價金 |
請求範例
package main
import (
"fmt"
"fubon"
)
func main() {
// 初始化 SDK 並登入
sdk := fubon.NewSDK()
// ... 登入、連線等初始化步驟 ...
// 查詢庫存
inventories, err := sdk.Accounting.Inventories(account)
// 錯誤處理
if err != nil {
fmt.Printf("❌ Inventories Error: %v (Type: %T)\n", err, err)
return
}
// 檢查是否成功
if !inventories.IsSuccess {
message := "No message"
if inventories.Message != nil {
message = *inventories.Message
}
fmt.Printf("Inventories query failed. Message: %s\n", message)
return
}
// 輸出庫存列表
if inventories.Data != nil && len(*inventories.Data) > 0 {
fmt.Printf("✅ Found %d inventory items\n", len(*inventories.Data))
for i, inv := range *inventories.Data {
fmt.Printf("\n=== Inventory %d ===\n", i+1)
fmt.Printf("StockNo: %s\n", *inv.StockNo)
fmt.Printf("OrderType: %v\n", inv.OrderType)
fmt.Printf("昨日庫存: %d\n", *inv.LastdayQty)
fmt.Printf("今日庫存: %d\n", *inv.TodayQty)
fmt.Printf("可委託量: %d\n", *inv.TradableQty)
fmt.Printf("今日買進: %d (成交: %d)\n", *inv.BuyQty, *inv.BuyFilledQty)
fmt.Printf("今日賣出: %d (成交: %d)\n", *inv.SellQty, *inv.SellFilledQty)
// 零股資訊
if inv.Odd != nil {
fmt.Printf("\n 零股庫存:\n")
fmt.Printf(" 今日零股: %d\n", *inv.Odd.TodayQty)
fmt.Printf(" 可委託零股: %d\n", *inv.Odd.TradableQty)
}
}
} else {
fmt.Println("Inventories query succeeded but no data returned.")
}
}
回傳範例
// Inventories 回傳結構
Result{
IsSuccess: true,
Message: nil,
Data: &[]Inventory{
{
Date: "2023/10/13", // 交易日期
Account: "26", // 帳號
BranchNo: "6460", // 分公司代號
StockNo: "1101", // 股票代號
OrderType: OrderTypeStock, // 委託單類型
LastdayQty: 2000, // 昨日庫存餘額
BuyQty: 0, // 今日委買股數
BuyFilledQty: 0, // 今日買進成交股數
BuyValue: 0, // 買進價金
TodayQty: 2000, // 今日庫存餘額
TradableQty: 2000, // 可委託股數
SellQty: 0, // 今日委賣股數
SellFilledQty: 0, // 今日賣出成交股數
SellValue: 0, // 賣出價金
Odd: &InventoryOdd{ // 零股庫存
LastdayQty: 0,
BuyQty: 0,
BuyFilledQty: 0,
BuyValue: 0,
TodayQty: 0,
TradableQty: 0,
SellQty: 0,
SellFilledQty: 0,
SellValue: 0,
},
},
// ... 更多庫存
},
}