Realized P&L Query
RealizedGainsAndLoses
Input Parameters
| Parameter | Type | Description |
|---|---|---|
| account | Account | Account |
Result Return
| Parameter | Type | Description |
|---|---|---|
| IsSuccess | bool | Whether successful |
| Data | *[]Realized | Returns realized P&L list |
| Message | *string | Returns error message when IsSuccess = false |
Realized Data Fields
| Parameter | Type | Description |
|---|---|---|
| Date | *string | Data Date |
| BranchNo | *string | Branch Code |
| Account | *string | Account |
| StockNo | *string | Stock Symbol |
| BuySell | BsAction | Buy/Sell Action: BsActionBuy Buy, BsActionSell Sell |
| FilledQty | *int64 | Filled Quantity |
| FilledPrice | *string | Filled Price |
| OrderType | OrderType | Order Type: OrderTypeStock Common, OrderTypeMargin Margin, OrderTypeShort Short Sell, OrderTypeDayTrade Day Trade, OrderTypeSbl SBL |
| RealizedProfit | *int64 | Realized Profit Amount |
| RealizedLoss | *int64 | Realized Loss Amount |
Request Example
package main
import (
"fmt"
"fubon"
)
func main() {
sdk := fubon.NewSDK()
// ... Login, connection, and other initialization steps ...
// Query Realized P&L Detail
realized, err := sdk.Accounting.RealizedGainsAndLoses(account)
if err != nil {
fmt.Printf("❌ Realized P&L Format/Parser Error: %v\n", err)
return
}
if realized.IsSuccess && realized.Data != nil {
fmt.Printf("✅ Found %d realized records\n", len(*realized.Data))
}
}
Response Example
Result{
IsSuccess: true,
Message: nil,
Data: &[]Realized{
{
Date: "2023/08/16", // Data Date
BranchNo: "6460", // Branch Code
Account: "26", // Account
StockNo: "1101", // Stock Symbol
BuySell: BsActionSell, // Buy/Sell Action
FilledQty: 1000, // Filled Quantity
FilledPrice: "36.5", // Filled Price
OrderType: OrderTypeStock,// Order Type
RealizedProfit: 36339, // Realized Profit Amount
RealizedLoss: 0, // Realized Loss Amount
},
},
}
Notes
- Detail Records: One record per filled transaction.
- Profit/Loss:
RealizedProfitandRealizedLosswill not have values simultaneously. - Fees Included: P&L is net of fees and transaction tax.