LibOFX
OfxTransactionData Struct Reference

An abstraction of a transaction in an account. More...

Data Fields

OFX mandatory elements

The OFX spec defines the following elements as mandatory. The associated variables should all contain valid data but you should not trust the servers. Check if the associated *_valid is true before using them.

char account_id [OFX_ACCOUNT_ID_LENGTH]
 
struct OfxAccountDataaccount_ptr
 
int account_id_valid
 
TransactionType transactiontype
 
int transactiontype_valid
 
InvTransactionType invtransactiontype
 
int invtransactiontype_valid
 
double units
 
int units_valid
 
double unitprice
 
int unitprice_valid
 
double amount
 
int amount_valid
 
char fi_id [OFX_FITID_LENGTH]
 
int fi_id_valid
 
OFX optional elements

The OFX spec defines the following elements as optional. If the associated *_valid is true, the corresponding element is present and the associated variable contains valid data.

char unique_id [OFX_UNIQUE_ID_LENGTH]
 
int unique_id_valid
 
char unique_id_type [OFX_UNIQUE_ID_TYPE_LENGTH]
 
int unique_id_type_valid
 
struct OfxSecurityDatasecurity_data_ptr
 
int security_data_valid
 
time_t date_posted
 
int date_posted_valid
 
time_t date_initiated
 
int date_initiated_valid
 
time_t date_funds_available
 
int date_funds_available_valid
 
char fi_id_corrected [OFX_FITID_LENGTH]
 
int fi_id_corrected_valid
 
FiIdCorrectionAction fi_id_correction_action
 
int fi_id_correction_action_valid
 
char server_transaction_id [OFX_SVRTID2_LENGTH]
 
int server_transaction_id_valid
 
char check_number [OFX_CHECK_NUMBER_LENGTH]
 
int check_number_valid
 
char reference_number [OFX_REFERENCE_NUMBER_LENGTH]
 
int reference_number_valid
 
long int standard_industrial_code
 
int standard_industrial_code_valid
 
char payee_id [OFX_SVRTID2_LENGTH]
 
int payee_id_valid
 
char name [OFX_TRANSACTION_NAME_LENGTH]
 
int name_valid
 
char memo [OFX_MEMO2_LENGTH]
 
int memo_valid
 
double commission
 
int commission_valid
 
double fees
 
int fees_valid
 
double oldunits
 
int oldunits_valid
 
double newunits
 
int newunits_valid
 
double market_value
 
int market_value_valid
 
char currency [OFX_CURRENCY_LENGTH]
 
int currency_valid
 
double currency_ratio
 
int currency_ratio_valid
 
int amounts_are_foreign_currency
 
int amounts_are_foreign_currency_valid
 

Other OFX elements for investment transactions

OFX spec 2.1.1 section 13.9.2.4.2 elements that are not already defined.

enum  BuyType { OFX_BUY_TYPE_BUY , OFX_BUY_TYPE_BUYTOCOVER , OFX_BUY_TYPE_BUYTOOPEN , OFX_BUY_TYPE_BUYTOCLOSE }
 
enum  IncomeType {
  OFX_CGLONG , OFX_CGSHORT , OFX_DIVIDEND , OFX_INTEREST ,
  OFX_MISC
}
 
enum  Inv401kSource {
  OFX_401K_SOURCE_PRETAX , OFX_401K_SOURCE_AFTERTAX , OFX_401K_SOURCE_MATCH , OFX_401K_SOURCE_PROFITSHARING ,
  OFX_401K_SOURCE_ROLLOVER , OFX_401K_SOURCE_OTHERVEST , OFX_401K_SOURCE_OTHERNONVEST
}
 
enum  OptAction { OFX_OPTACTION_EXERCISE , OFX_OPTACTION_ASSIGN , OFX_OPTACTION_EXPIRE }
 
enum  PosType { OFX_POSTYPE_LONG , OFX_POSTYPE_SHORT }
 
enum  RelatedType { OFX_RELTYPE_SPREAD , OFX_RELTYPE_STRADDLE , OFX_RELTYPE_NONE , OFX_RELTYPE_OTHER }
 
enum  OptionSecured { OFX_SECURED_NAKED , OFX_SECURED_COVERED }
 
enum  SellReason { OFX_SELLREASON_CALL , OFX_SELLREASON_SELL , OFX_SELLREASON_MATURITY }
 
enum  SellType { OFX_SELL_TYPE_SELL , OFX_SELL_TYPE_SELLSHORT , OFX_SELL_TYPE_SELLTOOPEN , OFX_SELL_TYPE_SELLTOCLOSE }
 
enum  SubAcctType { OFX_SUBACCT_CASH , OFX_SUBACCT_MARGIN , OFX_SUBACCT_SHORT , OFX_SUBACCT_OTHER }
 
