Skip to main content

ActivityFlexStatement

Struct ActivityFlexStatement 

Source
pub struct ActivityFlexStatement {
Show 39 fields pub account_id: String, pub from_date: NaiveDate, pub to_date: NaiveDate, pub when_generated: String, pub trades: TradesWrapper, pub positions: PositionsWrapper, pub cash_transactions: CashTransactionsWrapper, pub corporate_actions: CorporateActionsWrapper, pub securities_info: SecuritiesInfoWrapper, pub conversion_rates: ConversionRatesWrapper, pub account_information: Option<AccountInformation>, pub change_in_nav: Option<ChangeInNAV>, pub equity_summary: EquitySummaryWrapper, pub cash_report: CashReportWrapper, pub trade_confirms: TradeConfirmsWrapper, pub option_eae: OptionEAEWrapper, pub fx_transactions: FxTransactionsWrapper, pub change_in_dividend_accruals: ChangeInDividendAccrualsWrapper, pub open_dividend_accruals: OpenDividendAccrualsWrapper, pub interest_accruals: InterestAccrualsWrapper, pub transfers: TransfersWrapper, pub mtm_performance_summary: MTMPerformanceSummaryWrapper, pub fifo_performance_summary: FIFOPerformanceSummaryWrapper, pub mtd_ytd_performance_summary: MTDYTDPerformanceSummaryWrapper, pub statement_of_funds: StatementOfFundsWrapper, pub change_in_position_values: ChangeInPositionValueWrapper, pub unbundled_commission_details: UnbundledCommissionDetailWrapper, pub client_fees: ClientFeesWrapper, pub client_fees_detail: ClientFeesDetailWrapper, pub slb_activities: SLBActivitiesWrapper, pub slb_fees: SLBFeesWrapper, pub hard_to_borrow_details: HardToBorrowDetailsWrapper, pub fx_lots: FxLotsWrapper, pub unsettled_transfers: UnsettledTransfersWrapper, pub trade_transfers: TradeTransfersWrapper, pub prior_period_positions: PriorPeriodPositionsWrapper, pub tier_interest_details: TierInterestDetailsWrapper, pub debit_card_activities: DebitCardActivitiesWrapper, pub sales_tax: SalesTaxWrapper, /* private fields */
}
Expand description

Top-level Activity FLEX statement

Contains all data from an Activity FLEX query including trades, positions, cash transactions, and other portfolio data.

This is the main type returned by crate::parse_activity_flex.

§Example

use ib_flex::parse_activity_flex;
use rust_decimal::Decimal;

let xml = std::fs::read_to_string("activity.xml")?;
let statement = parse_activity_flex(&xml)?;

// Access account and date range
println!("Account: {}", statement.account_id);
println!("Period: {} to {}", statement.from_date, statement.to_date);

// Iterate through all trades
for trade in &statement.trades.items {
    println!("{}: {} {} @ {}",
        trade.symbol,
        trade.buy_sell.as_ref().map(|b| format!("{:?}", b)).unwrap_or_default(),
        trade.quantity.unwrap_or_default(),
        trade.price.unwrap_or_default()
    );
}

// Calculate total P&L
let total_pnl: Decimal = statement.trades.items.iter()
    .filter_map(|t| t.fifo_pnl_realized)
    .sum();
println!("Total realized P&L: {}", total_pnl);

// Access positions
for pos in &statement.positions.items {
    println!("{}: {} shares @ {}",
        pos.symbol,
        pos.quantity,
        pos.mark_price
    );
}

Fields§

§account_id: String

IB account number

§from_date: NaiveDate

Statement date range - start date

§to_date: NaiveDate

Statement date range - end date

§when_generated: String

When the report was generated

§trades: TradesWrapper

All trades in the period

§positions: PositionsWrapper

Open positions at end of period

§cash_transactions: CashTransactionsWrapper

Cash transactions (deposits, withdrawals, dividends, interest)

§corporate_actions: CorporateActionsWrapper

Corporate actions (splits, mergers, spinoffs)

§securities_info: SecuritiesInfoWrapper

Securities information (reference data)

§conversion_rates: ConversionRatesWrapper

Currency conversion rates

§account_information: Option<AccountInformation>

Account information

§change_in_nav: Option<ChangeInNAV>

Change in NAV - single element (not wrapped like other sections)

§equity_summary: EquitySummaryWrapper

Equity summary by report date in base currency

§cash_report: CashReportWrapper

Cash report by currency

§trade_confirms: TradeConfirmsWrapper

Trade confirmations

§option_eae: OptionEAEWrapper

Option exercises, assignments, and expirations

§fx_transactions: FxTransactionsWrapper

Foreign exchange transactions

§change_in_dividend_accruals: ChangeInDividendAccrualsWrapper

Change in dividend accruals

§open_dividend_accruals: OpenDividendAccrualsWrapper

Open dividend accruals

§interest_accruals: InterestAccrualsWrapper

Interest accruals by currency

§transfers: TransfersWrapper

Security transfers

§mtm_performance_summary: MTMPerformanceSummaryWrapper

MTM performance summary by underlying

§fifo_performance_summary: FIFOPerformanceSummaryWrapper

FIFO performance summary by underlying

§mtd_ytd_performance_summary: MTDYTDPerformanceSummaryWrapper

MTD/YTD performance summary

§statement_of_funds: StatementOfFundsWrapper

Statement of funds (cash flow tracking)

§change_in_position_values: ChangeInPositionValueWrapper

Change in position value (reconciliation)

§unbundled_commission_details: UnbundledCommissionDetailWrapper

Unbundled commission details

§client_fees: ClientFeesWrapper

Client fees (advisory fees)

§client_fees_detail: ClientFeesDetailWrapper

Client fees detail

§slb_activities: SLBActivitiesWrapper

Securities lending activities

§slb_fees: SLBFeesWrapper

Securities lending fees

§hard_to_borrow_details: HardToBorrowDetailsWrapper

Hard to borrow details

§fx_lots: FxLotsWrapper

FX position lots

§unsettled_transfers: UnsettledTransfersWrapper

Unsettled transfers

§trade_transfers: TradeTransfersWrapper

Trade transfers (inter-broker)

§prior_period_positions: PriorPeriodPositionsWrapper

Prior period positions

§tier_interest_details: TierInterestDetailsWrapper

Tier interest details

§debit_card_activities: DebitCardActivitiesWrapper

Debit card activities

§sales_tax: SalesTaxWrapper

Sales tax

Trait Implementations§

Source§

impl Clone for ActivityFlexStatement

Source§

fn clone(&self) -> ActivityFlexStatement

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActivityFlexStatement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ActivityFlexStatement

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ActivityFlexStatement

Source§

fn eq(&self, other: &ActivityFlexStatement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ActivityFlexStatement

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ActivityFlexStatement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,