Workflows
Real-Trade Review
On this page6
A backtest report shows theoretical positions; a real-trade review shows what you actually traded. TradeReview uses actual fill prices, fees, taxes, dividends and deposits/withdrawals to rebuild daily holdings, cash and NAV, computes time-weighted returns that exclude external cash flows, and produces the same FinLab report you get from a backtest.
By the end of this page you will have daily holdings and NAV, a time-weighted return, a FinLab report, and a table of how your actual positions differ from the strategy's targets.
Before you start, you need:
- A broker account connected through
finlab.online; see Live trading for setup. If your broker is not supported, or you want to use an exported fill file, see "Use your own fills" at the end of this page. - A start date for the review. When a broker API cannot return data that far back, the review can only start from the earliest available date.
Review straight from a broker account
Connect the broker account
This example uses Charles Schwab. Taiwan brokers and Binance are supported too; see the table below.
from finlab.online.schwab_account import SchwabAccount
acc = SchwabAccount()Build the review
from finlab.portfolio import TradeReview
review = TradeReview.from_account(acc, start="2026-01-01")from_account does four things:
- Pulls fills from
startto today through the broker API (see the table below). - Rebuilds starting holdings from the broker's current holdings (undoing fills, stock dividends and splits in the window), then reconciles the rebuilt ending holdings with the broker; mismatches are listed in
review.limitations. - Applies dividends: Schwab and Binance report them in the account records; for Taiwan accounts FinLab applies its dividend announcements automatically (cash dividends on the ex-dividend date, stock dividends and ETF splits on the ex-rights / resumption date).
- Values holdings daily at unadjusted close.
Read the limitations first
review.limitations # data limitations of this review: always read themReconciliation mismatches and skipped short-sale or securities-lending fills are listed here. Read them before you trust the numbers that follow.
Read the results
review.summary() # start/end NAV, net inflow, dividends, fees and tax, P&L, TWR
review.daily # daily cash, market value, NAV, flows, return, cumulative P&L
review.holdings # shares held at each close
review.trades # FIFO-matched round trips (with dividends); open lots have no exit_date
review.report.display() # FinLab report: equity curve, metrics, MAE/MFE, tradesCompare with strategy targets
compare uses the actual position at the close of each target date, never later fills. Targets can be share counts or weights:
import pandas as pd
target = pd.DataFrame({"AAPL": [20], "MSFT": [10]}, index=["2026-03-02"])
review.compare(target) # date, stock_id, target, actual, diff (shares)
weights = pd.DataFrame({"AAPL": [0.6], "MSFT": [0.4]}, index=["2026-03-02"])
review.compare(weights, kind="weight") # or compare weightsView the report in Studio and save the ledger separately
review.report is a regular Report. You can upload it with the public review.report.upload(name=...) method and view it in Studio My Strategies. This saves a report, rather than the entire real-trade ledger. The following describes finlab 2.3.4:
| What you need | Data in Python | Studio's native report after upload |
|---|---|---|
| Return curve and performance metrics | review.report | Available |
| FIFO-matched trades | review.trades | At most the last 500 report trades; these are not raw fills |
| Individual fills, fees and taxes | review.fills | No complete fills archive; the trade list does not show per-fill shares, fees or taxes |
| Daily shares held | review.holdings | No daily share-count table; ending holdings are shown as weights |
| Daily cash, NAV and cash flows | review.daily | No complete daily ledger; the return curve cannot replace cash records |
One fill may be split across several FIFO-matched trades, so 500 report trades do not mean 500 fills. Fees and taxes are included in returns according to the review's calculation mode.
Check where an upload will save the report
Uploads may update an existing strategy; inside Studio they target the current strategy even if you supply another name. Existing sharing settings are retained. See Report.upload for parameters, return values, limits on permission verification and a general upload example.
If you require create-only saving, guaranteed privacy, a returned ID and permission verification together, keep the review locally; no public API currently provides that contract.
Keep the complete details
After creating review, save the report and ledger separately on your computer, without uploading:
review.report.to_pickle("trade_review_report.pkl")
review.fills.to_csv("fills.csv", index=False)
review.trades.to_csv("fifo_trades.csv", index=False)
review.daily.to_csv("daily.csv", index_label="date")
review.holdings.to_csv("holdings.csv", index_label="date")to_pickle() saves the Report, without the full TradeReview fills, daily cash or daily share-count tables. To rebuild the review later, also keep the original fills, starting holdings and cash, cash flows, corporate actions and price inputs. Uploading a report does not save these local files in Studio.
Files generated in Studio web: downloads and temporary storage
When you ask the research AI in Studio web for a presentation or a spreadsheet, its Python saves a PowerPoint (.pptx) or Excel (.xlsx) file in the current folder, such as prs.save("report.pptx") or df.to_excel("details.xlsx"). The file then appears under that run's result; select Download to save it to your computer. Cloud Python comes with python-pptx and openpyxl installed.
| Item | Limit |
|---|---|
| Formats | PowerPoint (.pptx), Excel (.xlsx) |
| Size | Up to 5 MB per file; 6 MB and 10 files in all per run |
| Retention | Downloadable for 7 days after it is made, then deleted |
| Who can download | Only the account signed in when it ran; nothing is kept for signed-out visitors |
A file that does not open (an incomplete ZIP structure, for example) or exceeds a limit is not offered; the result says why. Other formats (CSV, JSON, ZIP) have no download path: writing them in Python creates a file in that execution environment, not on your computer. The data catalog's fixed CSV downloads are a separate feature and cannot export files generated by your research.
| Execution environment | Where files are stored and how long they last |
|---|---|
| Local Python on your computer | Written to your chosen local path; you manage retention and backups. The saving example above applies here. |
| Browser Python in Studio web | Written inside the browser execution environment, with no persistence guarantee. Do not rely on retrieving them after a refresh or reopening the page. |
| Studio cloud Python | Temporary files for one execution, discarded when it ends and unavailable to a later execution; only the .pptx and .xlsx files above are also kept for 7 days to download. |
To keep complete original files in other formats, generate and save them with local Python. A Report, Log or text displayed on screen cannot replace the original file bytes.
Compute the byte count and SHA-256 of an actual file
After writing and closing your files, run this in the same Python environment, replacing the example filenames. In cloud Python, include it in the execution that creates the files:
from pathlib import Path
import hashlib
for filename in ("fills.csv", "summary.json", "review.zip"):
raw = Path(filename).read_bytes()
print(filename, len(raw), hashlib.sha256(raw).hexdigest())len(raw) counts bytes, rather than text characters. A CSV's BOM and line endings, JSON encoding, or ZIP packaging can change the bytes and hash. Hash the file directly, without decoding or serializing it again. To compare two copies, compute and compare both the byte count and SHA-256 on each side.
These are checksums you compute yourself; Studio currently supplies no platform checksum for these research files. Printing a byte count or SHA-256 neither creates a download path nor proves that a download completed or that the platform verified file integrity.
How returns are computed: account mode and holdings mode
The review picks one of two modes, depending on what the broker reports:
| Mode | When | NAV | External flows |
|---|---|---|---|
| Account | Broker API has complete deposits/withdrawals (Schwab, Binance), or you pass initial_cash and cash_events | cash + market value | deposits, withdrawals |
| Holdings | Taiwan brokers (the settlement account is a bank account the API cannot see) | market value | buys are invested before the open; sell proceeds and dividends are withdrawn after the close |
Daily return r = (NAV + outflow) / (previous NAV + inflow) - 1, chained into the equity curve. CAGR, Sharpe and drawdown in the report are computed from it and are unaffected by deposits and withdrawals. In account mode, pnl is the NAV change minus net external inflow.
Press deposit and withdraw on the account below, and see which number jumps and which one stays put:
Deposit, withdraw: which number moves, and which one doesn’t?
Mission 1 of 3 Press Deposit $10,000: Plain change 10+ points above Time-weighted
review = TradeReview.from_account(
acc, start="2025-01-02", initial_cash=50_000,
cash_events=pd.DataFrame({
"time": [],
"amount": [],
"type": [],
}),
)
review.summary() Daily return r = (value + outflow) ÷ (yesterday + inflow) − 1
The account holds 8 large caps in equal weights through 2025 (real prices, rebalanced monthly, no fees). Deposits are invested before the open, withdrawals leave after the close; amounts are illustrative.
Brokers without deposit/withdrawal data (the Taiwan brokers) review holdings only. To get a full account NAV for such an account, pass starting cash and cash flows:
import pandas as pd
review = TradeReview.from_account(
acc,
start="2026-01-01",
initial_cash=50_000,
cash_events=pd.DataFrame(
{
"time": ["2026-03-02"],
"amount": [10_000],
"type": ["deposit"],
}
),
)Broker support
| Broker | Fill source | Fees / tax | Closed positions | Dividends | Deposits / withdrawals | Default mode |
|---|---|---|---|---|---|---|
| Schwab (U.S.) | get_transactions | net amount minus gross | yes | broker records | broker records | account |
| Sinopac (Taiwan) | realized P&L + detail, open lot detail | buys from detail; sells derived from realized P&L (combined in fee) | buy legs recovered | FinLab auto | none | holdings |
| Pocket (Taiwan) | realized P&L, open lot detail | none | as Sinopac when the SDK has the detail call; otherwise shares sold in the window are treated as held at start | FinLab auto | none | holdings |
| Fubon (Taiwan) | filled_history (30 days per call, fubon_neo 2.1.1+) | not in API; estimated from fee_ratio and statutory tax | yes | FinLab auto | none | holdings |
| Taishin, formerly Masterlink (Taiwan) | statement account_statment | actual per fill | yes | FinLab auto | none | holdings |
| E.SUN (Taiwan) | get_transactions_by_date (180 days per call) | actual per fill | yes | FinLab auto | none | holdings |
| Binance | myTrades (per symbol) | paid in quote or base asset; BNB-paid fees are not counted | only currently held assets and those passed in symbols= | quote-asset distributions | quote-asset deposits/withdrawals | account |
Limitations that apply to every broker:
- Only long cash and margin positions are reviewed; short-sale and securities-lending fills are skipped and listed in
limitations. Margin interest is not counted. - Fills that only have a date (most Taiwan brokers) are processed buys first, then sells, on the same day, which does not affect end-of-day valuation.
- Corporate actions the broker or FinLab does not supply are not applied automatically; add them to
corporate_actions(columnsstock_id, date, cash, ratio). Taiwan capital reductions and par value changes fall in this group; Taiwan stock dividends are converted with the par value, rounding fractional shares down. - When a broker API cannot return data that far back, the review can only start from the earliest available date.
Use your own fills
For other brokers or exported files, map them to the standard columns and build the review directly. quantity is in shares; fee and tax are the actual amounts of each fill, and missing fee/tax columns count as 0.
import pandas as pd
from finlab.markets.us import USMarket
from finlab.portfolio import TradeReview
fills = pd.DataFrame(
{
"time": ["2026-01-05 09:45", "2026-01-07 10:00"],
"stock_id": ["MSFT", "MSFT"],
"action": ["buy", "sell"],
"quantity": [50, 50], # shares
"price": [480.0, 486.5],
"fee": [0, 0], # actual amount of this fill; missing fee/tax columns count as 0
}
)
market = USMarket()
review = TradeReview(
fills,
market.get_price("close", adj=False),
start="2026-01-05",
initial_holdings={"AAPL": 100},
# Illustrative dividend: cash per share on the ex-date; ratio 2.0 would be a 2-for-1 split
corporate_actions=pd.DataFrame(
{"stock_id": ["AAPL"], "date": ["2026-02-09"], "cash": [0.25], "ratio": [1.0]}
),
market=market,
)For Taiwan fills, finlab.portfolio.trade_review.tw_corporate_actions(stock_ids, start, end) builds the corporate_actions table from FinLab's Taiwan dividend announcements.
Once built, review works exactly like one created from a broker account.
Next steps
- Live trading Connect a broker account, turn a backtest into positions and place orders.
- From research to live trading The full path from strategy idea through validation to deployment.
- Multi-strategy portfolios Run several strategies in one account and place their orders together.
- finlab.portfolio API Full parameters for
TradeReviewand the portfolio classes.
Was this page helpful?