Add better hover tip
This commit is contained in:
parent
e0a1e5417f
commit
b1a01345f9
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
import arrow
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -12,7 +13,7 @@ try:
|
|||||||
import plotly.graph_objs as go
|
import plotly.graph_objs as go
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.exception("Module plotly not found \n Please install using `pip install plotly`")
|
logger.exception("Module plotly not found \n Please install using `pip install plotly`")
|
||||||
exit()
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def generate_row(fig, row, indicators: List[str], data: pd.DataFrame) -> tools.make_subplots:
|
def generate_row(fig, row, indicators: List[str], data: pd.DataFrame) -> tools.make_subplots:
|
||||||
@ -25,9 +26,10 @@ def generate_row(fig, row, indicators: List[str], data: pd.DataFrame) -> tools.m
|
|||||||
"""
|
"""
|
||||||
for indicator in indicators:
|
for indicator in indicators:
|
||||||
if indicator in data:
|
if indicator in data:
|
||||||
scattergl = go.Scattergl(
|
# TODO: Figure out why scattergl causes problems
|
||||||
|
scattergl = go.Scatter(
|
||||||
x=data['date'],
|
x=data['date'],
|
||||||
y=data[indicator],
|
y=data[indicator].values,
|
||||||
mode='lines',
|
mode='lines',
|
||||||
name=indicator
|
name=indicator
|
||||||
)
|
)
|
||||||
@ -60,9 +62,14 @@ def plot_trades(fig, trades: pd.DataFrame):
|
|||||||
color='green'
|
color='green'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
# Create description for sell summarizing the trade
|
||||||
|
desc = trades.apply(lambda row: f"{round(row['profitperc'], 3)}%, {row['sell_reason']}, "
|
||||||
|
f"{row['duration']}min",
|
||||||
|
axis=1)
|
||||||
trade_sells = go.Scatter(
|
trade_sells = go.Scatter(
|
||||||
x=trades["close_time"],
|
x=trades["close_time"],
|
||||||
y=trades["close_rate"],
|
y=trades["close_rate"],
|
||||||
|
text=desc,
|
||||||
mode='markers',
|
mode='markers',
|
||||||
name='trade_sell',
|
name='trade_sell',
|
||||||
marker=dict(
|
marker=dict(
|
||||||
@ -123,7 +130,7 @@ def generate_graph(
|
|||||||
if 'buy' in data.columns:
|
if 'buy' in data.columns:
|
||||||
df_buy = data[data['buy'] == 1]
|
df_buy = data[data['buy'] == 1]
|
||||||
if len(df_buy) > 0:
|
if len(df_buy) > 0:
|
||||||
buys = go.Scattergl(
|
buys = go.Scatter(
|
||||||
x=df_buy.date,
|
x=df_buy.date,
|
||||||
y=df_buy.close,
|
y=df_buy.close,
|
||||||
mode='markers',
|
mode='markers',
|
||||||
@ -142,7 +149,7 @@ def generate_graph(
|
|||||||
if 'sell' in data.columns:
|
if 'sell' in data.columns:
|
||||||
df_sell = data[data['sell'] == 1]
|
df_sell = data[data['sell'] == 1]
|
||||||
if len(df_sell) > 0:
|
if len(df_sell) > 0:
|
||||||
sells = go.Scattergl(
|
sells = go.Scatter(
|
||||||
x=df_sell.date,
|
x=df_sell.date,
|
||||||
y=df_sell.close,
|
y=df_sell.close,
|
||||||
mode='markers',
|
mode='markers',
|
||||||
|
@ -216,7 +216,7 @@ def analyse_and_plot_pairs(args: Namespace):
|
|||||||
tickers[pair] = data
|
tickers[pair] = data
|
||||||
dataframe = generate_dataframe(strategy, tickers, pair)
|
dataframe = generate_dataframe(strategy, tickers, pair)
|
||||||
|
|
||||||
trades = load_trades(pair, db_url=args.db_url,
|
trades = load_trades(db_url=args.db_url,
|
||||||
exportfilename=args.exportfilename)
|
exportfilename=args.exportfilename)
|
||||||
trades = trades.loc[trades['pair'] == pair]
|
trades = trades.loc[trades['pair'] == pair]
|
||||||
trades = extract_trades_of_period(dataframe, trades)
|
trades = extract_trades_of_period(dataframe, trades)
|
||||||
|
Loading…
Reference in New Issue
Block a user