mplfinance - 如何在每个烛台顶部显示数字

发布于 01-12 08:53 字数 77 浏览 4 评论 0原文

如何在 mplfinance 上的每个烛台上显示字母或数字?例如,我想在每个烛台顶部显示 0(表示绿色条)和 1(表示红色条),而不是标记。

How can I display letters or numbers on each candle stick on mplfinance? For example, I want to show 0 (for green bars) and 1 (for red bars) on top of each candle stick, instead of marks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

违心°2025-01-19 08:53:23

有多种方法可以做到这一点。您可以使用 Axes.text()Axes.annotate() 来完成此操作,如以下示例所示:

然而,最简单的解决方案可能是 使用mpf.make_addplot() 创建一个 type=scatter 绘图,您希望在其中显示数字,然后传入标记序列marker= kwarg (make_addplot),并使用 数学文本标记 用于标记(例如“$1$”是“1”等)

单击此处获取示例代码。


< em>可能值得一读:

There are a number of ways to do this. You can do it with Axes.text() or with Axes.annotate() as noted in these examples:

However, probably the easiest solution is to use mpf.make_addplot() to create a type=scatter plot where you want the numbers to appear, and then pass in a sequence of markers for the marker= kwarg (of make_addplot), and use Mathtext markers for the markers (for example "$1$" is a '1', etc.)

Click here for example code.


Other discussions that may be worth reading through:

美人骨2025-01-19 08:53:23

根据@Daniel Goldfarb 的帖子,我使用下面的代码在每个烛台顶部显示数字:

apds=[]
data["buy"]= np.where(buy, '$0

假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data) /code>、买入ohlc 信号。
此代码在绿色蜡烛和 顶部以绿色显示 0(颜色代码中的 g 表示 mplfinance 标记颜色中的绿色) >1 红色蜡烛顶部的红色 (r)。

在我看来,最好在绿色蜡烛下方显示 0,为此,您可以将 data['low'] 设置为源而不是 data['high'] 并将 BitcoinbuyCoef 设置为 1.00001(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01。如果您喜欢这个想法,可以使用以下代码:

apds=[]
data["buy"]= np.where(buy, '$0
, 'None')
data["sell"]= np.where(sell, '$1

假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data) /code>、买入ohlc 信号。
此代码在绿色蜡烛和 顶部以绿色显示 0(颜色代码中的 g 表示 mplfinance 标记颜色中的绿色) >1 红色蜡烛顶部的红色 (r)。

在我看来,最好在绿色蜡烛下方显示 0,为此,您可以将 data['low'] 设置为源而不是 data['high'] 并将 BitcoinbuyCoef 设置为 1.00001(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01。如果您喜欢这个想法,可以使用以下代码:


 , 'None')
buyMarker=list(data['buy'].values)
buyColor=['g']*len(data)
sellMarker=list(data['sell'].values)
sellColor=['r']*len(data)
buyCoef = 1.0001
sellCoef = 1.0001
apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor))
apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor))
mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)

假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data) /code>、买入ohlc 信号。
此代码在绿色蜡烛和 顶部以绿色显示 0(颜色代码中的 g 表示 mplfinance 标记颜色中的绿色) >1 红色蜡烛顶部的红色 (r)。

在我看来,最好在绿色蜡烛下方显示 0,为此,您可以将 data['low'] 设置为源而不是 data['high'] 并将 BitcoinbuyCoef 设置为 1.00001(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01。如果您喜欢这个想法,可以使用以下代码:


, 'None')
data["sell"]= np.where(sell, '$1
, 'None')
data["sell"]= np.where(sell, '$1

假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data) /code>、买入ohlc 信号。
此代码在绿色蜡烛和 顶部以绿色显示 0(颜色代码中的 g 表示 mplfinance 标记颜色中的绿色) >1 红色蜡烛顶部的红色 (r)。

在我看来,最好在绿色蜡烛下方显示 0,为此,您可以将 data['low'] 设置为源而不是 data['high'] 并将 BitcoinbuyCoef 设置为 1.00001(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01。如果您喜欢这个想法,可以使用以下代码:


 , 'None')
