NavPipe is a high-performance, compiled Python SDK for fetching mutual fund NAV history from the unofficial API at:
By moving the core logic to Rust, NavPipe now offers massive concurrency with minimal overhead, returning results directly into Polars memory.
- 🦀 Safety: Memory-safe concurrent fetching using the
tokioruntime. - 🚀 Speed: Zero-copy data transfers between Rust and Python via
pyo3-polars. - 📊 Lazy-First: Native support for Polars
LazyFrame, allowing you to optimize queries before they run. - 🧵 True Parallelism: Bypasses the Python Global Interpreter Lock (GIL) for network I/O and data transformation.
pip install navpipeimport navpipe
import polars as pl
# Initialize the Rust-backed client
client = navpipe.NavPipe(max_concurrency=10)
# Eager execution: Returns a polars.DataFrame immediately
df = client.nav_history(
scheme_codes=[119551, 120503],
start_date="2023-01-01",
end_date="2023-12-31",
)
print(df)The Rust engine performs diagonal concatenation to ensure all scheme data is merged efficiently:
| Column | Type | Description |
|---|---|---|
| scheme_code | Int64 | The MFAPI unique identifier |
| date | Date | The NAV date |
| nav | Float64 | The Net Asset Value |
NavPipe requires scheme codes to be provided manually. You can find these on: 👉 https://www.mfapi.in
Example: https://api.mfapi.in/mf/119551 → 119551 is the code.
NavPipe(max_concurrency: int)
Initializes the engine.
max_concurrency: Limits the number of simultaneous HTTP requests using atokio::sync::Semaphore.
nav_history(...) -> pl.DataFrame
Eagerly fetches and collects data into a standard Polars DataFrame.
NavPipe aims to:
- Move the Heavy Lifting to Rust: All networking and JSON-to-Arrow transformation happens in compiled code.
- Polars First: Treat DataFrames as the primary citizen, avoiding the overhead of Python dictionaries or lists.
- Async Under the Hood: Use the tokio multi-threaded scheduler to manage I/O without requiring the user to write async/await code in Python.
Architecture Layers:
- Transport: Rust
reqwestwithrustlsfor high-performance HTTP. - Concurrency:
tokiosemaphore-controlled task spawning. - Transformation: Native Rust parsing into
polars-coreseries. - Bridge:
PyO3+pyo3-polarsfor zero-overhead Python integration.
We welcome contributions to the Rust core or the Python stubs! Just make sure to open an issue to discuss it first.
Apache 2.0
