Skip to content

Securities

A security is an investment instrument that you have purchased or sold. This can be a mutual fund, a stock, an ETF or even physical commodities such as gold or silver.

niveshpy securities

Work with securities.

Usage:

niveshpy securities [options] <command>

Options:

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

Subcommands

  • add: Add a new security.
  • delete: Delete a security based on a query.
  • list: List all securities.

niveshpy securities add

Add a new security.

To create securities interactively, run the command with no arguments. To add a single security non-interactively, provide all arguments along with --no-input.

is a unique identifier for the security, e.g., ticker symbol or ISIN. If another security with the same key exists, it will be updated.

category and type should be one of the enum values:

  • Category: EQUITY, DEBT, COMMODITY, OTHER
  • Type: STOCK, BOND, MUTUAL_FUND, ETF, OTHER

Usage:

niveshpy securities add [options] [<key>] [<name>] [<category>] [<type>]

Options:

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

niveshpy securities delete

Delete a security based on a query.

If no key is provided, you will be prompted to select from existing securities. The query will be used to search for securities by key or name. If multiple securities match the provided query, you will be prompted to select one.

Associated transactions and holdings are not deleted but will no longer be visible in reports.

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

Usage:

niveshpy securities 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 securities list

List all securities.

Optionally provide a text QUERY to filter securities by key or name.

Usage:

niveshpy securities list [options] [<queries>]

Options:

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

Model Reference

Models for securities.

SecurityCategory

Bases: StrEnum

Enum for security categories.

SecurityRead(key, name, type, category, created=datetime.now(), metadata=dict()) dataclass

Model for security data.

SecurityType

Bases: StrEnum

Enum for security types.

SecurityWrite(key, name, type, category, metadata=dict()) dataclass

Model for creating or updating security data.