Skip to main content

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:

  1. A free account on Kupala-Nich.com
  2. 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

kupala_val-0.2.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kupala_val-0.2.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file kupala_val-0.2.0.tar.gz.

File metadata

  • Download URL: kupala_val-0.2.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for kupala_val-0.2.0.tar.gz
Algorithm Hash digest
SHA256 77b2075aa9abd91dcc0988e65d0931885cb34bccbb42c718ab027215f6065271
MD5 f4687cc855d06b31a2feec2210f1f8dc
BLAKE2b-256 8c389a12e275792a2aa0f68361bc4cd8f46d6458a1321289d44cbd44a97f502b

See more details on using hashes here.

File details

Details for the file kupala_val-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: kupala_val-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for kupala_val-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdf1e24fbb2d38d6c7ddd43be4c8e8e6866ce080b5a0b2e883f9b0c6d11da5fb
MD5 f78889434558337b357a75d48689bea4
BLAKE2b-256 a1b0d42bf3c641d9e21abf33594a07729cb1eda03b6f6499be19af36d8c4b857

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page