<jupyter_start><jupyter_text>Acquiring Relative Strength Data (rsi) Values For various bitcoin trades data from SeaofBTC API<jupyter_code>import urllib, json
import numpy as np
import pandas as pd
import matplotlib.dates as mdates
url = "http://www.seaofbtc.com/api/indicator/rsi"<jupyter_output><empty_output><jupyter_text>This url takes in requests and converts them into another url by appending queries. Also we need the information from other notebook, where I have acquired the trade prices data.<jupyter_code>DataPace = "3d"   # 1d, 3d, 7d
ProgramName = "bitfinex" 
ResampleSize = "15Min"
datalink = "http://www.seaofbtc.com/api/basic/price?key=1&tf=" + DataPace + "&exchange=" + ProgramName

data = urllib.request.urlopen(datalink)
data = data.read().decode("utf-8")
data = json.loads(data)

df = pd.DataFrame({ "timestamp": data[0], "price": data[1], "volume": data[2]})
df["datestamp"] = np.array(df["timestamp"]).astype("datetime64[s]")

df.set_index("datestamp", inplace=True)

OHLC = df["price"].resample(ResampleSize).ohlc()

Vol = pd.DataFrame()
Vol["volume"] = df["volume"].resample(ResampleSize).sum()

OHLC["datestamp"] = OHLC.index
Vol["datestamp"] = Vol.index

price_data = OHLC["close"].apply(float).tolist()
OHLC["mpldates"] = OHLC["datestamp"].apply(lambda date: mdates.date2num(date.to_pydatetime()))
Vol["mpldates"] = Vol["datestamp"].apply(lambda date: mdates.date2num(date.to_pydatetime()))
OHLC.head()
Vol.head()
price_data[:10]
periods = 10
values = { "key":1, "prices":price_data, "periods":periods}
dataForRequest = urllib.parse.urlencode(values)
dataForRequest = dataForRequest.encode("utf-8")
request = urllib.request.Request(url, dataForRequest)
data = urllib.request.urlopen(request)
data = data.read().decode("utf-8")
data
data = data[1:-1]
data
data = data.split(", ")
data
data = [float(i) for i in data]
data<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.161427810335642, 'fraction_numerical': 0.012786361214704315, 'mean_word_length': 6.66530612244898, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '332330', 'license': 'MIT', 'n_tokens_mistral': 694, 'n_tokens_neox': 672, 'n_words': 144, 'path': 'rsi_requests.ipynb', 'repo_name': 'TejasReddy9/bitcoin-data-analysis', 'size': '1877'}