rkohli3 / tsmom Goto Github PK
View Code? Open in Web Editor NEWReplication of Time Series Momentum strategy by Moskowtiz, Ooi, Pedersen, 2011.
Replication of Time Series Momentum strategy by Moskowtiz, Ooi, Pedersen, 2011.
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.