enum  TransferAction { OFX_TFERACTION_IN , OFX_TFERACTION_OUT }
 
enum  UnitType { OFX_UNITTYPE_SHARES , OFX_UNITTYPE_CURRENCY }
 
double accrued_interest
 
int accrued_interest_valid
 
double avg_cost_basis
 
int avg_cost_basis_valid
 
enum OfxTransactionData::BuyType buy_type
 
int buy_type_valid
 
double denominator
 
int denominator_valid
 
time_t date_payroll
 
int date_payroll_valid
 
time_t date_purchase
 
int date_purchase_valid
 
double gain
 
int gain_valid
 
double cash_for_fractional
 
int cash_for_fractional_valid
 
enum OfxTransactionData::IncomeType income_type
 
int income_type_valid
 
enum OfxTransactionData::Inv401kSource inv_401k_source
 
int inv_401k_source_valid
 
double load
 
int load_valid
 
char loan_id [OFX_LOANID_LENGTH]
 
int loan_id_valid
 
double loan_interest
 
int loan_interest_valid
 
double loan_principal
 
int loan_principal_valid
 
double markdown
 
int markdown_valid
 
double markup
 
int markup_valid
 
double numerator
 
int numerator_valid
 
enum OfxTransactionData::OptAction opt_action
 
int opt_action_valid
 
double penalty
 
int penalty_valid
 
enum OfxTransactionData::PosType pos_type
 
int pos_type_valid
 
int prior_year_contrib
 
int prior_year_contrib_valid
 
char related_fi_tid [OFX_FITID_LENGTH]
 
int related_fi_tid_valid
 
enum OfxTransactionData::RelatedType related_type
 
int related_type_valid
 
enum OfxTransactionData::OptionSecured option_secured
 
int option_secured_valid
 
enum OfxTransactionData::SellReason sell_reason
 
int sell_reason_valid
 
enum OfxTransactionData::SellType sell_type
 
int sell_type_valid
 
double shares_per_cont
 
int shares_per_cont_valid
 
double state_withholding
 
int state_withholding_valid
 
enum OfxTransactionData::SubAcctType subacct_from
 
enum OfxTransactionData::SubAcctType subacct_funding
 
enum OfxTransactionData::SubAcctType subacct_security
 
enum OfxTransactionData::SubAcctType subacct_to
 
int subacct_from_valid
 
int subacct_funding_valid
 
int subacct_security_valid
 
int subacct_to_valid
 
double taxes
 
int taxes_valid
 
int tax_exempt
 
int tax_exempt_valid
 
enum OfxTransactionData::TransferAction transfer_action
 
int transfer_action_valid
 
enum OfxTransactionData::UnitType unit_type
 
int unit_type_valid
 
double withholding
 
int withholding_valid
 

Detailed Description

An abstraction of a transaction in an account.

The OfxTransactionData structure contains all available information about an actual transaction in an account.

Definition at line 682 of file libofx.h.

Member Enumeration Documentation

◆ BuyType

The <BUYTYPE> element is mandatory for stock, fund, and option buys This enum combines stock, fund, and option buy types into one field

Definition at line 850 of file libofx.h.

◆ IncomeType

Type of income for <INCOME> element

Enumerator
OFX_CGLONG 

Long term capital gains

OFX_CGSHORT 

Short term capital gains

OFX_DIVIDEND 

Dividend income

OFX_INTEREST 

Interest income

OFX_MISC 

miscellaneous income

Definition at line 875 of file libofx.h.

◆ Inv401kSource

<INV401KSOURCE> For 401(k) accounts, source of the money used for this security

Definition at line 886 of file libofx.h.

◆ OptAction

For options, the action type

Definition at line 920 of file libofx.h.

◆ OptionSecured

How an option is securred

Definition at line 958 of file libofx.h.

◆ PosType

Position type

Definition at line 932 of file libofx.h.

◆ RelatedType

Related option transaction type

Definition at line 948 of file libofx.h.

◆ SellReason

Reason for the sell of a debt security

Enumerator
OFX_SELLREASON_CALL 

the debt was called

OFX_SELLREASON_SELL 

the debt was sold

OFX_SELLREASON_MATURITY 

the debt reached maturity

Definition at line 966 of file libofx.h.

◆ SellType

The <SELLTYPE> element is mandatory for stock, fund, and option sells This enum combines stock, fund, and option sell types into one field

Definition at line 976 of file libofx.h.

◆ SubAcctType

Account types used for <SUBACCTFROM>, <SUBACCTFUND>, <SUBACCTSEC>, <SUBACCTTO>

Definition at line 994 of file libofx.h.

