问题描述
我很高兴能与大家分享我的问题,并希望向大家学习。 我当前的问题是def Calculation_hma,我无法获得像上面的计算一样的正确计算。
python27
iuputs
period = 9
Coin_pair = "USD-BTC"
Unit = thirtyMin''
def getClosingPrices(coin_pair,period,unit):
historical_data = api.getHistoricalData(coin_pair,unit)
closing_prices = []
for i in historical_data:
closing_prices.append(i['C'])
return closing_prices
def calculate_sma(coin_pair,unit):
total_closing = sum(getClosingPrices(coin_pair,unit))
return (total_closing / period)
def calculate_ema(coin_pair,unit):
closing_prices = getClosingPrices(coin_pair,unit)
previous_EMA = calculate_sma(coin_pair,unit)
constant = (2 / (period + 1))
current_EMA = (closing_prices[-1] * (2 / (1 + period))) + (previous_EMA * (1 - (2 / (1 + period))))
def calculate_hma(coin_pair,unit):
"""
Hull Moving Average.
Formula:
HMA = WMA(2*WMA(n/2) - WMA(n)),sqrt(n)
"""
-MY Try of calculation ?
ma = calculate_sma(coin_pair,unit)
HMA = ma(2*ma(period/2) - ma(period)),sqrt(period)
-my question ?
where to use the unit and pierod and coin_pair in the calculation ?
-check inputs above
)
return hma
ema = calculate_ema(market,period=9,unit=timeframe)
sma = calculate_sma(market,unit=timeframe)
hma = calculate_sma(market,unit=timeframe) ?
print (ema)
print (sma)
print (hma)
谢谢你们检查我的问题
致谢, 莫
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)