-
Notifications
You must be signed in to change notification settings - Fork 35
/
candles.py
44 lines (35 loc) · 1.22 KB
/
candles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import requests as r
import numpy as np
from __init__ import userVals
from oandapyV20 import API
import oandapyV20.endpoints.instruments as instruments
class user1():
client = API(access_token=userVals.key)
o = instruments.InstrumentsCandles(instrument=userVals.pair,
params=userVals.params)
class candleLogic:
def OHLC(self, data):
# Call imported user1 class
user1.client.request(user1.o)
candles = user1.o.response.get("candles")
candleData = candles[data].get("mid")
# OHLC variables to return in array
o = candleData.get("o")
h = candleData.get("h")
l = candleData.get("l")
c = candleData.get("c")
return float(o), float(h), float(l), float(c)
# Define clean function routes for returning proper data
def Open(self, data):
return self.OHLC(data)[0]
def High(self, data):
return self.OHLC(data)[1]
def Low(self, data):
return self.OHLC(data)[2]
def Close(self, data):
return self.OHLC(data)[3]
def getData(self):
numList = []
for x in range(0, userVals.count):
numList.append(self.Close(x))
return numList