◆ TransferAction

Action for transfers

Definition at line 1015 of file libofx.h.

◆ UnitType

Type of the units

Definition at line 1023 of file libofx.h.

Field Documentation

◆ account_id

char OfxTransactionData::account_id[OFX_ACCOUNT_ID_LENGTH]

Use this for matching with the relevant account in your application

Definition at line 690 of file libofx.h.

◆ account_ptr

struct OfxAccountData* OfxTransactionData::account_ptr

Pointer to the full account structure, see OfxAccountData

Definition at line 693 of file libofx.h.

◆ accrued_interest

double OfxTransactionData::accrued_interest

Accrued interest when trading debt

Definition at line 842 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ amount

double OfxTransactionData::amount

Total monetary amount of the transaction, signage will determine if money went in or out. amount is the total amount: -(units) * unitprice - various fees

Definition at line 720 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ amounts_are_foreign_currency

int OfxTransactionData::amounts_are_foreign_currency

Whether the amounts have already been converted to the default currency. An <ORIGCURRENCY> sets the flag to true, i.e. the amounts are reported in the foreign currency. A <CURRENCY> element sets the flag to false.

Definition at line 835 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute().

◆ avg_cost_basis

double OfxTransactionData::avg_cost_basis

Average cost basis

Definition at line 845 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ cash_for_fractional

double OfxTransactionData::cash_for_fractional

Cash for fractional units (for stock splits)

Definition at line 871 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ check_number

char OfxTransactionData::check_number[OFX_CHECK_NUMBER_LENGTH]

The check number is most likely an integer and can probably be converted properly with atoi(). However the spec allows for up to 12 digits, so it is not guaranteed to work

Definition at line 786 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ commission

double OfxTransactionData::commission

Commission paid to broker (investment transactions only)

Definition at line 808 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ currency

char OfxTransactionData::currency[OFX_CURRENCY_LENGTH]

<CURSYM> The currency is a string in ISO-4217 format

Definition at line 825 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ currency_ratio

double OfxTransactionData::currency_ratio

ratio of <CURDEF> currency to <CURSYM> currency

Definition at line 829 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ date_funds_available

time_t OfxTransactionData::date_funds_available

