portfolio_toolkit.account.account module
- class portfolio_toolkit.account.account.Account(name: str, currency: str, transactions: ~typing.List[~portfolio_toolkit.account.transaction.AccountTransaction] = <factory>)[source]
Bases:
object
Represents an account with a list of transactions.
- transactions: List[AccountTransaction]
- add_transaction(transaction: AccountTransaction)[source]
Adds a transaction to the account.
- Parameters:
transaction (AccountTransaction) – The transaction to add.
- add_transaction_from_dict(transaction_dict: dict)[source]
Adds a transaction to the account from a dictionary.
- Parameters:
transaction_dict (dict) – Dictionary containing transaction details.
- add_transaction_from_assets_dict(transaction_dict: dict)[source]
Adds a transaction to the account from a dictionary.
- Parameters:
transaction_dict (dict) – Dictionary containing transaction details.
- add_transaction_from_split_dict(split_dict: dict, amount: float = 0.0)[source]
Adds a transaction to the account from a stock split dictionary.
- Parameters:
split_dict (dict) – Dictionary containing split information with keys: - date: Split date (str) - ticker: Ticker symbol of the asset - split_factor: Split ratio as float (e.g., 2.0 for 2:1 split, 0.1 for 1:10 reverse split) - amount: Amount of the asset affected by the split (default is 0.0)
- to_list() List[dict] [source]
Converts the account transactions to a list of dictionaries.
- Returns:
List containing the account transactions.
- Return type:
List[dict]
- to_dataframe() DataFrame [source]
Converts the account transactions to a pandas DataFrame.
- Returns:
DataFrame containing the account transactions.
- Return type:
pd.DataFrame
- export_to_dataframe(from_date: str, to_date: str) DataFrame [source]
Converts the account transactions to a pandas DataFrame.
- Returns:
DataFrame containing the account transactions.
- Return type:
pd.DataFrame
- get_amount() float [source]
Calculates the total amount of all transactions in the account.
- Returns:
Total amount of all transactions.
- Return type: