Skip to main content

CashTransaction

Struct CashTransaction 

Source
pub struct CashTransaction {
Show 46 fields pub account_id: String, pub transaction_id: Option<String>, pub transaction_type: Option<String>, pub description: Option<String>, pub amount: Decimal, pub currency: String, pub fx_rate_to_base: Option<Decimal>, pub date: Option<NaiveDate>, pub settle_date: Option<NaiveDate>, pub ex_date: Option<NaiveDate>, pub conid: Option<String>, pub symbol: Option<String>, pub asset_category: Option<AssetCategory>, pub cusip: Option<String>, pub isin: Option<String>, pub figi: Option<String>, pub security_id: Option<String>, pub security_id_type: Option<String>, pub multiplier: Option<Decimal>, pub strike: Option<Decimal>, pub expiry: Option<NaiveDate>, pub put_call: Option<PutCall>, pub underlying_conid: Option<String>, pub underlying_symbol: Option<String>, pub code: Option<String>, pub date_time: Option<String>, pub report_date: Option<NaiveDate>, pub available_for_trading_date: Option<NaiveDate>, pub action_id: Option<String>, pub trade_id: Option<String>, pub client_reference: Option<String>, pub issuer: Option<String>, pub issuer_country_code: Option<String>, pub sub_category: Option<String>, pub listing_exchange: Option<String>, pub underlying_listing_exchange: Option<String>, pub underlying_security_id: Option<String>, pub principal_adjust_factor: Option<Decimal>, pub serial_number: Option<String>, pub delivery_type: Option<String>, pub commodity_type: Option<String>, pub fineness: Option<Decimal>, pub weight: Option<String>, pub level_of_detail: Option<String>, pub model: Option<String>, pub acct_alias: Option<String>,
}
Expand description

A cash transaction (deposit, withdrawal, dividend, interest, fee)

Represents any cash flow that affects your account balance: deposits, withdrawals, dividends, interest payments, withholding taxes, and fees. Fields are organized into CORE and EXTENDED sections.

§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)?;

// Categorize cash flows
let mut dividends = Decimal::ZERO;
let mut interest = Decimal::ZERO;
let mut fees = Decimal::ZERO;

for cash_txn in &statement.cash_transactions.items {
    match cash_txn.transaction_type.as_deref() {
        Some("Dividends") => {
            dividends += cash_txn.amount;
            println!("Dividend from {}: {}",
                cash_txn.symbol.as_ref().unwrap_or(&"N/A".to_string()),
                cash_txn.amount
            );
        }
        Some("Broker Interest Paid") | Some("Broker Interest Received") => {
            interest += cash_txn.amount;
        }
        Some("Other Fees") | Some("Commission Adjustments") => {
            fees += cash_txn.amount;
        }
        _ => {
            println!("{:?}: {}", cash_txn.transaction_type, cash_txn.amount);
        }
    }
}

println!("\nTotals:");
println!("  Dividends: {}", dividends);
println!("  Interest: {}", interest);
println!("  Fees: {}", fees);

Fields§

§account_id: String

IB account number

§transaction_id: Option<String>

IB transaction ID

§transaction_type: Option<String>

Transaction type (Deposits, Dividends, WithholdingTax, BrokerInterest, etc.)

§description: Option<String>

Description of transaction

§amount: Decimal

Amount (positive for credits, negative for debits)

§currency: String

Currency

§fx_rate_to_base: Option<Decimal>

FX rate to base currency

§date: Option<NaiveDate>

Transaction date

§settle_date: Option<NaiveDate>

Settlement date

§ex_date: Option<NaiveDate>

Ex-dividend date (tax-critical for dividends)

§conid: Option<String>

Related security’s contract ID (for dividends)

§symbol: Option<String>

Related security’s symbol

§asset_category: Option<AssetCategory>

Asset category

§cusip: Option<String>

CUSIP

§isin: Option<String>

ISIN

§figi: Option<String>

FIGI

§security_id: Option<String>

Security ID

§security_id_type: Option<String>

Security ID type

§multiplier: Option<Decimal>

Contract multiplier

§strike: Option<Decimal>

Strike price

§expiry: Option<NaiveDate>

Expiry date

§put_call: Option<PutCall>

Put or Call

§underlying_conid: Option<String>

Underlying contract ID

§underlying_symbol: Option<String>

Underlying symbol

§code: Option<String>

Transaction code (tax-relevant codes)

§date_time: Option<String>

Transaction datetime

§report_date: Option<NaiveDate>

Report date

§available_for_trading_date: Option<NaiveDate>

Available for trading date

§action_id: Option<String>

Action ID

§trade_id: Option<String>

Trade ID (for dividend/interest related to specific trade)

§client_reference: Option<String>

Client reference

§issuer: Option<String>

Issuer

§issuer_country_code: Option<String>

Issuer country code

§sub_category: Option<String>

Sub-category

§listing_exchange: Option<String>

Listing exchange

§underlying_listing_exchange: Option<String>

Underlying listing exchange

§underlying_security_id: Option<String>

Underlying security ID

§principal_adjust_factor: Option<Decimal>

Principal adjust factor

§serial_number: Option<String>

Serial number

§delivery_type: Option<String>

Delivery type

§commodity_type: Option<String>

Commodity type

§fineness: Option<Decimal>

Fineness

§weight: Option<String>

Weight

§level_of_detail: Option<String>

Level of detail

§model: Option<String>

Model

§acct_alias: Option<String>

Account alias

Trait Implementations§

Source§

impl Clone for CashTransaction

Source§

fn clone(&self) -> CashTransaction

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 CashTransaction

Source§

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

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

impl<'de> Deserialize<'de> for CashTransaction

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 CashTransaction

Source§

fn eq(&self, other: &CashTransaction) -> 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 CashTransaction

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 CashTransaction

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>,