mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 16:28:06 +00:00
36 lines
850 B
Markdown
36 lines
850 B
Markdown
- [Rsi](./examples/py/)
|
|
|
|
|
|
```python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
import sys
|
|
|
|
|
|
import pandas_ta as ta
|
|
import pandas as pd
|
|
import ccxt
|
|
print('CCXT Version:', ccxt.__version__)
|
|
|
|
exchange = ccxt.binance()
|
|
symbol = 'BTC/USDT'
|
|
timeframe = '1m'
|
|
limit = 500
|
|
rsi_length = 100
|
|
while True:
|
|
try:
|
|
ohlcv = exchange.fetch_ohlcv(symbol, timeframe)
|
|
print('--------------------------------------------------------------')
|
|
if len(ohlcv):
|
|
df = pd.DataFrame(ohlcv, columns=['time', 'open', 'high', 'low', 'close', 'volume'])
|
|
df['time'] = pd.to_datetime(df['time'], unit='ms')
|
|
df = pd.concat([df, df.ta.rsi(length=rsi_length)], axis=1)
|
|
print(df[-20:])
|
|
print(exchange.iso8601 (exchange.milliseconds()))
|
|
except Exception as e:
|
|
print(type(e).__name__, str(e))
|
|
|
|
|
|
|
|
``` |