Prices¶
niveshpy prices¶
Commands for updating and fetching price data.
Price data for securities are stored at a daily granularity.
External price providers can be installed to fetch price data automatically.
Usage:
niveshpy prices [options] <command>
Options:
-v, --version Show the version and exit.
-h, --help Show this message and exit.
Subcommands
- list: List latest price for all securities.
- sync: Sync prices from installed providers.
- update: Update price for a specific security.
niveshpy prices list¶
List latest price for all securities.
By default, lists last available price for all securities in the portfolio.
Optionally provide text
Run niveshpy prices sync to fetch latest prices from installed providers.
See https://yashovardhan99.github.io/niveshpy/cli/prices for example usage.
Usage:
niveshpy prices list [options] [<queries>]
Options:
-v, --version Show the version and exit.
-l, --limit INTEGER Maximum number of securities to list. [default: 30]
--json
--csv
-h, --help Show this message and exit.
niveshpy prices sync¶
Sync prices from installed providers.
By default, syncs prices for all securities in the portfolio.
Optionally provide text
See https://yashovardhan99.github.io/niveshpy/cli/prices for example usage.
Usage:
niveshpy prices sync [options] [<queries>]
Options:
-v, --version Show the version and exit.
--force Force update even if prices are up-to-date.
--provider PROVIDER Specify a particular price provider to use.
-h, --help Show this message and exit.
niveshpy prices update¶
Update price for a specific security.
Requires the security
See https://yashovardhan99.github.io/niveshpy/cli/prices for example usage and notes.
Usage:
niveshpy prices update [options] [<security_key>] [<date>] [<ohlc>]
Options:
-v, --version Show the version and exit.
-h, --help Show this message and exit.
Usage notes and examples¶
List prices¶
Example
niveshpy prices list # (1)
niveshpy prices list UTI DSP # (2)
niveshpy prices list 'date:2023-01-01..2023-01-31' # (3)
niveshpy prices list UTI 'date:2023-01-01' # (4)
- Show the latest prices for all available securities
- Show the latest prices for all securities matching the regex "UTI" or "DSP"
- Show all prices from 2023-01-01 to 2023-01-31.
- Show price of all securities matching "UTI" for date 2023-01-01
Update prices¶
Note
- If 1 value is provided for
<ohlc>, it is treated as the closing price. Other prices are set to the same value. - If 2 values are provided, they are treated as opening and closing prices. High and Low are automatically set.
- If 4 values are provided, they are treated as opening, high, low, and closing prices respectively.
- Any other number of values will raise an error.
Example
niveshpy prices update # (1)
niveshpy prices update AAPL 2023-01-15 150.25 # (2)
- Update prices interactively.
- Set closing price of security with key "AAPL" on 2023-01-15 to 150.25.
Sync prices¶
Example
niveshpy prices sync # (1)
niveshpy prices sync UTI DSP # (2)
niveshpy prices sync 'date:2023-01' # (3)
niveshpy prices sync 'UTI Nifty' 'date:2025' --force --provider amfi # (4)
- Sync prices for all securities with default providers
- Sync prices for securites matching regex "UTI" and "DSP".
- Sync prices for all securities from 2023-01-01 to 2023-01-31.
- Sync prices for securities matching regex "UTI Nifty" from 2025-01-01 to 2025-12-31 using the provider "amfi". Due to
--force, it will forcefully re-fetch all prices even if the prices were already available in the database.
Price Providers¶
NiveshPy comes bundled with a few useful providers. However, you can use your own custom provider as well.
Bundled Providers¶
| Provider Name | Description | Command |
|---|---|---|
| AMFI | Provide mutual fund prices from AMFI. | niveshpy prices sync --provider amfi |
Custom Providers¶
To learn how to create your own custom provider, check our guide