Skip to content

Transactions

niveshpy transactions

List, add, or delete transactions.

Usage:

niveshpy transactions [options] <command>

Options:

  -v, --version  Show the version and exit.
  -h, --help     Show this message and exit.

Subcommands

  • add: Create a new transaction.
  • delete: Delete a transaction based on a query.
  • list: List all transactions.

niveshpy transactions add

Create a new transaction.

To create transactions interactively, run niveshpy transactions add without any arguments.

To add a transaction non-interactively, provide all required arguments along with an optional --no-input flag.

Arguments: transaction_date : Date of the transaction in YYYY-MM-DD format. transaction_type : Type of the transaction (either "purchase" or "sale"). description : Description of the transaction. amount : Amount of money involved in the transaction. units : Number of units involved in the transaction. account_id : ID of the account associated with the transaction. security_key : Key of the security involved in the transaction.

Usage:

niveshpy transactions add [options] [<transaction_date>] [<transaction_type>]
                          [<description>] [<amount>] [<units>] [<account_id>]
                          [<security_key>]

Options:

  -v, --version  Show the version and exit.
  --no-input     Run without user input, using defaults or skipping prompts.
  -h, --help     Show this message and exit.

niveshpy transactions delete

Delete a transaction based on a query.

If no key is provided, you will be prompted to select from existing transactions. The query will be used to search for transactions by ID first. If no exact match is found, a text search will be performed based on various attributes. If multiple transactions match the provided query, you will be prompted to select one.

Associated accounts and securities will not be deleted.

When running in a non-interactive mode, --force must be provided to confirm deletion. Additionally, the must match exactly one transaction ID.

Usage:

niveshpy transactions delete [options] [<queries>]

Options:

  -l, --limit INTEGER  Maximum number of limit to list.  [default: 100]
  --no-input           Run without user input, using defaults or skipping
                       prompts.
  -f, --force          Force the operation without confirmation.
  -n, --dry-run        Simulate the operation without making any changes.
  -v, --version        Show the version and exit.
  -h, --help           Show this message and exit.

niveshpy transactions list

List all transactions.

Optionally provide a text QUERY to filter transactions by various attributes.

View the documentation at https://yashovardhan99.github.io/niveshpy/cli/transactions/ for examples.

Usage:

niveshpy transactions list [options] [<queries>]

Options:

  -l, --limit INTEGER  Maximum number of accounts to list.  [default: 30]
  --json
  --csv
  -v, --version        Show the version and exit.
  -h, --help           Show this message and exit.

Usage notes and examples

List transactions

Example

niveshpy transactions
niveshpy transactions list gold # (1)
niveshpy transactions list acct:Z123 # (2)
niveshpy transactions list type:purchase # (3)
  1. Filter by a security with 'gold' in its name or key.
  2. Filter by account 'Z123'.
  3. Filter by transaction type 'purchase'

Model Reference

Models for financial transactions.

TransactionRead(id, transaction_date, type, description, amount, units, security, account, created, metadata=dict()) dataclass

Model for reading transaction data.

TransactionType

Bases: StrEnum

Enum for transaction types.

TransactionWrite(transaction_date, type, description, amount, units, security_key, account_id, metadata=dict()) dataclass

Model for transaction data.