비트맥스 1일 RSI 출력해주는 파이썬 코드 입니다.
비트맥스 수수료 할인 링크
https://www.bitmex.com/register/Kkr3R5
import time, requests, json
from datetime import datetime
import pandas as pd
import webbrowser
import calendar, requests
a=1
while True:
symbol='XBTUSD'
symbol=symbol
now = datetime.now()
unixtime = calendar.timegm(now.utctimetuple())
since = unixtime - 60 * 60 *24*100
param = {"period": 60, "from": since, "to": unixtime}
urlcheck="https://www.bitmex.com/api/udf/history?symbol="+symbol+"&resolution={period}&from={from}&to={to}"
url = urlcheck.format(**param)
res = requests.get(url)
data = res.json()
if a==1:
url = "https://www.bitmex.com/register/Kkr3R5"
webbrowser.open(url)
a=2
df = pd.DataFrame({
"timestamp": data["t"],
"open": data["o"],
"high": data["h"],
"low": data["l"],
"close": data["c"],
"volume": data["v"],
}, columns = ["timestamp","open","high","low","close","volume"])
df["datetime"] = pd.to_datetime(df["timestamp"], unit="s")
df = df.set_index("datetime")
df = df.resample("1440T").agg({
"timestamp": "first",
"open": "first",
"high": "max",
"low": "min",
"close": "last",
"volume": "sum",
})
def rsi(ohlc: pd.DataFrame, period: int = 14) -> pd.Series:
delta = ohlc["close"].diff()
up, down = delta.copy(), delta.copy()
up[up < 0] = 0
down[down > 0] = 0
_gain = up.ewm(com=(period - 1), min_periods=period).mean()
_loss = down.abs().ewm(com=(period - 1), min_periods=period).mean()
RS = _gain / _loss
return pd.Series(100 - (100 / (1 + RS)), name="RSI")
rsi=rsi(df,14)[-1]
print("1 Day RSI",rsi)
time.sleep(1)
'비트코인 Bitcoin' 카테고리의 다른 글
| バイナンス(Binance) かんたん口座開設 (0) | 2021.01.24 |
|---|---|
| Binance 바이낸스 이메일 주소로 회원 가입하는 방법 (0) | 2021.01.22 |
| Bitmex Bitcoin RSI Code Python (0) | 2020.12.18 |