Portfolio & Accounts¶
All portfolio endpoints use POST against dpservice.fidelity.com with JSON request/response bodies.
Accounts¶
Returns the list of brokerage accounts linked to the authenticated session.
Account Features¶
New in v0.3
Added in Phase 4. Reveals account capabilities and trading permissions.
features = client.account_features.get_features(["Z12345678"])
for f in features.features:
print(f"{f.acct_num}: margin={f.margin_ind}, options={f.options_ind}, "
f"level={f.option_level}, short_sell={f.short_sell_ind}")
Response fields (AccountFeature):
| Field | Type | Description |
|---|---|---|
acct_num |
str | Account number |
acct_type |
str | Account type (INDIVIDUAL, JOINT, IRA, etc.) |
option_level |
str | Options trading level (0-5) |
margin_ind |
bool | Margin trading enabled |
short_sell_ind |
bool | Short selling enabled |
options_ind |
bool | Options trading enabled |
crypto_ind |
bool | Crypto trading enabled |
directed_trading_ind |
bool | Directed trading enabled |
penny_stock_ind |
bool | Penny stock trading enabled |
Service: GET /api/v1/accounts/{acct}/features
Positions¶
positions = client.positions.get_positions(["Z12345678"])
for pos in positions.positions:
print(f"{pos.symbol}: {pos.quantity} shares @ ${pos.price_detail.last_price}")
Balances¶
balances = client.balances.get_balances(["Z12345678"])
for bal in balances.balances:
print(f"Account value: ${bal.acct_val_detail.total_acct_value}")
Open Lots¶
New in v0.3
Per-position tax lot breakdown with acquisition dates and gain/loss.
lots = client.open_lots.get_open_lots("Z12345678", "AAPL")
for lot in lots.lots:
print(f" Lot {lot.lot_id}: {lot.quantity} shares, "
f"cost=${lot.cost_per_share}, G/L=${lot.gain_loss} ({lot.term})")
Response fields (LotDetail):
| Field | Type | Description |
|---|---|---|
lot_id |
str | Unique lot identifier |
acquired_date |
str | Date the lot was acquired |
quantity |
float | Number of shares in this lot |
cost_basis |
float | Total cost basis |
cost_per_share |
float | Cost per share |
market_value |
float | Current market value |
gain_loss |
float | Unrealized gain/loss amount |
gain_loss_pct |
float | Gain/loss percentage |
term |
str | Holding period: "LONG" or "SHORT" |
Properties:
lot.is_long_term—Truewhen held over 1 year
Service: GET /api/v1/accounts/{acct}/lots/{symbol}
Hard-to-Borrow¶
New in v0.3
Short selling borrow rates and stock availability.
htb = client.hard_to_borrow.get_borrow_rates("Z12345678", ["GME", "AMC"])
for p in htb.positions:
print(f"{p.symbol}: rate={p.borrow_rate}%, htb={p.is_hard_to_borrow}, "
f"locate_needed={p.needs_locate}, available={p.available_qty}")
Response fields (HardToBorrowPosition):
| Field | Type | Description |
|---|---|---|
symbol |
str | Ticker symbol |
cusip |
str | CUSIP identifier |
borrow_rate |
float | Annual borrow rate (%) |
available_qty |
float | Shares available to borrow |
htb_ind |
bool | Hard-to-borrow flag |
locate_required_ind |
bool | Locate required before shorting |
status |
str | Status code |
status_desc |
str | Status description |
Properties:
p.is_hard_to_borrow—Truewhen stock is hard to borrowp.needs_locate—Truewhen a locate is required
Service: GET /api/v1/accounts/{acct}/hard-to-borrow?symbols=
Short Insights¶
New in v0.3
Short interest data and historical time series.
# Current short interest snapshot
insights = client.short_insights.get_insights("Z12345678", ["GME"])
for i in insights.insights:
print(f"{i.symbol}: short_interest={i.short_interest}, "
f"days_to_cover={i.days_to_cover}, short_pct={i.short_pct_of_float}%")
# Historical time series
ts = client.short_insights.get_time_series("GME", metric="shortInterest")
for point in ts.data_points:
print(f" {point.date}: {point.value}")
Response fields (ShortInsightDetail):
| Field | Type | Description |
|---|---|---|
symbol |
str | Ticker symbol |
short_interest |
float | Total shares sold short |
short_interest_ratio |
float | Short interest ratio |
days_to_cover |
float | Days to cover at avg volume |
short_pct_of_float |
float | Short interest as % of float |
shares_short |
float | Current shares short |
prior_shares_short |
float | Prior reporting period |
settlement_date |
str | Current data date |
borrow_rate |
float | Current borrow rate |
lending_supply |
float | Shares available for lending |
Service: GET /api/v1/accounts/{acct}/short-insights?symbols= and GET /api/v1/accounts/{acct}/short-insights/{symbol}/timeseries
Accruals¶
New in v0.3
Margin interest, dividend accruals, and cash sweep interest.
# Margin interest and dividend accruals
accruals = client.accruals.get_accruals(["Z12345678"])
for a in accruals.accruals:
print(f"{a.acct_num}: {a.accrual_type} = ${a.accrual_amount}")
# V2 endpoint (same response shape)
accruals_v2 = client.accruals.get_accruals_v2(["Z12345678"])
# Cash sweep accruals
cash = client.accruals.get_cash_accruals(["Z12345678"])
for c in cash.accruals:
print(f"{c.acct_num}: ${c.cash_accrual_amount} ({c.description})")
Response fields (AccrualDetail):
| Field | Type | Description |
|---|---|---|
acct_num |
str | Account number |
accrual_type |
str | Type (MARGIN_INTEREST, DIVIDEND, etc.) |
accrual_amount |
float | Accrued amount |
accrual_date |
str | Accrual date |
description |
str | Human-readable description |
symbol |
str | Associated symbol (if applicable) |
rate |
float | Interest/dividend rate |
Cash accrual fields (CashAccrualDetail):
| Field | Type | Description |
|---|---|---|
acct_num |
str | Account number |
cash_accrual_amount |
float | Cash sweep accrual amount |
accrual_date |
str | Accrual date |
description |
str | Description (e.g., "Cash Sweep Interest") |
Service: GET /api/v1/accounts/{acct}/accruals and GET /api/v1/accounts/{acct}/cash-accruals
Closed Lots¶
New in v0.3
Realized gain/loss per tax lot for closed positions, with wash sale detection.
lots = client.closed_lots.get_closed_lots("Z12345678", "AAPL",
start_date="2026-01-01", end_date="2026-03-31")
for lot in lots.lots:
print(f" Lot {lot.lot_id}: {lot.quantity} shares, "
f"cost=${lot.cost_basis}, proceeds=${lot.proceeds}, "
f"G/L=${lot.gain_loss} ({lot.term})")
if lot.is_wash_sale:
print(" ⚠ Wash sale")
Response fields (ClosedLotDetail):
| Field | Type | Description |
|---|---|---|
lot_id |
str | Unique lot identifier |
symbol |
str | Ticker symbol |
quantity |
float | Number of shares |
acquired_date |
str | Date the lot was acquired |
sold_date |
str | Date the lot was sold |
cost_basis |
float | Total cost basis |
proceeds |
float | Sale proceeds |
gain_loss |
float | Realized gain/loss |
gain_loss_pct |
float | Gain/loss percentage |
term |
str | Holding period: "LONG" or "SHORT" |
wash_sale_ind |
bool | Wash sale indicator |
Properties:
lot.is_long_term—Truewhen held over 1 yearlot.is_wash_sale—Truewhen flagged as a wash sale
Service: GET /api/v1/accounts/{acct}/closed-lots/{symbol}
Other Portfolio Endpoints¶
These endpoints were available before Phase 4:
| Module | Method | Description |
|---|---|---|
option_summary |
get_option_summary(accts) |
Per-account option positions summary |
transactions |
get_transaction_history(accts, from, to) |
Account activity history |
closed_positions |
get_closed_positions(accts, start, end) |
Realized gain/loss |
loaned_securities |
get_loaned_securities(accts) |
Fully paid lending rates |
tax_lots |
get_tax_lots(acct, symbol) |
Tax lot cost basis details |