![](/img/trans.png)
[英]I have a syntax error while creating a function and i am not sure what I have got wrong
[英]Error message: Function is not callable, not sure what is wrong?
def smaShort(self):
while True:
ohlcv_candles = bitmex2.bitmex.fetch_ohlcv(self, symbol= 'XBTUSD', timeframe= '5m')
mas = []
mas = ohlcv_candles.rolling(window=5).mean()
return mas#[-1]
嘗試調用 smaShort 函數時
logger.info("sma short value:" (self.smaShort()))
我收到錯誤 smaShort is not callable,有人知道我做錯了什么嗎?
import pandas as pd
import ccxt
exchange = ccxt.bitmex({
'enableRateLimit': True, # required by the Manual
})
ohlcv = exchange.fetch_ohlcv('BTC/USD', '1m')
df = pd.DataFrame (ohlcv)
df[4].rolling(window=5).mean() # OHLCV, C (closing price) has index 4
XBTUSD
符號,它是市場ID而不是符號,如手冊中所述:https ://github.com/ccxt/ccxt/wiki/Manual#symbols-and-market-ids 。 正確的符號是BTC/USD
。bitmex.fetch_ohlcv
將返回以下結構: https://github.com/ccxt/ccxt/wiki/Manual#ohlcv-structure 。.rolling(window=5).mean()
,您必須將其轉換為 DataFrame首先,如上所示(或以 Pandas 支持的任何其他方式)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.