已實現損益彙總
RealizedGainsAndLosesSummary
輸入參數
| 參數 | 類別 | 說明 |
|---|---|---|
| account | Account | 帳號 |
Result 回傳
| 參數 | 類別 | 說明 |
|---|---|---|
| IsSuccess | bool | 是否成功 |
| Data | *[]RealizedSummary | 回傳已實現損益彙總列表 |
| Message | *string | 當 IsSuccess = false 回傳錯誤訊息 |
已實現彙總 RealizedSummary 欄位
| 參數 | 類別 | 說明 |
|---|---|---|
| StartDate | *string | 彙總起始日 |
| EndDate | *string | 彙總截止日 |
| BranchNo | *string | 分公司代號 |
| Account | *string | 帳號 |
| StockNo | *string | 股票代號 |
| BuySell | BsAction | 買賣別 : BsActionBuy 買 、 BsActionSell 賣 |
| OrderType | OrderType | 委託單類型 : OrderTypeStock 現股 、 OrderTypeMargin 融資 、 OrderTypeShort 融券 、 OrderTypeDayTrade 現股當沖、OrderTypeSbl 借券 |
| FilledQty | *int64 | 成交股數 |
| FilledAvgPrice | *string | 成交均價 |
| RealizedProfitAndLoss | *int64 | 已實現損益金額 |
請求範例
package main
import (
"fmt"
"fubon"
)
func main() {
sdk := fubon.NewSDK()
// ... 登入、連線等初始化步驟 ...
// 查詢已實現損益彙總
realizedSum, err := sdk.Accounting.RealizedGainsAndLosesSummary(account)
if err != nil {
fmt.Printf("❌ Realized P&L Summary Format Parser error: %v\n", err)
return
}
if realizedSum.IsSuccess && realizedSum.Data != nil {
fmt.Printf("✅ Found %d realized summaries\n", len(*realizedSum.Data))
totalPnL := int64(0)
for _, item := range *realizedSum.Data {
fmt.Printf("\n股票: %s\n", *item.StockNo)
fmt.Printf("期間: %s ~ %s\n", *item.StartDate, *item.EndDate)
fmt.Printf("成交股數: %d\n", *item.FilledQty)
fmt.Printf("成交均價: %s\n", *item.FilledAvgPrice)
fmt.Printf("已實現損益: %d\n", *item.RealizedProfitAndLoss)
totalPnL += *item.RealizedProfitAndLoss
}
fmt.Printf("\n總已實現損益: %d\n", totalPnL)
}
}
回傳範例
Result{
IsSuccess: true,
Message: nil,
Data: &[]RealizedSummary{
{
StartDate: "20230801", // 起始日期
EndDate: "20230801", // 截止日期
BranchNo: "6460", // 分公司代號
Account: "26", // 帳號
StockNo: "1101", // 股票代號
BuySell: BsActionSell,// 買賣別
OrderType: OrderTypeStock, // 委託單類型
FilledQty: 3000, // 成交股數
FilledAvgPrice: "35.7", // 成交均價
RealizedProfitAndLoss: 34026, // 已實現損益金額
},
},
}