Date the funds are available (not always provided) (ex: the date you are allowed to withdraw a deposit

Definition at line 762 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute().

◆ date_initiated

time_t OfxTransactionData::date_initiated

Date the transaction was initiated (ex: date you bought something in a store for credit card; trade date for stocks; day of record for stock split)

Mandatory for investment transactions

Definition at line 754 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ date_payroll

time_t OfxTransactionData::date_payroll

For 401(k) accounts, date the funds were deducted from payroll

Definition at line 862 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ date_posted

time_t OfxTransactionData::date_posted

Date the transaction took effect (ex: date it appeared on your credit card bill). Setlement date; for stock split, execution date.

Mandatory for bank and credit card transactions

Definition at line 747 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ date_purchase

time_t OfxTransactionData::date_purchase

The security's original purchase date

Definition at line 865 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ denominator

double OfxTransactionData::denominator

For stock splits, split ratio denominator

Definition at line 859 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ fees

double OfxTransactionData::fees

Fees applied to trade (investment transactions only)

Definition at line 811 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ fi_id

char OfxTransactionData::fi_id[OFX_FITID_LENGTH]

Generated by the financial institution (fi), unique id of the transaction, to be used to detect duplicate downloads

Definition at line 726 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute().

◆ fi_id_corrected

char OfxTransactionData::fi_id_corrected[OFX_FITID_LENGTH]

IMPORTANT: if fi_id_corrected is present, this transaction is meant to replace or delete the transaction with this fi_id. See OfxTransactionData::fi_id_correction_action to know what to do.

Definition at line 770 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute().

◆ fi_id_correction_action

FiIdCorrectionAction OfxTransactionData::fi_id_correction_action

The OfxTransactionData::FiIdCorrectionAction enum contains the action to be taken

Definition at line 775 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute().

◆ gain

double OfxTransactionData::gain

For sales, the total gain

Definition at line 868 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ load

double OfxTransactionData::load

load on the transaction (amount)

Definition at line 898 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ loan_id

char OfxTransactionData::loan_id[OFX_LOANID_LENGTH]

401(k): indicates the transaction is due to a loan or loan repayment

Definition at line 901 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ loan_interest

double OfxTransactionData::loan_interest

401(k): how much of the load repayment was interest (amount)

Definition at line 904 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ loan_principal

double OfxTransactionData::loan_principal

401(k): how much of the load repayment was principal (amount)

Definition at line 907 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ markdown

double OfxTransactionData::markdown

Portion of the unit price attributed to dealer markdown (unitprice)

Definition at line 910 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ market_value

double OfxTransactionData::market_value

Market value, should be UNITS*UNITPRICE

Definition at line 821 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ markup

double OfxTransactionData::markup

Portion of the unit price attributed to dealer markup (unitprice)

Definition at line 913 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ memo

char OfxTransactionData::memo[OFX_MEMO2_LENGTH]

Extra information not included in name

Definition at line 805 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute().

◆ name

char OfxTransactionData::name[OFX_TRANSACTION_NAME_LENGTH]

Can be the name of the payee or the description of the transaction

Definition at line 801 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ newunits

double OfxTransactionData::newunits

Number of units held after stock split

Definition at line 817 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ numerator

double OfxTransactionData::numerator

For stock splits, split ratio numerator

Definition at line 916 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ oldunits

double OfxTransactionData::oldunits

Number of units held before stock split

Definition at line 814 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ payee_id

char OfxTransactionData::payee_id[OFX_SVRTID2_LENGTH]

The identifier of the payee

Definition at line 798 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ penalty

double OfxTransactionData::penalty

Amount withheld due to a penalty

Definition at line 928 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ prior_year_contrib

int OfxTransactionData::prior_year_contrib

401(k): whether this buy was made with prior year contribution

Definition at line 940 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ reference_number

char OfxTransactionData::reference_number[OFX_REFERENCE_NUMBER_LENGTH]

Might present in addition to or instead of a check_number. Not necessarily a number

Definition at line 791 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ related_fi_tid

char OfxTransactionData::related_fi_tid[OFX_FITID_LENGTH]

ID of related trade

Definition at line 944 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ security_data_valid

int OfxTransactionData::security_data_valid

A pointer to the security's data.

Definition at line 745 of file libofx.h.

◆ server_transaction_id

char OfxTransactionData::server_transaction_id[OFX_SVRTID2_LENGTH]

Used for user initiated transaction such as payment or funds transfer. Can be seen as a confirmation number.

Definition at line 780 of file libofx.h.

Referenced by OfxTransactionContainer::add_attribute().

◆ shares_per_cont

double OfxTransactionData::shares_per_cont

For options, shares per contract

Definition at line 986 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ standard_industrial_code

long int OfxTransactionData::standard_industrial_code

The standard industrial code can have at most 6 digits

Definition at line 794 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ state_withholding

double OfxTransactionData::state_withholding

Used for withholding state taxes on a withdrawal

Definition at line 990 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ subacct_from_valid

int OfxTransactionData::subacct_from_valid

acct the security or cash is being transferred from

Definition at line 1001 of file libofx.h.

◆ subacct_funding_valid

int OfxTransactionData::subacct_funding_valid

acct the cash for the transaction came from

Definition at line 1002 of file libofx.h.

◆ subacct_security_valid

int OfxTransactionData::subacct_security_valid

acct for the security

Definition at line 1003 of file libofx.h.

◆ subacct_to_valid

int OfxTransactionData::subacct_to_valid

acct the security or cash is being transferred to

Definition at line 1004 of file libofx.h.

◆ tax_exempt

int OfxTransactionData::tax_exempt

Tax exempt transaction

Definition at line 1011 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ taxes

double OfxTransactionData::taxes

Taxes on the trade

Definition at line 1007 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ transactiontype_valid

int OfxTransactionData::transactiontype_valid

Investment transaction type. You should read this if transactiontype == OFX_OTHER. See OFX spec 1.6 p.442 to 445 for details

Definition at line 698 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ unique_id

char OfxTransactionData::unique_id[OFX_UNIQUE_ID_LENGTH]

The id of the security being traded. Mandatory for investment transactions

Definition at line 738 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ unique_id_type

char OfxTransactionData::unique_id_type[OFX_UNIQUE_ID_TYPE_LENGTH]

Usially "CUSIP" for FIs in north america

Definition at line 740 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().

◆ unitprice

double OfxTransactionData::unitprice

Value of each unit, 1.00 if the commodity is money

Definition at line 716 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ units

double OfxTransactionData::units

Variation of the number of units of the commodity

Suppose units is -10, ave unitprice is 1. If the commodity is stock, you have 10 less stock, but 10 more dollars in you amccount (fees not considered, see amount). If commodity is money, you have 10 less dollars in your pocket, but 10 more in your account

Definition at line 713 of file libofx.h.

Referenced by OfxBankTransactionContainer::add_attribute(), and OfxInvestmentTransactionContainer::add_attribute().

◆ withholding

double OfxTransactionData::withholding

Federal tax withholding

Definition at line 1031 of file libofx.h.

Referenced by OfxInvestmentTransactionContainer::add_attribute().


The documentation for this struct was generated from the following file: