Currently I have daily data. I know how to resample it to weekly, monthly, yearly, etc. However, I only want to use it in indicator calculation. I do not want to plot the resampled data. How do I do it?

Latest posts made by Kristofer Monisit
-
Resample data but do not plot it
-
How do I access the Trade object from within the next() method of Strategy?
I would like to keep track of the time I am currently in the trade. I know that the trade object has a
barlen
attribute. I would like to check for it in thenext()
method of the Strategy. How do I do it? -
RE: An indicator that knows if I have a position or not
@momentum Thanks! I would add that
Cerebro
will have to be instantiated withCerebro(runonce=False)
. Otherwise, if I use the default, i.e.runonce=True
, all indicators would be precalculated all the way to the end, and they would not be able to observe if a trade is open or not.Reference for the
runonce
argument:
https://www.backtrader.com/docu/cerebro.html?highlight=vectorize#backtrader.Cerebro -
An indicator that knows if I have a position or not
I am building an indicator that does one thing if I'm not in the trade, and does another if I'm in.
Is it possible for a subclass of
Indicators
to access theposition
attribute of theStrategy
?Of course, this indicator cannot be pre-computed, but is emits data as the backtest progresses.
The following code surely raises
AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Indicat' object has no attribute 'position'
class CustomIndicator(bt.Indicator): lines = ('custom_indicator',) params = (('period', 14), ) def next(self): if self.position: self.lines.custom_indicator[0] = True and is_something_else_true() self.do_something() else: self.lines.custom_indicator[0] = False self.do_nothing()
-
RE: Volume plot of PandasData uses the whole DataFrame as legend label
I tried it again with a pristine installation of backtrader (
pip install backtrader
). With the defaults, it's OK, but withvoloverlay=False
, the entire DataFrame is printed.
-
Volume plot of PandasData uses the whole DataFrame as legend label
I have the following DataFrame
Then add it to
cerebro
and plot it:
But the volume plot prints out the whole DataFrame as the legend label:
How do I fix this?
-
RE: How to remove frame around the plot in Jupyter Notebook
I have filed a pull request to do this: https://github.com/backtrader/backtrader/pull/384
-
How to remove frame around the plot in Jupyter Notebook
How do I remove the frame around the plot in Jupyter Notebook? I do not need the interactive buttons.