Skip to main content

Realized P&L Summary

RealizedGainsAndLosesSummary

Input Parameters

ParameterTypeDescription
accountAccountAccount

Result Return

ParameterTypeDescription
IsSuccessboolWhether successful
Data*[]RealizedSummaryReturns realized P&L summary list
Message*stringReturns error message when IsSuccess = false

Realized Summary Fields

ParameterTypeDescription
StartDate*stringSummary Start Date
EndDate*stringSummary End Date
BranchNo*stringBranch Code
Account*stringAccount
StockNo*stringStock Symbol
BuySellBsActionBuy/Sell Action: BsActionBuy Buy, BsActionSell Sell
OrderTypeOrderTypeOrder Type: OrderTypeStock Common, OrderTypeMargin Margin, OrderTypeShort Short Sell, OrderTypeDayTrade Day Trade, OrderTypeSbl SBL
FilledQty*int64Filled Quantity
FilledAvgPrice*stringFilled Average Price
RealizedProfitAndLoss*int64Realized 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
},
},
}