Skip to main content

Realized P&L Query

RealizedGainsAndLoses

Input Parameters

ParameterTypeDescription
accountAccountAccount

Result Return

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

Realized Data Fields

ParameterTypeDescription
Date*stringData Date
BranchNo*stringBranch Code
Account*stringAccount
StockNo*stringStock Symbol
BuySellBsActionBuy/Sell Action: BsActionBuy Buy, BsActionSell Sell
FilledQty*int64Filled Quantity
FilledPrice*stringFilled Price
OrderTypeOrderTypeOrder Type: OrderTypeStock Common, OrderTypeMargin Margin, OrderTypeShort Short Sell, OrderTypeDayTrade Day Trade, OrderTypeSbl SBL
RealizedProfit*int64Realized Profit Amount
RealizedLoss*int64Realized 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

  1. Detail Records: One record per filled transaction.
  2. Profit/Loss: RealizedProfit and RealizedLoss will not have values simultaneously.
  3. Fees Included: P&L is net of fees and transaction tax.