Portfolio valuation, cashflow analysis, and risk assessment.
Project description
Kupala Val
Kupala Val is a Python package that serves as an API wrapper around Kupala-Nich.com. It provides easy-to-use interfaces for obtaining valuations, cashflows, and bucketed DV01 (dollar value of a basis point) for portfolios of both listed and derivative financial products.
Features
- Portfolio valuation for listed and derivative products
- Cashflow analysis and projections
- Bucketed DV01 sensitivity analysis
- Support for both CSV files and pandas DataFrames
Supported Instruments
As of this release, only OIS Swaps referencing SOFR, ESTR, SONIA, CORRA, TONA, TIIE ON, SARON, and SORA, along with listed instruments available via the YFinance API, are supported. This list will expand over time. Since all valuations are performed through a remote API, updates to supported instruments will be seamless. Users do not need to modify their kupala_val installations to access new products as they become available.
To see full list of supported products, please refer to valuations Page on Kupala-Nich.com. To inquire about specific instrument support, please contact me at maksim.kozyarchuk@gmail.com
Valuation Methodology
Kupala-Nich values OIS Swaps and other OTC products using QuantLib. The valuation curves are constructed from trade data reported via DTCC GTR feeds and overnight rates (OR) retrieved from relevant central banks. Curve data has been maintained since January 2025, while overnight rates have been backfilled to April 2024.
Listed instruments are valued using data provided by the YFinance API.
Installation
pip install kupala_val
Getting Started
Prerequisites
To use this library, you need:
- A free account on Kupala-Nich.com
- An API key (available in the settings menu in the top right corner after login)
Usage Examples
Working with CSV files
from kupala_val import KupalaVal, ValuationStatus
# Create an instance of KupalaVal object with an API Key
val = KupalaVal(API_KEY, vebose=True)
# Upload portfolio.csv to kupala-nich valuation service,
# will return portfolio valuation, cashflows and dv01_buckets data
pa = val.analyze( csv_file_path=r"/path/to/portfolio.csv")
# Save recieved data to csv files in specified folder
if pa.status in [ValuationStatus.SUCCESS, ValuationStatus.PARTIAL_SUCCESS]:
pa.save_all_to_csv(folder=r"kupala_val")
Working with SampleFiles and pandas DataFrames
from kupala_val import KupalaVal, SampleData
# List available sample files. i.e. ois_sample.csv, multi_asset_sample.csv
print(SampleData.get_available_samples())
# Load multi_asset_sample.csv into a DataFrame
df = SampleData.get_sample_data('multi_asset_sample.csv')
# Get valuations for positions in dataframe
val = KupalaVal(API_KEY)
pa = val.analyze(df=df)
# Print returned dataframes
print(pa.positions)
print(pa.cashflows)
print(pa.dv01_buckets)
API Documentation
To obtain valuations for a portfolio of positions, please provide the following information in the CSV file or DataFrame format. For upto date API documentation, please visit valuations section Kupala-Nich.com:
| Field | Required / Optional | Description |
|---|---|---|
product |
Required | Product type (OISSwap; Listed; Cash are supported) |
position_id |
Optional | Unique identifier for the position |
symbol |
Required (for Listed and Cash) | Currency code or ticker recognized by Yahoo Finance |
quantity |
Required (for Listed and Cash) | Number of shares or cash amount. Treated as absolute value; use direction to indicate sign |
cost |
Optional (for Listed) | Cost prices to subtract from market price when calculating NPV |
template |
Required (for Swaps) | Can be curve_name, upi, upi_underlier, or upi_fsin. Refer to the template list for available templates |
direction |
Required | One of Receive Fixed, Pay Fixed, Buy, Sell |
notional |
Required (for Swaps) | Principal amount |
effective_date |
Optional | If not provided, defaults to current day plus settlement day offset for the curve; format YYYY-MM-DD |
maturity_date |
Required (for Swaps) | Maturity date; can be expressed as tenor (e.g., 10Y) or date (YYYY-MM-DD) |
roll_period |
Optional | Defaults from template if not provided |
fixed_rate |
Required (for Swaps) | Fixed rate as a percentage (0 to 100%); e.g., 4.06% |
price_date |
Optional | Valuation date in YYYY-MM-DD format |
roll_type |
Optional | Roll type; valid options: Standard, IMM, EOM |
stub_type |
Optional | Stub type; valid options: ShortInitial, ShortFinal, LongInitial, LongFinal |
roll_conv |
Optional | Roll convention; valid options: Following, ModifiedFollowing, Preceding, ModifiedPreceding, Unadjusted |
term_roll_conv |
Optional | Term roll convention; same valid options as roll_conv |
payment_lag |
Optional | Payment lag in days |
averaging_method |
Optional | Averaging method; valid options: Simple, Compounded |
lookback_days |
Optional | Lookback days for fixings |
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kupala_val-1.0.0.tar.gz.
File metadata
- Download URL: kupala_val-1.0.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12fe9325a72b7c3b76f1ef7924a8950b81ebecce1b0c4434dce81f050839da58
|
|
| MD5 |
3f8c13298bdbd2adc2350778d4ae3974
|
|
| BLAKE2b-256 |
658e9f61497cde679543508e08bdc3d2ab664cfc097e6aef0103a1415884f2d9
|
File details
Details for the file kupala_val-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kupala_val-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
092fde2d6795c125537477d5c2b3da6c8705d44204ac5e81ce893ab163ebc37a
|
|
| MD5 |
b3c76e2eefa9c41e767278bbe8c93805
|
|
| BLAKE2b-256 |
08338e64fa577a4d1302786fd3ad8aad10485a95ba3843e4b4968b162e358ef6
|