### Install opstrat Source: https://pypi.org/project/opstrat Use pip to install the opstrat library. ```bash pip install opstrat ``` -------------------------------- ### Installation and Basic Usage Source: https://pypi.org/project/opstrat Instructions on how to install the opstrat library and import it for use, along with a version check. ```APIDOC ## Installation Use the package manager pip to install opstrat. ```python pip install opstrat ``` ## Usage ### Import opstrat ```python import opstrat as op ``` ## Version check ```python op.__version__ ``` If you are using an older version upgrade to the latest package using: ```python pip install opstrat --upgrade ``` ``` -------------------------------- ### Check opstrat version Source: https://pypi.org/project/opstrat Verify the currently installed version of the library. ```python op.__version__ ``` -------------------------------- ### Import opstrat Source: https://pypi.org/project/opstrat Import the library to begin using its visualization functions. ```python import opstrat ``` -------------------------------- ### Plot multi-option strategy with default parameters Source: https://pypi.org/project/opstrat Generate a payoff diagram for a short strangle strategy using default settings. ```python op.multi_plotter() ``` -------------------------------- ### Plot single option with default parameters Source: https://pypi.org/project/opstrat Generate a payoff diagram for a single option using default settings. ```python op.single_plotter() ``` -------------------------------- ### Plot single option with custom parameters Source: https://pypi.org/project/opstrat Generate a payoff diagram for a single option by specifying spot price, strike, type, transaction type, and premium. ```python op.single_plotter(spot=460, strike=460, op_type='p', tr_type='s', op_pr=12.5) ``` -------------------------------- ### Upgrade opstrat Source: https://pypi.org/project/opstrat Update the package to the latest version using pip. ```bash pip install opstrat --upgrade ``` -------------------------------- ### Plot complex multi-option strategy Source: https://pypi.org/project/opstrat Generate a payoff diagram for an Iron Condor strategy by defining a list of option dictionaries. ```python op1={'op_type': 'c', 'strike': 215, 'tr_type': 's', 'op_pr': 7.63} op2={'op_type': 'c', 'strike': 220, 'tr_type': 'b', 'op_pr': 5.35} op3={'op_type': 'p', 'strike': 210, 'tr_type': 's', 'op_pr': 7.20} op4={'op_type': 'p', 'strike': 205, 'tr_type': 'b', 'op_pr': 5.52} op_list=[op1, op2, op3, op4] op.multi_plotter(spot=212.26,spot_range=10, op_list=op_list) ``` -------------------------------- ### Plot Default Strangle on Microsoft Source: https://pypi.org/project/opstrat Generates a default plot for a strangle strategy on Microsoft stock. No specific parameters are required for this basic plot. ```python op.yf_plotter() ``` -------------------------------- ### Save Option Plot to File Source: https://pypi.org/project/opstrat Saves the generated option plot to a file. Set `save=True` and provide a filename with extension to `file`. If `file` is omitted, it defaults to 'fig.png'. ```python op.single_plotter(save=True,file='simple_option.jpeg') ``` -------------------------------- ### multi_plotter() - Plotting Multiple Options Strategies Source: https://pypi.org/project/opstrat This function is used for plotting payoff diagrams involving multiple options, suitable for complex strategies like strangles and iron condors. ```APIDOC ## 2. multi_plotter() Used for plotting a single option ### Parameters - **spot** (int, float, default: 100) - Spot Price. - **spot_range** (int, float, optional, default: 20) - Range of spot variation in percentage. - **op_list** (list of dictionary) - A list of dictionaries, where each dictionary represents an option and must contain the following keys: - **'strike'** (int, float, default: 720) - Strike Price. - **'tr_type'** (kind {'b', 's'}, default:'b') - Transaction Type: 'b' for long, 's' for short. - **'op_pr'** (int, float, default: 10) - Option Price. - **'op_type'** (kind {'c','p'}, default:'c') - Option type: 'c' for call, 'p' for put. ### 2.a Default plot : The short strangle Options trading that involve: (a) selling of a slightly out-of-the-money put and (b) a slightly out-of-the-money call of the same underlying stock and expiration date. spot_range=+/-20% spot=100 Option 1:Short call at strike price 110 op_type: 'c','strike': 110 'tr_type': 's', 'op_pr': 2 Option 2 : Short put at strike price 95 'op_type': 'p', 'strike': 95, 'tr_type': 's', 'op_pr': 6 ```python op.multi_plotter() ``` ### 2.b Example: Iron Condor (Option strategy with 4 options) An iron condor is an options strategy consisting of two puts (one long and one short) and two calls (one long and one short), and four strike prices, all with the same expiration date. stock currently trading at 212.26 (Spot Price) Option 1: Sell a call with a 215 strike, which gives 7.63 in premium Option 2: Buy a call with a strike of 220, which costs 5.35. Option 3: Sell a put with a strike of 210 with premium received 7.20 Option 4: Buy a put with a strike of 205 costing 5.52. ```python op1={'op_type': 'c', 'strike': 215, 'tr_type': 's', 'op_pr': 7.63} op2={'op_type': 'c', 'strike': 220, 'tr_type': 'b', 'op_pr': 5.35} op3={'op_type': 'p', 'strike': 210, 'tr_type': 's', 'op_pr': 7.20} op4={'op_type': 'p', 'strike': 205, 'tr_type': 'b', 'op_pr': 5.52} op_list=[op1, op2, op3, op4] op.multi_plotter(spot=212.26,spot_range=10, op_list=op_list) ``` ``` -------------------------------- ### Plot Strangle on Amazon with Custom Options Source: https://pypi.org/project/opstrat Plots a strangle strategy on Amazon stock with specified option types, strikes, and transaction types. Ensure 'amzn' ticker and 'default' expiration are used. ```python op_1={'op_type': 'c', 'strike':3070, 'tr_type': 'b'} op_2={'op_type': 'p', 'strike':3070, 'tr_type': 'b'} op.yf_plotter(ticker='amzn', exp='default', op_list=[op_1, op_2]) ``` -------------------------------- ### single_plotter() - Plotting Single Option Payoff Source: https://pypi.org/project/opstrat This function is used for plotting the payoff diagram of a single option, allowing customization of various parameters. ```APIDOC ## 1. single_plotter() Used for plotting payoff diagram involving multiple options. ### Parameters - **op_type** (kind {'c','p'}, default:'c') - Option type: 'c' for call, 'p' for put. - **spot** (int, float, default: 100) - Spot Price. - **spot_range** (int, float, optional, default: 5) - Range of spot variation in percentage. - **strike** (int, float, default: 102) - Strike Price. - **tr_type** (kind {'b', 's'}, default:'b') - Transaction Type: 'b' for long, 's' for short. - **op_pr** (int, float, default: 10) - Option Price. ### 1.a Default plot Option type : Call Spot Price : 100 Spot range : +/- 5% Strike price: 102 Position : Long Option Premium: 10 ```python op.single_plotter() ``` Green : Profit Red : Loss ### 1.b Input parameters Strike Price : 450 Spot price : 460 Option type : Put Option Position : Short Option Premium : 12.5 ```python op.single_plotter(spot=460, strike=460, op_type='p', tr_type='s', op_pr=12.5) ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.