Code Monkey home page Code Monkey logo

advanced-portfolio-construction's Introduction

Notebooks and Code for Advanced Portfolio Construction and Analysis with Python

(c) Vijay Vaidyanathan 2019

These files should be in the same level where you have your data folder.

Please send any comments, bugs (or bug fixes!) to [email protected] and I'll incorporate in the next version.

This is the beta test version v03 19_01_2021

The amendents in v03 with respect to v02 are:

  1. lab_203: to give the width of the rolling window we have to use the number of months. In the previous version there was the number of days written as string but it was not working.

ax = ind_cw.rolling('1825D').apply(erk.sharpe_ratio, raw=True, kwargs={"riskfree_rate":0.03, "periods_per_year":12}).mean(axis=1)["1945":].plot(figsize=(12,5), label="CW", legend=True) ind_ew.rolling('1825D').apply(erk.sharpe_ratio, raw=True, kwargs={"riskfree_rate":0.03, "periods_per_year":12}).mean(axis=1)["1945":].plot(ax=ax, label="EW", legend=True)

====

#=========================
#=========================== #=========================

====

ax = ind_cw.rolling(60).apply(erk.sharpe_ratio, raw=True, kwargs={"riskfree_rate":0.03, "periods_per_year":12}).mean(axis=1)["1945":].plot(figsize=(12,5), label="CW", legend=True) ind_ew.rolling(60).apply(erk.sharpe_ratio, raw=True, kwargs={"riskfree_rate":0.03, "periods_per_year":12}).mean(axis=1)["1945":].plot(ax=ax, label="EW", legend=True)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  1. lab_204: in the weight_cw fuction it was used the less recent information in the rolling window to compute the weights of the portfolio in the back test. Now the function takes the most recent information available.

def weight_cw(r, cap_weights, **kwargs): """ Returns the weights of the CW portfolio based on the time series of capweights """ return cap_weights.loc[r.index[0]]

====

#=========================
#=========================== #=========================

====

def weight_cw(r, cap_weights, **kwargs): """ Returns the weights of the CW portfolio based on the time series of capweights """ return cap_weights.loc[r.index[1]]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

def weight_cw(r, cap_weights, **kwargs): """ Returns the weights of the CW portfolio based on the time series of capweights """ w = cap_weights.loc[r.index[0]] return w/w.sum()

====

#=========================
#=========================== #=========================

====

def weight_cw(r, cap_weights, **kwargs): """ Returns the weights of the CW portfolio based on the time series of capweights """ w = cap_weights.loc[r.index[1]] return w/w.sum()

advanced-portfolio-construction's People

Contributors

mathieu-fortin 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.