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 release 1.1 the following products are supported

  • OIS Swaps referencing SOFR, ESTR, SONIA, CORRA, TONA, TIIE ON, SARON, and SORA
  • FX Forwards using available OIS Curves for discounting, Support for FX Specific curves will be added over time
  • Listed instruments available via the YFinance API
  • Cash balances

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
currency_pair Required (for FX) Currency pair in XXX/YYY format i.e EUR/USD, GBP/JPY...
traded_currency Required (for FX) Traded FX Currency, linked with direction and notional
direction Required One of Receive Fixed, Pay Fixed, Buy, Sell
notional Required (for Swaps, FX) 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, FX) 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%
forward_rate Required (for FX) FX Forward Rate in convention of the currency pair
price_date Optional Valuation date in YYYY-MM-DD format, or LATEST
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-1.1.1.tar.gz (11.6 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-1.1.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kupala_val-1.1.1.tar.gz
Algorithm Hash digest
SHA256 b4a3d6f3ee83ca6ac55733134a18d5191b998e2bee87e5a3f0cfa9afb18e6def
MD5 55d18c5f1154ccdee96bf953e0f8a79d
BLAKE2b-256 7d68846819206629d14ff276e363ac5f12ecce55b74b018d0af02aa217dbc3e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kupala_val-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 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-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8cdb65a3c1048ad165bc9bdb42d11cae769ea20891f927e5b9c160bea554883
MD5 30ab46ee2be0401256f6964ffec3db75
BLAKE2b-256 406cad3b174dd01f2fef2213ae1dc8dd9020702a26fa0259193f68a7894a07a5

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