GithubHelp home page GithubHelp logo

quantitativehedging's Introduction

Quantitative Hedging

Contents

Overview

The Quantitative Hedging repository provides an easy way to hedge a stock using a basket of other stocks which collectively behave as a hedge against the desired stock. The repo is intended for two types of users: (1) market makers who need to offset the risk derived from undesired inventory and (2) quantitative researchers who need to identify factors or replicate studies involving the performance of a security, portfolio, or hedge fund.

Dependencies

Trading Baskets requires the following libraries:

Install these libraries using pip with requirements.txt:

pip install -r requirements.txt

Usage

This repo exports one public functions (in hedge.py) build_basket which builds the basket of stocks intended to hedge a desired stock.

build_basket()

Use build_basket() to compose a hedging basket from (1) the stock to be hedged (hedged_ticker_symbol) and (2) the ticker symbols to consider including in the hedging basket (basket_ticker_symbols):

 basket(build_basket, basket_ticker_symbols)

The basket() arguments are as follows:

Name Type Description Optional? Sample Value
hedged_ticker_symbol str The stock-ticker name of the stock to be hedged. No "AAPL"
basket_ticker_symbols list A list of ticker symbols the library will consider including in the hedging basket. No ["GOOG", "MSFT", "NFLX", "AMZN", "FB"]

Example

The code below shows how to hedge a stock. The code defines APPL (Apple) as the stock to hedge, a list of stocks to consider using as part of the hedge (GOOG, MSFT, NFLX, AMZN, and FB), and composes a corresponding hedge basket for AAPL.

from hedge import build_basket

hedged_ticker_symbol = "AAPL"
basket_ticker_symbols = ["GOOG", "MSFT", "NFLX", "AMZN", "FB"]
print("Hedge for %s:" % hedged_ticker_symbol)
print(build_basket(hedged_ticker_symbol, basket_ticker_symbols))

This will produce the following hedging basket:

{'AAPL': 0.2614353523521262, 'FB': 0.1921680128468791, 'AMZN': 0.5463966348009947}

i.e. AAPL with weight 27%, FB with weight 19%, and AMZN with weight 54%.

A snippet like this can be incorporated in any Python application.

License

Trading Baskets is licensed under the Apache License 2.0.

Links

quantitativehedging's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.