Longbridge Developers
Get Started

Profit Analysis Summary

Get a P&L summary for the account including total asset, total P&L, and yield metrics.

>_ CLI
longbridge profit-analysis
longbridge profit-analysis --start 2026-01-01

Parameters

SDK method parameters.

NameTypeRequiredDescription
start_datestringNOAnalysis start date in YYYY-MM-DD format
end_datestringNOAnalysis end date in YYYY-MM-DD format

Request Example

from longbridge.openapi import PortfolioContext, Config, OAuthBuilder

oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = PortfolioContext(config)

resp = ctx.profit_analysis_summary()
print(resp)
import asyncio
from longbridge.openapi import AsyncPortfolioContext, Config, OAuthBuilder

async def main() -> None:
    oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
    config = Config.from_oauth(oauth)
    ctx = AsyncPortfolioContext.create(config)

    resp = await ctx.profit_analysis_summary()
    print(resp)

if __name__ == "__main__":
    asyncio.run(main())
const { Config, PortfolioContext, OAuth } = require('longbridge')

async function main() {
  const oauth = await OAuth.build('your-client-id', (_, url) => {
    console.log('Open this URL to authorize: ' + url)
  })
  const config = Config.fromOAuth(oauth)
  const ctx = PortfolioContext.new(config)
  const resp = await ctx.profit_analysis_summary()
  console.log(resp)
}
main().catch(console.error)
import com.longbridge.*;
import com.longbridge.portfolio.*;

class Main {
    public static void main(String[] args) throws Exception {
        try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get();
             Config config = Config.fromOAuth(oauth);
             PortfolioContext ctx = PortfolioContext.create(config)) {
            var resp = ctx.getProfitAnalysisSummary().get();
            System.out.println(resp);
        }
    }
}
use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, Config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let oauth = OAuthBuilder::new("your-client-id").build(|url| println!("Open: {url}")).await?;
    let config = Arc::new(Config::from_oauth(oauth));
    let ctx = PortfolioContext::new(config);
    let resp = ctx.profit_analysis_summary().await?;
    println!("{:?}", resp);
    Ok(())
}
#include &lt;iostream&gt;
#include <longbridge.hpp>

using namespace longbridge;
using namespace longbridge::portfolio;

int main() {
    OAuthBuilder("your-client-id").build(
        [](const std::string& url) { std::cout << "Open: " << url << std::endl; },
        [](auto res) {
            if (!res) return;
            Config config = Config::from_oauth(*res);
            PortfolioContext ctx = PortfolioContext::create(config);
            ctx.profit_analysis_summary([](auto resp) {
                if (resp) std::cout << "OK" << std::endl;
            });
        });
    std::cin.get();
}
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/longbridge/openapi-go/config"
	"github.com/longbridge/openapi-go/oauth"
	"github.com/longbridge/openapi-go/portfolio"
)

func main() {
	o := oauth.New("your-client-id").
		OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
	if err := o.Build(context.Background()); err != nil {
		log.Fatal(err)
	}
	conf, err := config.New(config.WithOAuthClient(o))
	if err != nil {
		log.Fatal(err)
	}
	c, err := portfolio.NewFromCfg(conf)
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()
	resp, err := c.ProfitAnalysisSummary(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", resp)
}

Response

Response Example

{
  "code": 0,
  "message": "success",
  "data": {
    "summary": {
      "currency": "USD",
      "sum_profit": "62905.97",
      "sum_profit_rate": "0.6128",
      "invest_amount": "102659.74",
      "current_total_asset": "165565.71",
      "initial_asset_value": "0.00",
      "ending_asset_value": "165565.71",
      "is_traded": true,
      "start_date": "2025-10-17",
      "start_time": "1760659200",
      "end_date": "2026-05-14",
      "end_time": "1778731947",
      "profits": {
        "stock": "66370.84",
        "crypto": "0",
        "fund": null,
        "ipo": null,
        "mmf": null,
        "other": null,
        "cumulative_transaction_amount": "1244920.28"
      }
    },
    "sublist": {
      "start": "2025-10-17",
      "start_date": "2025-10-17",
      "end": "2026-05-14",
      "end_date": "2026-05-14",
      "updated_at": "1778731947",
      "updated_date": "2026-05-14",
      "items": [
        {
          "symbol": "AAPL.US",
          "name": "Apple",
          "market": "US",
          "currency": "USD",
          "profit": "100.00",
          "profit_rate": "0.05",
          "holding_period": "180",
          "clearance_times": 0,
          "is_holding": true,
          "item_type": "Stock",
          "isin": "",
          "security_code": "AAPL",
          "underlying_profit": "100.00",
          "derivatives_profit": "0.00",
          "order_profit": null
        }
      ]
    }
  }
}

Response Status

StatusDescriptionSchema
200SuccessProfitAnalysisResponse
400Bad requestNone

Schemas

ProfitAnalysisResponse

NameTypeRequiredDescription
summaryobjecttrueOverall summary
sublistobjectfalsePer-position breakdown

ProfitAnalysisSummary

NameTypeRequiredDescription
currencystringfalseCurrency
sum_profitstringfalseTotal profit/loss
sum_profit_ratestringfalseTotal profit/loss rate
invest_amountstringfalseTotal invested amount
current_total_assetstringfalseCurrent total asset value
initial_asset_valuestringfalseInitial asset value
ending_asset_valuestringfalseEnding asset value
is_tradedbooleanfalseWhether any trades exist
start_datestringfalsePeriod start date
start_timestringfalsePeriod start timestamp
end_datestringfalsePeriod end date
end_timestringfalsePeriod end timestamp
profitsobjectfalseProfit breakdown by category
profits.stockstringfalseStock profit
profits.cryptostringfalseCrypto profit
profits.fundstringfalseFund profit
profits.ipostringfalseIPO profit
profits.mmfstringfalseMoney market fund profit
profits.otherstringfalseOther profit
profits.cumulative_transaction_amountstringfalseCumulative transaction amount

ProfitAnalysisSublist

NameTypeRequiredDescription
startstringfalsePeriod start
start_datestringfalseStart date
endstringfalsePeriod end
end_datestringfalseEnd date
updated_atstringfalseLast update timestamp
updated_datestringfalseLast update date
itemsobject[]falsePer-position P&L items, see ProfitAnalysisItem

ProfitAnalysisItem

NameTypeRequiredDescription
symbolstringfalseSecurity symbol
namestringfalseSecurity name
marketstringfalseMarket
currencystringfalseCurrency
profitstringfalseProfit/loss
profit_ratestringfalseProfit/loss rate
holding_periodstringfalseHolding period (days)
clearance_timesintegerfalseNumber of clearances
is_holdingbooleanfalseWhether currently holding
item_typestringfalseAsset type: Stock, Fund, Crypto, etc.
isinstringfalseISIN code
security_codestringfalseSecurity code
underlying_profitstringfalseUnderlying stock profit
derivatives_profitstringfalseDerivatives profit
order_profitstringfalseOrder profit