added graphing of OSC and CMF
This commit is contained in:
parent
9d844696f9
commit
610029ba94
@ -288,6 +288,25 @@ class Arguments(object):
|
|||||||
default=None
|
default=None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.parser.add_argument(
|
||||||
|
'--plot-osc',
|
||||||
|
help='Renders a osc chart of the given osc dataframe name, for example --plot-osc osc',
|
||||||
|
dest='plotosc',
|
||||||
|
nargs='+',
|
||||||
|
|
||||||
|
default=None
|
||||||
|
)
|
||||||
|
|
||||||
|
self.parser.add_argument(
|
||||||
|
'--plot-cmf',
|
||||||
|
help='Renders a cmf chart of the given cmf dataframe name, for example --plot-cmf cmf',
|
||||||
|
dest='plotcmf',
|
||||||
|
nargs='+',
|
||||||
|
|
||||||
|
default=None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
'--plot-macd',
|
'--plot-macd',
|
||||||
help='Renders a macd chart of the given '
|
help='Renders a macd chart of the given '
|
||||||
|
@ -10,6 +10,22 @@ Optional Cli parameters
|
|||||||
-d / --datadir: path to pair backtest data
|
-d / --datadir: path to pair backtest data
|
||||||
--timerange: specify what timerange of data to use.
|
--timerange: specify what timerange of data to use.
|
||||||
-l / --live: Live, to download the latest ticker for the pair
|
-l / --live: Live, to download the latest ticker for the pair
|
||||||
|
|
||||||
|
--plot-max-ticks N: plot N data points and overwrite the internal 750 cut of
|
||||||
|
|
||||||
|
|
||||||
|
Plotting Subplots, require the name of the dataframe column.
|
||||||
|
|
||||||
|
Each plot will be displayed as usual on exchanges
|
||||||
|
|
||||||
|
--plot-rsi <RSI>
|
||||||
|
--plot-cci <CCI>
|
||||||
|
--plot-osc <CCI>
|
||||||
|
--plot-macd <MACD>
|
||||||
|
--plot-cmf <CMF>
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
"""
|
"""
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
@ -26,9 +42,11 @@ from freqtrade import exchange
|
|||||||
from freqtrade.analyze import Analyze
|
from freqtrade.analyze import Analyze
|
||||||
from freqtrade.arguments import Arguments
|
from freqtrade.arguments import Arguments
|
||||||
from freqtrade.configuration import Configuration
|
from freqtrade.configuration import Configuration
|
||||||
|
from pandas import DataFrame
|
||||||
|
|
||||||
logger = logging.getLogger('freqtrade')
|
logger = logging.getLogger('freqtrade')
|
||||||
|
|
||||||
|
|
||||||
def plot_dataframes_markers(data, fig, args):
|
def plot_dataframes_markers(data, fig, args):
|
||||||
"""
|
"""
|
||||||
plots additional dataframe markers in the main plot
|
plots additional dataframe markers in the main plot
|
||||||
@ -40,7 +58,7 @@ def plot_dataframes_markers(data, fig, args):
|
|||||||
|
|
||||||
if args.plotdataframemarker:
|
if args.plotdataframemarker:
|
||||||
for x in args.plotdataframemarker:
|
for x in args.plotdataframemarker:
|
||||||
filter = data[(data[x] == 100 ) | (data[x] == -100) ]
|
filter = data[(data[x] == 100) | (data[x] == -100)]
|
||||||
marker = go.Scatter(
|
marker = go.Scatter(
|
||||||
x=filter.date,
|
x=filter.date,
|
||||||
y=filter.low * 0.99,
|
y=filter.low * 0.99,
|
||||||
@ -114,6 +132,103 @@ def plot_rsi_dataframe(data, fig, args, plotnumber):
|
|||||||
rsi = go.Scattergl(x=data['date'], y=data[x], name=x)
|
rsi = go.Scattergl(x=data['date'], y=data[x], name=x)
|
||||||
fig.append_trace(rsi, plotnumber, 1)
|
fig.append_trace(rsi, plotnumber, 1)
|
||||||
|
|
||||||
|
fig['layout']['shapes'].append(
|
||||||
|
{
|
||||||
|
'yref': 'y' + str(plotnumber),
|
||||||
|
'fillcolor': 'red',
|
||||||
|
'opacity': 0.1,
|
||||||
|
'type': 'rect',
|
||||||
|
'x0': DataFrame.min(data['date']),
|
||||||
|
'x1': DataFrame.max(data['date']),
|
||||||
|
'y0': 70,
|
||||||
|
'y1': 100,
|
||||||
|
'line': {'color': 'gray'}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
fig['layout']['shapes'].append(
|
||||||
|
{
|
||||||
|
'yref': 'y' + str(plotnumber),
|
||||||
|
'fillcolor': 'green',
|
||||||
|
'opacity': 0.1,
|
||||||
|
'type': 'rect',
|
||||||
|
'x0': DataFrame.min(data['date']),
|
||||||
|
'x1': DataFrame.max(data['date']),
|
||||||
|
'y0': 0,
|
||||||
|
'y1': 30,
|
||||||
|
'line': {'color': 'gray'}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def plot_osc_dataframe(data, fig, args, plotnumber):
|
||||||
|
"""
|
||||||
|
|
||||||
|
this function plots an additional cci chart under the exiting charts
|
||||||
|
:param data:
|
||||||
|
:param fig:
|
||||||
|
:param args:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
if args.plotosc:
|
||||||
|
for x in args.plotosc:
|
||||||
|
chart = go.Scattergl(x=data['date'], y=data[x], name=x)
|
||||||
|
fig.append_trace(chart, plotnumber, 1)
|
||||||
|
|
||||||
|
fig['layout']['shapes'].append(
|
||||||
|
{
|
||||||
|
'yref': 'y' + str(plotnumber),
|
||||||
|
'fillcolor': 'gray',
|
||||||
|
'opacity': 0.1,
|
||||||
|
'type': 'rect',
|
||||||
|
'x0': DataFrame.min(data['date']),
|
||||||
|
'x1': DataFrame.max(data['date']),
|
||||||
|
'y0': 0.3,
|
||||||
|
'y1': 0.7,
|
||||||
|
'line': {'color': 'gray'}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
fig['layout']['shapes'].append(
|
||||||
|
{
|
||||||
|
'yref': 'y' + str(plotnumber),
|
||||||
|
'type': 'line',
|
||||||
|
'x0': DataFrame.min(data['date']),
|
||||||
|
'x1': DataFrame.max(data['date']),
|
||||||
|
'y0': 0.6,
|
||||||
|
'y1': 0.6,
|
||||||
|
'line': {'color': 'red','width': 1}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
fig['layout']['shapes'].append(
|
||||||
|
{
|
||||||
|
'yref': 'y' + str(plotnumber),
|
||||||
|
'type': 'line',
|
||||||
|
'x0': DataFrame.min(data['date']),
|
||||||
|
'x1': DataFrame.max(data['date']),
|
||||||
|
'y0': 0.4,
|
||||||
|
'y1': 0.4,
|
||||||
|
'line': {'color': 'green','width':1}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def plot_cmf_dataframe(data, fig, args, plotnumber):
|
||||||
|
"""
|
||||||
|
|
||||||
|
this function plots an additional cci chart under the exiting charts
|
||||||
|
:param data:
|
||||||
|
:param fig:
|
||||||
|
:param args:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
minValue = 0;
|
||||||
|
maxValue = 0;
|
||||||
|
if args.plotcmf:
|
||||||
|
for x in args.plotcmf:
|
||||||
|
chart = go.Bar(x=data['date'], y=data[x], name=x)
|
||||||
|
fig.append_trace(chart, plotnumber, 1)
|
||||||
|
|
||||||
|
|
||||||
def plot_cci_dataframe(data, fig, args, plotnumber):
|
def plot_cci_dataframe(data, fig, args, plotnumber):
|
||||||
"""
|
"""
|
||||||
@ -124,11 +239,45 @@ def plot_cci_dataframe(data, fig, args, plotnumber):
|
|||||||
:param args:
|
:param args:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
minValue = 0;
|
||||||
|
maxValue = 0;
|
||||||
if args.plotcci:
|
if args.plotcci:
|
||||||
for x in args.plotcci:
|
for x in args.plotcci:
|
||||||
|
if minValue > min(data[x]):
|
||||||
|
minValue = min(data[x])
|
||||||
|
if maxValue < max(data[x]):
|
||||||
|
maxValue = max(data[x])
|
||||||
|
|
||||||
chart = go.Scattergl(x=data['date'], y=data[x], name=x)
|
chart = go.Scattergl(x=data['date'], y=data[x], name=x)
|
||||||
fig.append_trace(chart, plotnumber, 1)
|
fig.append_trace(chart, plotnumber, 1)
|
||||||
|
|
||||||
|
fig['layout']['shapes'].append(
|
||||||
|
{
|
||||||
|
'yref': 'y' + str(plotnumber),
|
||||||
|
'fillcolor': 'red',
|
||||||
|
'opacity': 0.1,
|
||||||
|
'type': 'rect',
|
||||||
|
'x0': DataFrame.min(data['date']),
|
||||||
|
'x1': DataFrame.max(data['date']),
|
||||||
|
'y0': 100,
|
||||||
|
'y1': maxValue,
|
||||||
|
'line': {'color': 'gray'}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
fig['layout']['shapes'].append(
|
||||||
|
{
|
||||||
|
'yref': 'y' + str(plotnumber),
|
||||||
|
'fillcolor': 'green',
|
||||||
|
'opacity': 0.1,
|
||||||
|
'type': 'rect',
|
||||||
|
'x0': DataFrame.min(data['date']),
|
||||||
|
'x1': DataFrame.max(data['date']),
|
||||||
|
'y0': -100,
|
||||||
|
'y1': minValue,
|
||||||
|
'line': {'color': 'gray'}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def plot_stop_loss_trade(df_sell, fig, analyze, args):
|
def plot_stop_loss_trade(df_sell, fig, analyze, args):
|
||||||
@ -285,7 +434,7 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
|
|||||||
|
|
||||||
buys = go.Scattergl(
|
buys = go.Scattergl(
|
||||||
x=df_buy.date,
|
x=df_buy.date,
|
||||||
y=df_buy.close * 0.995,
|
y=df_buy.close,
|
||||||
mode='markers',
|
mode='markers',
|
||||||
name='buy',
|
name='buy',
|
||||||
marker=dict(
|
marker=dict(
|
||||||
@ -299,7 +448,7 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
|
|||||||
|
|
||||||
sells = go.Scatter(
|
sells = go.Scatter(
|
||||||
x=df_sell.date,
|
x=df_sell.date,
|
||||||
y=df_sell.close * 1.01,
|
y=df_sell.close,
|
||||||
mode='markers+text',
|
mode='markers+text',
|
||||||
name='sell',
|
name='sell',
|
||||||
text=df_sell.profit,
|
text=df_sell.profit,
|
||||||
@ -346,6 +495,10 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
|
|||||||
rowWidth.append(1)
|
rowWidth.append(1)
|
||||||
if args.plotcci:
|
if args.plotcci:
|
||||||
rowWidth.append(1)
|
rowWidth.append(1)
|
||||||
|
if args.plotcmf:
|
||||||
|
rowWidth.append(1)
|
||||||
|
if args.plotosc:
|
||||||
|
rowWidth.append(1)
|
||||||
|
|
||||||
# standard layout signal + volume
|
# standard layout signal + volume
|
||||||
fig = tools.make_subplots(
|
fig = tools.make_subplots(
|
||||||
@ -397,6 +550,16 @@ def plot_analyzed_dataframe(args: Namespace) -> None:
|
|||||||
plot_cci_dataframe(data, fig, args, subplots)
|
plot_cci_dataframe(data, fig, args, subplots)
|
||||||
fig['layout']['yaxis' + str(subplots)].update(title='CCI')
|
fig['layout']['yaxis' + str(subplots)].update(title='CCI')
|
||||||
|
|
||||||
|
if args.plotosc:
|
||||||
|
subplots = subplots + 1
|
||||||
|
plot_osc_dataframe(data, fig, args, subplots)
|
||||||
|
fig['layout']['yaxis' + str(subplots)].update(title='OSC')
|
||||||
|
|
||||||
|
if args.plotcmf:
|
||||||
|
subplots = subplots + 1
|
||||||
|
plot_cmf_dataframe(data, fig, args, subplots)
|
||||||
|
fig['layout']['yaxis' + str(subplots)].update(title='CMF')
|
||||||
|
|
||||||
# updated all the
|
# updated all the
|
||||||
|
|
||||||
plot(fig, filename='freqtrade-plot.html')
|
plot(fig, filename='freqtrade-plot.html')
|
||||||
|
Loading…
Reference in New Issue
Block a user