-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtil.py
70 lines (58 loc) · 1.76 KB
/
Util.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
import threading
import numpy as np
from Elastic import Elastic
import urllib.request
from ValueAnalyse import ValueAnalyse
import json
class Util:
def __init__(self):
pass
def disp(self,el,call,prices,assets):
threading.Timer(1, self.disp,[el,call,prices,assets]).start()
print("value length")
print(len(prices))
value = urllib.request.urlopen(call).read() # Ca daoit être à cause de ma connection internet mais ca donne rien
prices.append(value)
#print("prices : ")
#print(type(prices))
#a = " ".join(str(x) for x in prices)
#print(a)
# test
if(False):
json_text = """
[
{"BTC":{"USD":2167.85},"ETH":{"USD":167.88},"DASH":{"USD":102.31}},
{"BTC":{"USD":2253.12},"ETH":{"USD":177.76},"DASH":{"USD":109.17}},
{"BTC":{"USD":2251.47},"ETH":{"USD":177.71},"DASH":{"USD":109.12}},
{"BTC":{"USD":2251.47},"ETH":{"USD":177.71},"DASH":{"USD":109.12}},
{"BTC":{"USD":2251.47},"ETH":{"USD":177.71},"DASH":{"USD":109.12}},
{"BTC":{"USD":2167.85},"ETH":{"USD":167.88},"DASH":{"USD":102.31}}
]
"""
a = json.loads(json_text)
json_text = "[" + ','.join([e.decode("utf-8") for e in prices]) + ']'
#a = json.loads(json_text)
va = ValueAnalyse(json_text)
results = va.actionDecision()
buyValue =(len(results[1])-1)*[""]
sellValue = (len(results[1])-1)*[""]
# on parcourt la deuxieme ligne
for i in range(1,len(results[1])):
k = 0
j = 0
if results[1][i] == "buy":
buyExist = True
# il me faut l'indice a acheter
buyValue[k] = results[0][i]
k=k+1
if results[1][i] == "sell":
sellExist = True
sellValue[j] = results[0][i]
j=j+1
#if ((sellExist != 0) and (buyExist !=0)):
# break
print("Vendre ")
print(sellValue)
print(" contre ")
print (buyValue)
el.store(assets,value)