mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2025-12-24 00:34:23 +01:00
(feat) format visualizations
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from plotly.subplots import make_subplots
|
from plotly.subplots import make_subplots
|
||||||
from frontend.visualization.candles import get_bt_candlestick_trace, get_candlestick_trace
|
|
||||||
|
from frontend.visualization.candles import get_bt_candlestick_trace
|
||||||
from frontend.visualization.executors import add_executors_trace
|
from frontend.visualization.executors import add_executors_trace
|
||||||
from frontend.visualization.pnl import get_pnl_trace
|
from frontend.visualization.pnl import get_pnl_trace
|
||||||
from frontend.visualization.theme import get_default_layout
|
from frontend.visualization.theme import get_default_layout
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ def render_accuracy_metrics(summary_results):
|
|||||||
st.metric(label="Accuracy Long", value=f"{accuracy_long:.2%}")
|
st.metric(label="Accuracy Long", value=f"{accuracy_long:.2%}")
|
||||||
st.metric(label="Accuracy Short", value=f"{accuracy_short:.2%}")
|
st.metric(label="Accuracy Short", value=f"{accuracy_short:.2%}")
|
||||||
|
|
||||||
|
|
||||||
def render_accuracy_metrics2(summary_results):
|
def render_accuracy_metrics2(summary_results):
|
||||||
accuracy = summary_results.get('accuracy', 0)
|
accuracy = summary_results.get('accuracy', 0)
|
||||||
total_long = summary_results.get('total_long', 0)
|
total_long = summary_results.get('total_long', 0)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import plotly.graph_objects as go
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
import plotly.graph_objects as go
|
||||||
|
|
||||||
from frontend.visualization import theme
|
from frontend.visualization import theme
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ def get_candlestick_trace(df):
|
|||||||
low=df['low'],
|
low=df['low'],
|
||||||
close=df['close'],
|
close=df['close'],
|
||||||
name="Candlesticks",
|
name="Candlesticks",
|
||||||
increasing_line_color='#2ECC71', decreasing_line_color='#E74C3C',)
|
increasing_line_color='#2ECC71', decreasing_line_color='#E74C3C', )
|
||||||
|
|
||||||
|
|
||||||
def get_bt_candlestick_trace(df):
|
def get_bt_candlestick_trace(df):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from decimal import Decimal
|
|
||||||
import plotly.graph_objects as go
|
import plotly.graph_objects as go
|
||||||
from plotly.subplots import make_subplots
|
from plotly.subplots import make_subplots
|
||||||
|
|
||||||
import frontend.visualization.theme as theme
|
import frontend.visualization.theme as theme
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import plotly.graph_objects as go
|
import plotly.graph_objects as go
|
||||||
|
|
||||||
import frontend.visualization.theme as theme
|
import frontend.visualization.theme as theme
|
||||||
|
|
||||||
|
|
||||||
def create_executors_distribution_traces(buy_spreads, sell_spreads, buy_amounts_pct, sell_amounts_pct, total_amount_quote):
|
def create_executors_distribution_traces(buy_spreads, sell_spreads, buy_amounts_pct, sell_amounts_pct,
|
||||||
|
total_amount_quote):
|
||||||
colors = theme.get_color_scheme()
|
colors = theme.get_color_scheme()
|
||||||
|
|
||||||
buy_spread_distributions = [spread * 100 for spread in buy_spreads]
|
buy_spread_distributions = [spread * 100 for spread in buy_spreads]
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ def get_bbands_traces(df, bb_length, bb_std):
|
|||||||
|
|
||||||
def get_volume_trace(df):
|
def get_volume_trace(df):
|
||||||
df.index = pd.to_datetime(df.timestamp, unit='s')
|
df.index = pd.to_datetime(df.timestamp, unit='s')
|
||||||
return go.Bar(x=df.index, y=df['volume'], name="Volume", marker_color=theme.get_color_scheme()["volume"], opacity=0.7)
|
return go.Bar(x=df.index, y=df['volume'], name="Volume", marker_color=theme.get_color_scheme()["volume"],
|
||||||
|
opacity=0.7)
|
||||||
|
|
||||||
|
|
||||||
def get_macd_traces(df, macd_fast, macd_slow, macd_signal):
|
def get_macd_traces(df, macd_fast, macd_slow, macd_signal):
|
||||||
tech_colors = theme.get_color_scheme()
|
tech_colors = theme.get_color_scheme()
|
||||||
@@ -38,7 +40,8 @@ def get_macd_traces(df, macd_fast, macd_slow, macd_signal):
|
|||||||
go.Scatter(x=df.index, y=df[macd_s], line=dict(color=tech_colors['macd_signal']),
|
go.Scatter(x=df.index, y=df[macd_s], line=dict(color=tech_colors['macd_signal']),
|
||||||
name='MACD Signal'),
|
name='MACD Signal'),
|
||||||
go.Bar(x=df.index, y=df[macd_hist], name='MACD Histogram',
|
go.Bar(x=df.index, y=df[macd_hist], name='MACD Histogram',
|
||||||
marker_color=df[f"MACDh_{macd_fast}_{macd_slow}_{macd_signal}"].apply(lambda x: '#FF6347' if x < 0 else '#32CD32'))
|
marker_color=df[f"MACDh_{macd_fast}_{macd_slow}_{macd_signal}"].apply(
|
||||||
|
lambda x: '#FF6347' if x < 0 else '#32CD32'))
|
||||||
]
|
]
|
||||||
return traces
|
return traces
|
||||||
|
|
||||||
@@ -79,4 +82,3 @@ def get_supertrend_traces(df, length, multiplier):
|
|||||||
]
|
]
|
||||||
|
|
||||||
return traces
|
return traces
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from frontend.visualization import theme
|
|
||||||
import plotly.graph_objects as go
|
|
||||||
import pandas_ta as ta # noqa: F401
|
import pandas_ta as ta # noqa: F401
|
||||||
|
import plotly.graph_objects as go
|
||||||
|
|
||||||
|
from frontend.visualization import theme
|
||||||
|
|
||||||
|
|
||||||
def get_signal_traces(buy_signals, sell_signals):
|
def get_signal_traces(buy_signals, sell_signals):
|
||||||
@@ -15,6 +16,7 @@ def get_signal_traces(buy_signals, sell_signals):
|
|||||||
]
|
]
|
||||||
return traces
|
return traces
|
||||||
|
|
||||||
|
|
||||||
def get_bollinger_v1_signal_traces(df, bb_length, bb_std, bb_long_threshold, bb_short_threshold):
|
def get_bollinger_v1_signal_traces(df, bb_length, bb_std, bb_long_threshold, bb_short_threshold):
|
||||||
# Add Bollinger Bands
|
# Add Bollinger Bands
|
||||||
candles = df.copy()
|
candles = df.copy()
|
||||||
@@ -29,7 +31,6 @@ def get_bollinger_v1_signal_traces(df, bb_length, bb_std, bb_long_threshold, bb_
|
|||||||
|
|
||||||
def get_macdbb_v1_signal_traces(df, bb_length, bb_std, bb_long_threshold, bb_short_threshold, macd_fast, macd_slow,
|
def get_macdbb_v1_signal_traces(df, bb_length, bb_std, bb_long_threshold, bb_short_threshold, macd_fast, macd_slow,
|
||||||
macd_signal):
|
macd_signal):
|
||||||
tech_colors = theme.get_color_scheme()
|
|
||||||
# Add Bollinger Bands
|
# Add Bollinger Bands
|
||||||
df.ta.bbands(length=bb_length, std=bb_std, append=True)
|
df.ta.bbands(length=bb_length, std=bb_std, append=True)
|
||||||
# Add MACD
|
# Add MACD
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
def add_traces_to_fig(fig, traces, row=1, col=1):
|
def add_traces_to_fig(fig, traces, row=1, col=1):
|
||||||
for trace in traces:
|
for trace in traces:
|
||||||
fig.add_trace(trace, row=row, col=col)
|
fig.add_trace(trace, row=row, col=col)
|
||||||
|
|||||||
Reference in New Issue
Block a user