-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmoving_average.py
More file actions
46 lines (33 loc) · 1.31 KB
/
moving_average.py
File metadata and controls
46 lines (33 loc) · 1.31 KB
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
45
46
from iqoptionapi.stable_api import IQ_Option
import logging, json, sys, time, configparser
from talib.abstract import *
import numpy as np
logging.disable(level=(logging.DEBUG))
arquivo_user = configparser.RawConfigParser()
arquivo_user.read('config_user.txt')
API = IQ_Option(arquivo_user.get('USER', 'user'), arquivo_user.get('USER', 'password'))
API.connect()
API.change_balance('PRACTICE') # PRACTICE / REAL
if API.check_connect():
print('\n\nConectado com sucesso')
else:
print('\n Erro ao se conectar')
sys.exit()
par = 'EURUSD'
periodo = 14
tempo_segundos = 60
API.start_candles_stream(par, tempo_segundos, 280)
while True:
velas = API.get_realtime_candles(par, tempo_segundos)
valores = {'open': np.array([]), 'high': np.array([]), 'low': np.array([]), 'close': np.array([]), 'volume': np.array([]) }
for x in velas:
valores['open'] = np.append(valores['open'], velas[x]['open'])
valores['high'] = np.append(valores['open'], velas[x]['max'])
valores['low'] = np.append(valores['open'], velas[x]['min'])
valores['close'] = np.append(valores['open'], velas[x]['close'])
valores['volume'] = np.append(valores['open'], velas[x]['volume'])
calculo_sma = SMA(valores, timeperiod=periodo)
print(calculo_sma)
sys.exit()
print(calculo_sma[-1])
time.sleep(1)