Back

Indicator Research Template

Here is a QuantBook research template on indicators. We can use this template to select and display indicators. We can also annotate trading signals on the charts so as to have a better understanding of how the indicators actually work.

Update Backtest








0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


However, it is very likely to come across overfitting problems when using indicators. Here is an example which might be likely to have an overfitting problem.

0


Hi,

 

I've been looking to join the indicator information with the data. this post seems to be doing that. however when I'm running the exact same code after I clode, I'm getting an error. It seems a real nuissance that the types we're working with are not dataframes. Could I get any help with this? thanks

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-e930ac87de9f> in <module>
4 df2['nextdayreturn'] = df2.close.shift(-1)/df2.close
5 # Merge return series with indicators
----> 6 df2 = df2.merge(bbdf,how="left",left_index=True, right_index=True)
7 df2 = df2.merge(macddf,how="left",left_index=True, right_index=True)
8 df2 = df2.merge(rsidf,how="left",left_index=True, right_index=True)

/opt/miniconda3/lib/python3.6/site-packages/pandas/core/frame.py in merge(self, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
6387 right_on=right_on, left_index=left_index,
6388 right_index=right_index, sort=sort, suffixes=suffixes,
-> 6389 copy=copy, indicator=indicator, validate=validate)
6390
6391 def round(self, decimals=0, *args, **kwargs):

/opt/miniconda3/lib/python3.6/site-packages/pandas/core/reshape/merge.py in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
60 copy=copy, indicator=indicator,
61 validate=validate)
---> 62 return op.get_result()
63
64

/opt/miniconda3/lib/python3.6/site-packages/pandas/core/reshape/merge.py in get_result(self)
566 self.left, self.right)
567
--> 568 join_index, left_indexer, right_indexer = self._get_join_info()
569
570 ldata, rdata = self.left._data, self.right._data

/opt/miniconda3/lib/python3.6/site-packages/pandas/core/reshape/merge.py in _get_join_info(self)
763 join_index, left_indexer, right_indexer = \
764 left_ax.join(right_ax, how=self.how, return_indexers=True,
--> 765 sort=self.sort)
766 elif self.right_index and self.how == 'left':
767 join_index, left_indexer, right_indexer = \

TypeError: join() got an unexpected keyword argument 'return_indexers'

 

 

 

 

0

Hi Jens,

This old template needs some updates to work properly. First we need to change the way we're defining df2. Instead of constructing df2 with df.close, let's create a blank dataframe and populate it.

# Put asset and indicators into a new dataframe
df2 = pd.DataFrame()

# Suppose we want to predict tomorrow's return
df2['nextdayreturn'] = df.close.shift(-1)/df.close

Next, we'll also need to update a column's name.

df2['macd>0'] = (df2.signal > 0)*1.0

needs to be updated to

df2['macd>0'] = (df2.movingaverageconvergencedivergence > 0)*1.0

Best
Rahul

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Rahul,

I'm unable to get your code to run.  When I clone and try I get

FileNotFoundException Traceback (most recent call last)
<ipython-input-1-b176378fef3c> in <module>
4 AddReference("System")
5 AddReference("QuantConnect.Common")
----> 6 AddReference("QuantConnect.Jupyter")
7 AddReference("QuantConnect.Indicators")
8 from System import *

FileNotFoundException: Unable to find assembly 'QuantConnect.Jupyter'.
at Python.Runtime.CLRModule.AddReference (System.String name) [0x00072] in <53bf9f243db14559b291c5af7e1f629f>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0

If I remove the references to Jupyter, it works.  But then when I attempt to plot I get  epoch2num deprecation warning and image size too large error.

/opt/miniconda3/lib/python3.6/site-packages/pandas/plotting/_matplotlib/converter.py:245: MatplotlibDeprecationWarning:
The epoch2num function was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
base = dates.epoch2num(dt.asi8 / 1.0e9)
<Figure size 432x288 with 0 Axes>
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/opt/miniconda3/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
339 pass
340 else:
--> 341 return printer(obj)
342 # Finally look for special method names
343 method = get_real_method(obj, self.print_method)

...................... truncated.

ValueError: Image size of 21462365x376 pixels is too large. It must be less than 2^16 in each direction.

<Figure size 576x432 with 1 Axes>

 

0

Hi Ju,

To resolve the first error explained above, we need to replace

AddReference("QuantConnect.Jupyter")
from QuantConnect.Jupyter import *

with

AddReference("QuantConnect.Research")
from QuantConnect.Research import *

After making this change, the last cell in the notebook still throws an error. To resolve this one, we just need to decrease `plotto` from

plotto = "2015-6-15"

to

plotto = "2015-6-6"

See the attached notebook for reference.

Best,
Derek Melchin

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


That works great. Thank you.

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed