portfolio_toolkit.account package
Submodules
portfolio_toolkit.account.account module
- class portfolio_toolkit.account.account.Account(name: str, currency: str, transactions: ~typing.List[~portfolio_toolkit.account.transaction.AccountTransaction] = <factory>)[fuente]
Bases:
object
Represents an account with a list of transactions.
- transactions: List[AccountTransaction]
- add_transaction(transaction: AccountTransaction)[fuente]
Adds a transaction to the account.
- Parámetros:
transaction (AccountTransaction) – The transaction to add.
- add_transaction_from_dict(transaction_dict: dict)[fuente]
Adds a transaction to the account from a dictionary.
- Parámetros:
transaction_dict (dict) – Dictionary containing transaction details.
- add_transaction_from_assets_dict(transaction_dict: dict)[fuente]
Adds a transaction to the account from a dictionary.
- Parámetros:
transaction_dict (dict) – Dictionary containing transaction details.
- add_transaction_from_split_dict(split_dict: dict, amount: float = 0.0)[fuente]
Adds a transaction to the account from a stock split dictionary.
- Parámetros:
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] [fuente]
Converts the account transactions to a list of dictionaries.
- Devuelve:
List containing the account transactions.
- Tipo del valor devuelto:
List[dict]
- to_dataframe() DataFrame [fuente]
Converts the account transactions to a pandas DataFrame.
- Devuelve:
DataFrame containing the account transactions.
- Tipo del valor devuelto:
pd.DataFrame
- export_to_dataframe(from_date: str, to_date: str) DataFrame [fuente]
Converts the account transactions to a pandas DataFrame.
- Devuelve:
DataFrame containing the account transactions.
- Tipo del valor devuelto:
pd.DataFrame
- get_amount() float [fuente]
Calculates the total amount of all transactions in the account.
- Devuelve:
Total amount of all transactions.
- Tipo del valor devuelto:
portfolio_toolkit.account.transaction module
- class portfolio_toolkit.account.transaction.AccountTransaction(transaction_date: date, transaction_type: str, amount: float, description: str | None = None)[fuente]
Bases:
object
Represents a transaction in an account.
Module contents
- class portfolio_toolkit.account.AccountTransaction(transaction_date: date, transaction_type: str, amount: float, description: str | None = None)[fuente]
Bases:
object
Represents a transaction in an account.
- __init__(transaction_date: date, transaction_type: str, amount: float, description: str | None = None) None
- class portfolio_toolkit.account.Account(name: str, currency: str, transactions: ~typing.List[~portfolio_toolkit.account.transaction.AccountTransaction] = <factory>)[fuente]
Bases:
object
Represents an account with a list of transactions.
- __init__(name: str, currency: str, transactions: ~typing.List[~portfolio_toolkit.account.transaction.AccountTransaction] = <factory>) None
- add_transaction(transaction: AccountTransaction)[fuente]
Adds a transaction to the account.
- Parámetros:
transaction (AccountTransaction) – The transaction to add.
- add_transaction_from_assets_dict(transaction_dict: dict)[fuente]
Adds a transaction to the account from a dictionary.
- Parámetros:
transaction_dict (dict) – Dictionary containing transaction details.
- add_transaction_from_dict(transaction_dict: dict)[fuente]
Adds a transaction to the account from a dictionary.
- Parámetros:
transaction_dict (dict) – Dictionary containing transaction details.
- add_transaction_from_split_dict(split_dict: dict, amount: float = 0.0)[fuente]
Adds a transaction to the account from a stock split dictionary.
- Parámetros:
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)
- export_to_dataframe(from_date: str, to_date: str) DataFrame [fuente]
Converts the account transactions to a pandas DataFrame.
- Devuelve:
DataFrame containing the account transactions.
- Tipo del valor devuelto:
pd.DataFrame
- get_amount() float [fuente]
Calculates the total amount of all transactions in the account.
- Devuelve:
Total amount of all transactions.
- Tipo del valor devuelto:
- get_amount_at(date) float [fuente]
Calculates the total amount of all transactions in the account up to a given date.
- Parámetros:
date – The cutoff date (can be string or date object)
- Devuelve:
Total amount of all transactions up to the specified date.
- Tipo del valor devuelto:
- to_dataframe() DataFrame [fuente]
Converts the account transactions to a pandas DataFrame.
- Devuelve:
DataFrame containing the account transactions.
- Tipo del valor devuelto:
pd.DataFrame
- to_list() List[dict] [fuente]
Converts the account transactions to a list of dictionaries.
- Devuelve:
List containing the account transactions.
- Tipo del valor devuelto:
List[dict]
- transactions: List[AccountTransaction]