semvec/pypi-packages huggingface dataset:
hoadleyYaPu 0.2
A package for Black-Scholes option pricing and implied volatility calculation(European Options only)
Requires Python: >=3.6

# **Calculation Of Option Greeks and Implied Volatility in Python**

The aim of this package is to calculate Option Greeks and Implied Volatility for European options. The function takes input in a similar form to the popular Hoadley add-in used in Excel.

## **Functions:**
```blackScholes(calculation_type, Option_type, K, S, T, sigma, r = 0)```: Calculates option price, delta, gamma, vega, theta, or rho.
```implied_volatility(Option_type, K, S, T, Option_price, r = 0, tol = 0.0001, max_iterations = 100)```: Estimates implied volatility using Newton-Ralphson method.

## **Calculations**: 
1.  Performs price, delta, gamma, vega, theta, and rho calculations for both call and put options.
2.  Implied Volatility: Estimates implied volatility using numerical methods.
Input Validation: Includes checks for invalid inputs (e.g., NaN values, zero strike price).
Error Handling: Handles potential errors (e.g., incorrect option type, wrong Datatype entry when number is expected, etc.).

## **Input Parameters**:
```calculation_type```: Specifies the type of calculation to perform (price, delta, gamma, vega, theta, rho).<br>
&nbsp;&nbsp;&nbsp;i. Use 'p' for price.<br>
&nbsp;&nbsp;&nbsp;ii. Use 'd' for delta.<br>
&nbsp;&nbsp;&nbsp;iii. Use 'g' for gamma.<br>
&nbsp;&nbsp;&nbsp;iv. Use 'v' for vega.<br>
&nbsp;&nbsp;&nbsp;v. Use 't' for theta.<br>
&nbsp;&nbsp;&nbsp;vi. Use 'r' for rho.<br>
```Option_type```: Specifies the option type (call or put).<br>
```K```: Strike price.<br>
```S```: Underlying asset price.<br>
```T```: Time to expiration (in Days).<br>
```sigma```: Volatility.<br>
```r```: Risk-free interest rate.<br>
```Option_price```: Market price of the option (used for implied volatility calculation).<br>
```tol```: Tolerance level for implied volatility calculation.<br>
```max_iterations```: Maximum number of iterations for implied volatility calculation.<br>

## Example Usage

Here is an example of how to use the `blackScholes` and `implied_volatility` functions:

```python
from hoadleyYaPu import hoadleyYaPu

# Calculate call and put prices using the Black-Scholes model
callprice = hoadleyYaPu.blackScholes("p", "c", 100, 100, 15, 0.1855, 0)
putprice = hoadleyYaPu.blackScholes("p", "p", 1350, 1400, 15, 0.25, 0)

# Calculate the Greeks for a call option using the Black-Scholes model
callDelta = hoadleyYaPu.blackScholes("d", "c", 1350, 1400, 15, 0.25, 0)
callgamma = hoadleyYaPu.blackScholes("g", "c", 1350, 1400, 15, 0.25, 0)
callvega = hoadleyYaPu.blackScholes("v", "c", 1350, 1400, 15, 0.25, 0)
calltheta = hoadleyYaPu.blackScholes("t", "c", 1350, 1400, 15, 0.25, 0)
callrho = hoadleyYaPu.blackScholes("r", "c", 1350, 1400, 15, 0.25, 0)

# Calculate implied volatility for call and put options
callIV = hoadleyYaPu.implied_volatility("c", 42200, 41653.55, 1, 14.05, 0)
putIV = hoadleyYaPu.implied_volatility("p", 42200, 41653.55, 15, 550, 0)
dodecaphony 0.2.1
Algorithmic composition of modern classical music in the twelve-tone technique
Requires Python: >=3.9
Keywords: ai_music, algorithmic_composition, atonality, dodecaphony, serialism, twelve_tone

[![Build Status](https://github.com/Nikolay-Lysenko/dodecaphony/actions/workflows/main.yml/badge.svg)](https://github.com/Nikolay-Lysenko/dodecaphony/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/Nikolay-Lysenko/dodecaphony/branch/master/graph/badge.svg)](https://codecov.io/gh/Nikolay-Lysenko/dodecaphony)
[![Maintainability](https://api.codeclimate.com/v1/badges/b83bc51361ac046bc7eb/maintainability)](https://codeclimate.com/github/Nikolay-Lysenko/dodecaphony/maintainability)
[![PyPI version](https://badge.fury.io/py/dodecaphony.svg)](https://pypi.org/project/dodecaphony/)

# Dodecaphony

## Overview

This is a configurable tool that generates music written in [the twelve-tone technique](https://nikolay-lysenko.github.io/2024/04/30/introduction-to-twelve-tone-technique). In short, this means that the output pieces are based on different principles than the vast majority of classical and popular music. If you have never listened to the twelve-tone works, you may find them not ear-pleasant, but, given enough experience, you can change your mind. Twelve-tone music is logic-oriented and has many symmetries, so it is a good choice for combinatorial optimization.

Each run of the tool results in creation of a fragment which can be used as a part of a larger composition. These fragments are stored in separate directories containing:
* MIDI file
* WAV file
* Events file in [sinethesizer](https://github.com/Nikolay-Lysenko/sinethesizer) TSV format
* PDF file with sheet music and its Lilypond source
* YAML file that can be copied to a config for a derivative fragment
* Text file with meta information (such as path to config and evaluation scores)

With this tool, I released a 26-minutes album on Spotify and many other streaming platforms. However, main melodies for the album were written manually by myself and a lot of hard work was done with configs, but, nevertheless, the package really helped to generate background melodies. To read more about the album, please visit its [official page](https://nikolay-lysenko.github.io/2024/05/31/suite-for-virtual-pipe-organ-op1).

## Installation

To install a stable version, run:
```bash
pip install dodecaphony
```

## Usage

To create a new musical fragment, run:
```bash
python -m dodecaphony [-c path_to_config]
```

[Default config](https://github.com/Nikolay-Lysenko/dodecaphony/blob/master/dodecaphony/configs/default_config.yml) is used if `-c` argument is not passed. To create your own config, please look at [this example](https://github.com/Nikolay-Lysenko/dodecaphony/blob/master/docs/config_with_explanations.yml) with detailed explanations. Also, you can read the source code — it is structured and has built-in documentation.

If you are on macOS, please make sure that [parallelism is enabled](https://stackoverflow.com/questions/50168647/multiprocessing-causes-python-to-crash-and-gives-an-error-may-have-been-in-progr).