我有一个 python pandas 代码来将 url Json 数据从 api 解析到数据帧
import pandas as pd
import json
import urllib.request
import os
from pandas import DataFrame
with urllib.request.urlopen(
"https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-WAVES&tickInterval=fiveMin") as URL:
data = json.loads(URL.read().decode())
df2 = pd.DataFrame(data=data['result'])
df2.rename(columns={'BV': 'BaseVolume', 'C': 'Close', 'H': 'High', 'L': 'Low', 'O': 'Open', 'T': 'TimeStamp','V': 'Volume'}, inplace=True)
high_prices = df2['High']
close_prices = df2['Close']
low_prices = df2['Low']
TimeStamp = df2.index
nine_period_high = pd.rolling_max(df2['High'], window=9)
nine_period_low = pd.rolling_min(df2['Low'], window=9)
df2['tenkan_sen'] = (nine_period_high + nine_period_low) /2
# Kijun-sen (Base Line): (26-period high + 26-period low)/2))
period26_high = pd.rolling_max(high_prices, window=26)
period26_low = pd.rolling_min(low_prices, window=26)
df2['kijun_sen'] = (period26_high + period26_low) / 2
# Senkou Span A (Leading Span A): (Conversion Line + Base Line)/2))
df2['senkou_span_a'] = ((df2['tenkan_sen'] + df2['kijun_sen']) / 2).shift(26)
# Senkou Span B (Leading Span B): (52-period high + 52-period low)/2))
period52_high = pd.rolling_max(high_prices, window=52)
period52_low = pd.rolling_min(low_prices, window=52)
df2['senkou_span_b'] = ((period52_high + period52_low) / 2).shift(26)
print('df2')
print('DONE')
它对我来说很完美,除了这个错误(不是:它不会影响结果,但我担心这个未来的警告。
FutureWarning: pd.rolling_max is deprecated for Series and will be removed in a future version, replace with
Series.rolling(window=9,center=False).max()
nine_period_high = pd.rolling_max(df2['High'], window=9)
并且所有脚本中的所有 rolling_max 和 rolling_min 总是重复相同的错误。
任何机构都可以帮忙。