Realized P&L Summary
RealizedGainsAndLosesSummary
Input Parameters
| Parameter | Type | Description |
|---|---|---|
| account | Account | Account |
Result Return
| Parameter | Type | Description |
|---|---|---|
| IsSuccess | bool | Whether successful |
| Data | *[]RealizedSummary | Returns realized P&L summary list |
| Message | *string | Returns error message when IsSuccess = false |
Realized Summary Fields
| Parameter | Type | Description |
|---|---|---|
| StartDate | *string | Summary Start Date |
| EndDate | *string | Summary End Date |
| BranchNo | *string | Branch Code |
| Account | *string | Account |
| StockNo | *string | Stock Symbol |
| BuySell | BsAction | Buy/Sell Action: BsActionBuy Buy, BsActionSell Sell |
| OrderType | OrderType | Order Type: OrderTypeStock Common, OrderTypeMargin Margin, OrderTypeShort Short Sell, OrderTypeDayTrade Day Trade, OrderTypeSbl SBL |
| FilledQty | *int64 | Filled Quantity |
| FilledAvgPrice | *string | Filled Average Price |
| RealizedProfitAndLoss | *int64 | Realized P&L Amount |
Request Example
package main
import (
"fmt"
"fubon"
)
func main() {
sdk := fubon.NewSDK()
// ... Login, connection, and other initialization steps ...
// Query Realized P&L Summary
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("\nStock: %s\n", *item.StockNo)
fmt.Printf("Period: %s ~ %s\n", *item.StartDate, *item.EndDate)
fmt.Printf("Filled Qty: %d\n", *item.FilledQty)
fmt.Printf("Filled Avg Price: %s\n", *item.FilledAvgPrice)
fmt.Printf("Realized P&L: %d\n", *item.RealizedProfitAndLoss)
totalPnL += *item.RealizedProfitAndLoss
}
fmt.Printf("\nTotal Realized P&L: %d\n", totalPnL)
}
}
Response Example
Result{
IsSuccess: true,
Message: nil,
Data: &[]RealizedSummary{
{
StartDate: "20230801", // Start Date
EndDate: "20230801", // End Date
BranchNo: "6460", // Branch Code
Account: "26", // Account
StockNo: "1101", // Stock Symbol
BuySell: BsActionSell,// Buy/Sell Action
OrderType: OrderTypeStock, // Order Type
FilledQty: 3000, // Filled Quantity
FilledAvgPrice: "35.7", // Filled Avg Price
RealizedProfitAndLoss: 34026, // Realized P&L Amount
},
},
}