buyMarker=list(data['buy'].values)
buyColor=['g']*len(data)
sellMarker=list(data['sell'].values)
sellColor=['r']*len(data)
buyCoef = 1.0001
sellCoef = 1.0001
apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor))
apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor))
mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)

假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data) /code>、买入ohlc 信号。
此代码在绿色蜡烛和 顶部以绿色显示 0(颜色代码中的 g 表示 mplfinance 标记颜色中的绿色) >1 红色蜡烛顶部的红色 (r)。

在我看来,最好在绿色蜡烛下方显示 0,为此,您可以将 data['low'] 设置为源而不是 data['high'] 并将 BitcoinbuyCoef 设置为 1.00001(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01。如果您喜欢这个想法,可以使用以下代码:

, 'None') buyMarker=list(data['buy'].values) buyColor=['g']*len(data) sellMarker=list(data['sell'].values) sellColor=['r']*len(data) buyCoef = 1.00001 sellCoef = 1.0001 apds.append(mpf.make_addplot(buyCoef*data['low'],type='scatter',marker=buyMarker,markersize=45,color=buyColor)) apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor)) mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500) , 'None') data["sell"]= np.where(sell, '$1

假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data) /code>、买入ohlc 信号。
此代码在绿色蜡烛和 顶部以绿色显示 0(颜色代码中的 g 表示 mplfinance 标记颜色中的绿色) >1 红色蜡烛顶部的红色 (r)。

在我看来,最好在绿色蜡烛下方显示 0,为此,您可以将 data['low'] 设置为源而不是 data['high'] 并将 BitcoinbuyCoef 设置为 1.00001(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01。如果您喜欢这个想法,可以使用以下代码:

, 'None') buyMarker=list(data['buy'].values) buyColor=['g']*len(data) sellMarker=list(data['sell'].values) sellColor=['r']*len(data) buyCoef = 1.0001 sellCoef = 1.0001 apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor)) apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor)) mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)

假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data) /code>、买入ohlc 信号。
此代码在绿色蜡烛和 顶部以绿色显示 0(颜色代码中的 g 表示 mplfinance 标记颜色中的绿色) >1 红色蜡烛顶部的红色 (r)。

在我看来,最好在绿色蜡烛下方显示 0,为此,您可以将 data['low'] 设置为源而不是 data['high'] 并将 BitcoinbuyCoef 设置为 1.00001(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01。如果您喜欢这个想法,可以使用以下代码:

According to @Daniel Goldfarb's post, I use the below code to display numbers on top of each candle stick:

apds=[]
data["buy"]= np.where(buy, '$0

Suppose you have a pandas data frame (in my example: data) containing the sell, buy, and ohlc signals.
This code displays the 0 by green color (g in color code means green in mplfinance marker's colors) on top of green candles and the 1 by red color(r) on top of red candles.

In my opinion, it's better that display the 0 below the green candles, for this purpose you can set the data['low'] as the source instead of data['high'] and set the buyCoef to 1.00001 for Bitcoin(today's price is 68000) so you can adjust the coefficient according to the price of that currency. For example, if the price of that currency is a two digit, then it becomes its coefficient 1.01. If you'd like this idea you can use the below code:

apds=[]
data["buy"]= np.where(buy, '$0
, 'None')
data["sell"]= np.where(sell, '$1

Suppose you have a pandas data frame (in my example: data) containing the sell, buy, and ohlc signals.
This code displays the 0 by green color (g in color code means green in mplfinance marker's colors) on top of green candles and the 1 by red color(r) on top of red candles.

In my opinion, it's better that display the 0 below the green candles, for this purpose you can set the data['low'] as the source instead of data['high'] and set the buyCoef to 1.00001 for Bitcoin(today's price is 68000) so you can adjust the coefficient according to the price of that currency. For example, if the price of that currency is a two digit, then it becomes its coefficient 1.01. If you'd like this idea you can use the below code:


 , 'None')
buyMarker=list(data['buy'].values)
buyColor=['g']*len(data)
sellMarker=list(data['sell'].values)
sellColor=['r']*len(data)
buyCoef = 1.0001
sellCoef = 1.0001
apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor))
apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor))
mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)

