Python
Python is everywhere in finance and it would suit you to use it in your data analysis. I recommend installing the Jupyter Notebook so you can do you data science.
Jupyter
Jupyter can really help you do some data analysis but you will need a few packages to help you do so. In your terminal run the following:
pip install requests python mplfinance
Candlestick Queries
Remember QuestDb has the option to pull data via a REST call so we can make a Jupyter notebook via the following:
import requests
import time
import pandas as pd
import json
import mplfinance as mpf
from requests.models import PreparedRequest
baseUrl = "http://[Your Kmaster Server IP Address]:[Api exposed server port]>"
exchange = "OANDA"
symbol = "EUR/USD"
hoursBack = 24
timeframe = 15
startTime = (int(time.time()) - (hoursBack * 60 * 60)) * 1000
params = {"exchange": exchange,"symbol": symbol,"startEpoch": startTime,"endEpoch": int(time.time()) * 1000, "limit":10000, "timeframe": timeframe}
req = PreparedRequest()
req.prepare_url(f"{baseUrl}/api/markets/candlesticks", params)
response = requests.get(req.url)
data = response.json()
data["status"]
if data["status"] == "ok":
candlesticks = data["data"]
if len(candlesticks) > 0:
df = pd.DataFrame(candlesticks)
df.timestamp = pd.to_datetime(df.timestamp)
df = df.set_index("timestamp")
df = df.sort_values(by="timestamp")
mpf.plot(df,title=exchange+":"+symbol, type="candle",volume=True,tight_layout=True, mav=(50), style="yahoo")
else:
print("There is no data in the time range selected.")
else:
print(f"Error in request: {response.text}")