<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>hongkongpay.dao</title>
        <link>https://paragraph.com/@hongkongpay-dao</link>
        <description>You can use cryptocurrency to pay to the address: hongkongpay.dao [donate BTC, Eth, LTC, XRP, XLM, Ray, Sol, Matic] to support this project</description>
        <lastBuildDate>Fri, 24 Jul 2026 00:39:05 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>hongkongpay.dao</title>
            <url>https://storage.googleapis.com/papyrus_images/a6eda7709f2fac99302b063db1c1933427a6369fef7aa08e21d631a9b698d7d9.png</url>
            <link>https://paragraph.com/@hongkongpay-dao</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[基于Binance SDK的BTC 1小时趋势策略，策略使用了KDJ、RSI、OVB指标]]></title>
            <link>https://paragraph.com/@hongkongpay-dao/binance-sdk-btc-1-kdj-rsi-ovb</link>
            <guid>AODjkvpOG8VPr6JFo8gW</guid>
            <pubDate>Wed, 26 Apr 2023 13:41:59 GMT</pubDate>
            <description><![CDATA[import time from binance.client import Client import numpy as np import talib设置Binance API key和secretapi_key = &apos;YOUR_API_KEY&apos; api_secret = &apos;YOUR_API_SECRET&apos;创建Binance客户端client = Client(api_key, api_secret)定义指标计算函数def calculate_indicators(klines): closes = np.array([float(kline[4]) for kline in klines])# 计算KDJ指标 high_prices = np.array([float(kline[2]) for kline in klines]) low_prices = np.array([float(kline[3]) for kline in klines]) close_prices = np.array([float(kline[4]) f...]]></description>
            <content:encoded><![CDATA[<p>import time from binance.client import Client import numpy as np import talib</p><h1 id="h-binance-api-keysecret" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">设置Binance API key和secret</h1><p>api_key = &apos;YOUR_API_KEY&apos; api_secret = &apos;YOUR_API_SECRET&apos;</p><h1 id="h-binance" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">创建Binance客户端</h1><p>client = Client(api_key, api_secret)</p><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">定义指标计算函数</h1><p>def calculate_indicators(klines): closes = np.array([float(kline[4]) for kline in klines])</p><pre data-type="codeBlock" text="# 计算KDJ指标
high_prices = np.array([float(kline[2]) for kline in klines])
low_prices = np.array([float(kline[3]) for kline in klines])
close_prices = np.array([float(kline[4]) for kline in klines])
k, d = talib.STOCH(high_prices, low_prices, close_prices, fastk_period=9, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0)
j = 3 * k - 2 * d

# 计算RSI指标
rsi = talib.RSI(closes, timeperiod=14)

# 计算OVB指标
obv = talib.OBV(closes, np.array([float(kline[5]) for kline in klines]))

return k, d, j, rsi, obv
"><code># 计算KDJ指标
high_prices <span class="hljs-operator">=</span> np.array([float(kline[<span class="hljs-number">2</span>]) <span class="hljs-keyword">for</span> kline in klines])
low_prices <span class="hljs-operator">=</span> np.array([float(kline[<span class="hljs-number">3</span>]) <span class="hljs-keyword">for</span> kline in klines])
close_prices <span class="hljs-operator">=</span> np.array([float(kline[<span class="hljs-number">4</span>]) <span class="hljs-keyword">for</span> kline in klines])
k, d <span class="hljs-operator">=</span> talib.STOCH(high_prices, low_prices, close_prices, fastk_period<span class="hljs-operator">=</span><span class="hljs-number">9</span>, slowk_period<span class="hljs-operator">=</span><span class="hljs-number">3</span>, slowk_matype<span class="hljs-operator">=</span><span class="hljs-number">0</span>, slowd_period<span class="hljs-operator">=</span><span class="hljs-number">3</span>, slowd_matype<span class="hljs-operator">=</span><span class="hljs-number">0</span>)
j <span class="hljs-operator">=</span> <span class="hljs-number">3</span> <span class="hljs-operator">*</span> k <span class="hljs-operator">-</span> <span class="hljs-number">2</span> <span class="hljs-operator">*</span> d

# 计算RSI指标
rsi <span class="hljs-operator">=</span> talib.RSI(closes, timeperiod<span class="hljs-operator">=</span><span class="hljs-number">14</span>)

# 计算OVB指标
obv <span class="hljs-operator">=</span> talib.OBV(closes, np.array([float(kline[<span class="hljs-number">5</span>]) <span class="hljs-keyword">for</span> kline in klines]))

<span class="hljs-keyword">return</span> k, d, j, rsi, obv
</code></pre><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">定义交易策略函数</h1><p>def trading_strategy(symbol): # 获取K线数据 klines = client.get_klines(symbol=symbol, interval=Client.KLINE_INTERVAL_1HOUR, limit=30)</p><pre data-type="codeBlock" text="# 计算指标
k, d, j, rsi, obv = calculate_indicators(klines)

# 判断买入条件
if k[-1] &gt; d[-1] and j[-1] &gt; 0 and rsi[-1] &lt; 50 and obv[-1] &gt; obv[-2]:
    print(f&quot;Buy {symbol} at {klines[-1][4]}&quot;)

# 判断卖出条件
elif k[-1] &lt; d[-1] and j[-1] &lt; 0 and rsi[-1] &gt; 50 and obv[-1] &lt; obv[-2]:
    print(f&quot;Sell {symbol} at {klines[-1][4]}&quot;)
"><code><span class="hljs-comment"># 计算指标</span>
k, d, j, rsi, <span class="hljs-attr">obv</span> = calculate_indicators(klines)

<span class="hljs-comment"># 判断买入条件</span>
if k<span class="hljs-section">[-1]</span> > d<span class="hljs-section">[-1]</span> and j<span class="hljs-section">[-1]</span> > 0 and rsi<span class="hljs-section">[-1]</span> &#x3C; 50 and obv<span class="hljs-section">[-1]</span> > obv<span class="hljs-section">[-2]</span>:
    print(f"Buy {symbol} at {klines<span class="hljs-section">[-1]</span><span class="hljs-section">[4]</span>}")

<span class="hljs-comment"># 判断卖出条件</span>
elif k<span class="hljs-section">[-1]</span> &#x3C; d<span class="hljs-section">[-1]</span> and j<span class="hljs-section">[-1]</span> &#x3C; 0 and rsi<span class="hljs-section">[-1]</span> > 50 and obv<span class="hljs-section">[-1]</span> &#x3C; obv<span class="hljs-section">[-2]</span>:
    print(f"Sell {symbol} at {klines<span class="hljs-section">[-1]</span><span class="hljs-section">[4]</span>}")
</code></pre><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">运行交易策略</h1><p>while True: trading_strategy(&quot;BTCUSDT&quot;) time.sleep(3600) # 每小时运行一次</p><p>这个策略会每隔一个小时运行一次，并且根据KDJ、RSI和OVB指标来判断买入和卖出的条件。具体来说，当K线在低位交叉并且KDJ的J值大于0、RSI小于50、OVB上升时，会发出买入信号；而当K线在高位交叉并且KDJ的J值小于0、RSI大于50、OVB下降时，会发出卖出信号。你可以根据需要调整指标参数和交易条件。</p>]]></content:encoded>
            <author>hongkongpay-dao@newsletter.paragraph.com (hongkongpay.dao)</author>
        </item>
    </channel>
</rss>