Coder Social home page Coder Social logo

mapping's Introduction

mapping

PyPI version Build Status Coverage Status

Description

mapping provides functionality for mapping to and from generic exposures and tradeable instruments for financial assets.

An example of this might be on 2016-12-01 we would have CL1 -> CLZ16, i.e. the first generic for Crude oil on the above date corresponds to trading the December 2016 contract.

The main features of mapping include:

  • creating continuous return series for Futures instruments
  • creating time series of percentage allocations to tradeable contracts
  • creating instrument trade lists

Currently there is no support for indexing/futures instrument rescaling, e.g. what happened to the VIX, discussed here. This should accounted for by rescaling the instrument data upstream of using mapping

Details

The mapping of instruments to and from generics is equivalent to solving the equation Ax = b where A is the weights and b is the instrument holdings. When Ax = b has no solution we solve for x' such that Ax' is closest to b in the least squares sense with the additional constraint that sum(x') = sum(instruments).

A more realistic example of a mapping is given below

Generic Instruments
CL1 CL2 Scenario 1 Scenario 2 Scenario 3
CLX16 0.5 0 10 10 10
CLZ16 0.5 0.5 20 20 25
CLF17 0 0.5 10 11 11

Which would result in the following solutions to the mapping from instruments to generics

Generic Scenario 1 Scenario 2 Scenario 3
CL1 20 19.5 22
CL2 20 21.5 24

Usage

A general workflow for using mapping for mapping from generics to tradeable instruments is as follows

workflow

The layout for mapping from tradeables to generics is as follows

workflow

Install

You can pip install this package from github, i.e.

pip install git+git://github.com/matthewgilbert/mapping.git@master

mapping is also available on PyPI, you can pip install the latest version using

pip install mapping

mapping's People

Contributors

matthewgilbert 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.