forked from flechajm/BluePy
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor_dolar_venezuela.py
74 lines (64 loc) · 2.22 KB
/
monitor_dolar_venezuela.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import util
import pyDolarVenezuela as pdv
from datetime import datetime
def getValues():
monitor = pdv.Monitor()
values = monitor.get_value_monitors()
return values
def getOficial():
monitor = pdv.Monitor()
value_bancamiga = monitor.get_value_monitors(
monitor_code='bancamiga', name_property='price'
)
value_banco_de_venezuela = monitor.get_value_monitors(
monitor_code='banco_de_venezuela', name_property='price'
)
value_banco_exterior = monitor.get_value_monitors(
monitor_code='banco_exterior', name_property='price'
)
value_banesco = monitor.get_value_monitors(
monitor_code='banesco', name_property='price'
)
value_bbva_provincial = monitor.get_value_monitors(
monitor_code='bbva_provincial', name_property='price'
)
value_bcv = monitor.get_value_monitors(
monitor_code='bcv', name_property='price'
)
value_bnc = monitor.get_value_monitors(
monitor_code='bnc', name_property='price'
)
prices = [
util.convertToDecimal(value_bancamiga),
util.convertToDecimal(value_banco_de_venezuela),
util.convertToDecimal(value_banco_exterior),
util.convertToDecimal(value_banesco),
util.convertToDecimal(value_bbva_provincial),
util.convertToDecimal(value_bcv),
util.convertToDecimal(value_bnc),
]
values = [n for n in prices if n > 0]
return sum(values) / len(values)
def getParalelo():
monitor = pdv.Monitor()
value_enparalelovzla = monitor.get_value_monitors(
monitor_code='enparalelovzla', name_property='price'
)
value_dolartoday = monitor.get_value_monitors(
monitor_code='dolartoday', name_property='price'
)
value_monitor = monitor.get_value_monitors(
monitor_code='monitor_dolar_venezuela', name_property='price'
)
prices = [
util.convertToDecimal(value_enparalelovzla),
util.convertToDecimal(value_dolartoday),
util.convertToDecimal(value_monitor),
]
values = [n for n in prices if n > 0]
return sum(values) / len(values)
def formatResponse(value):
return {
"fecha": datetime.today().strftime('%Y-%m-%d %H:%M:%S'),
"valor": '{:.2f}'.format(value)
}