Suppose you have a pandas data frame (in my example: data) containing the sell, buy, and ohlc signals.
This code displays the 0 by green color (g in color code means green in mplfinance marker's colors) on top of green candles and the 1 by red color(r) on top of red candles.

In my opinion, it's better that display the 0 below the green candles, for this purpose you can set the data['low'] as the source instead of data['high'] and set the buyCoef to 1.00001 for Bitcoin(today's price is 68000) so you can adjust the coefficient according to the price of that currency. For example, if the price of that currency is a two digit, then it becomes its coefficient 1.01. If you'd like this idea you can use the below code:


, 'None')
data["sell"]= np.where(sell, '$1
, 'None')
data["sell"]= np.where(sell, '$1

Suppose you have a pandas data frame (in my example: data) containing the sell, buy, and ohlc signals.
This code displays the 0 by green color (g in color code means green in mplfinance marker's colors) on top of green candles and the 1 by red color(r) on top of red candles.

In my opinion, it's better that display the 0 below the green candles, for this purpose you can set the data['low'] as the source instead of data['high'] and set the buyCoef to 1.00001 for Bitcoin(today's price is 68000) so you can adjust the coefficient according to the price of that currency. For example, if the price of that currency is a two digit, then it becomes its coefficient 1.01. If you'd like this idea you can use the below code:


 , 'None')
buyMarker=list(data['buy'].values)
buyColor=['g']*len(data)
sellMarker=list(data['sell'].values)
sellColor=['r']*len(data)
buyCoef = 1.0001
sellCoef = 1.0001
apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor))
apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor))
mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)

Suppose you have a pandas data frame (in my example: data) containing the sell, buy, and ohlc signals.
This code displays the 0 by green color (g in color code means green in mplfinance marker's colors) on top of green candles and the 1 by red color(r) on top of red candles.

In my opinion, it's better that display the 0 below the green candles, for this purpose you can set the data['low'] as the source instead of data['high'] and set the buyCoef to 1.00001 for Bitcoin(today's price is 68000) so you can adjust the coefficient according to the price of that currency. For example, if the price of that currency is a two digit, then it becomes its coefficient 1.01. If you'd like this idea you can use the below code:

, 'None') buyMarker=list(data['buy'].values) buyColor=['g']*len(data) sellMarker=list(data['sell'].values) sellColor=['r']*len(data) buyCoef = 1.00001 sellCoef = 1.0001 apds.append(mpf.make_addplot(buyCoef*data['low'],type='scatter',marker=buyMarker,markersize=45,color=buyColor)) apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor)) mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500) , 'None') data["sell"]= np.where(sell, '$1

Suppose you have a pandas data frame (in my example: data) containing the sell, buy, and ohlc signals.
This code displays the 0 by green color (g in color code means green in mplfinance marker's colors) on top of green candles and the 1 by red color(r) on top of red candles.

In my opinion, it's better that display the 0 below the green candles, for this purpose you can set the data['low'] as the source instead of data['high'] and set the buyCoef to 1.00001 for Bitcoin(today's price is 68000) so you can adjust the coefficient according to the price of that currency. For example, if the price of that currency is a two digit, then it becomes its coefficient 1.01. If you'd like this idea you can use the below code:

, 'None') buyMarker=list(data['buy'].values) buyColor=['g']*len(data) sellMarker=list(data['sell'].values) sellColor=['r']*len(data) buyCoef = 1.0001 sellCoef = 1.0001 apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor)) apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor)) mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)

Suppose you have a pandas data frame (in my example: data) containing the sell, buy, and ohlc signals.
This code displays the 0 by green color (g in color code means green in mplfinance marker's colors) on top of green candles and the 1 by red color(r) on top of red candles.

In my opinion, it's better that display the 0 below the green candles, for this purpose you can set the data['low'] as the source instead of data['high'] and set the buyCoef to 1.00001 for Bitcoin(today's price is 68000) so you can adjust the coefficient according to the price of that currency. For example, if the price of that currency is a two digit, then it becomes its coefficient 1.01. If you'd like this idea you can use the below code:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文