GithubHelp home page GithubHelp logo

rkohli3 / tsmom Goto Github PK

View Code? Open in Web Editor NEW
52.0 52.0 39.0 32.13 MB

Replication of Time Series Momentum strategy by Moskowtiz, Ooi, Pedersen, 2011.

Python 0.37% Jupyter Notebook 99.50% CSS 0.14%

tsmom's People

Contributors

rkohli3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tsmom's Issues

Include spy1985.csv

Hello,

Thank you for amazing work.. I am relativley new to quant python and trying to learn following along your work.
You are missing some data files that are used in this program like spy 1985 csv.

Would you be so kind including all data files or instructions how to generate them?
Thabks

Cannot concatenate object

Hello,
Thank you so much for this amazing code.
I was trying to apply it and I came up with an issue I am having a hard time to solve. When I try to run

unlevered = get_tsmom_port(mnth_vol, mnth_cum)

I get this error:
TypeError Traceback (most recent call last)
/tmp/ipykernel_1372/2551585938.py in
----> 1 unlevered = get_tsmom_port(mnth_vol, mnth_cum)

~/code/mdayoub493/grimper/notebooks/trading_strategies/TSMOM/tsmom.py in get_tsmom_port(mnth_vol, mnth_cum, flag, scale, lookback)
666
667 def get_tsmom_port(mnth_vol, mnth_cum, flag = False, scale = 0.2, lookback = 12):
--> 668 port_long, port_short, leverage = get_tsmom(mnth_vol,
669 mnth_cum,
670 flag = flag,

~/code/mdayoub493/grimper/notebooks/trading_strategies/TSMOM/tsmom.py in get_tsmom(mnth_vol, mnth_cum, flag, scale, lookback)
645 def get_tsmom(mnth_vol, mnth_cum, flag = False, scale = 0.20, lookback = 12):
646 total = mnth_cum.apply(lambda x: tsmom(x, mnth_vol, mnth_cum, scale = scale, vol_flag= flag, lookback= lookback))
--> 647 pnl_long = pd.concat([i[0] for i in total], axis = 1, ignore_index=True)
648 pnl_short = pd.concat([i[1] for i in total], axis = 1, ignore_index=True)
649 lev = pd.concat([i[2] for i in total], axis = 1, ignore_index=True)

~/.pyenv/versions/3.8.12/envs/lewagon/lib/python3.8/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)
312
313 return wrapper

~/.pyenv/versions/3.8.12/envs/lewagon/lib/python3.8/site-packages/pandas/core/reshape/concat.py in concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
292 ValueError: Indexes have overlapping values: ['a']
293 """
--> 294 op = _Concatenator(
295 objs,
296 axis=axis,

~/.pyenv/versions/3.8.12/envs/lewagon/lib/python3.8/site-packages/pandas/core/reshape/concat.py in init(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort)
382 "only Series and DataFrame objs are valid"
383 )
--> 384 raise TypeError(msg)
385
386 ndims.add(obj.ndim)

TypeError: cannot concatenate object of type '<class 'str'>'; only Series and DataFrame objs are valid

Apparently, it is not being able to concatenate pnl_long (I believe there will be the same issue for pnl_short and lev.

Have you ever seen this problem before? Could you help me, please?

Thank you so much!

Best

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.