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
|
import asyncio,time
import ccxt.async_support as ccxt
from threading import Thread
ACTUALRATE={}
class Info():
# def __init__(self):
# self.crypto_rate={}
def set_rate(self,crypto_rate):
key, value=crypto_rate
ACTUALRATE[key]=value
def get_rate(self):
print ("sortie dans get",ACTUALRATE)
return ACTUALRATE
#demarrage du socket pour récupérér les taux
async def poll(tickers):
i = 0
gdax = ccxt.gdax()
while True:
symbol = tickers[i % len(tickers)]
yield (symbol, await gdax.fetch_ticker(symbol))
i += 1
await asyncio.sleep(gdax.rateLimit / 1000)
async def main():
instantrate = Info()
instantrate.set_rate(crypto_rate=('eth/eur', '0.5515'))
async for (symbol, ticker) in poll(['BTC/EUR', 'ETH/EUR', 'LTC/EUR']):
print ("sortie dans ccxt")
# print(ticker['symbol'],ticker['last'])
rate=(ticker['symbol'],ticker['last'])
asyncio.get_event_loop().run_until_complete(main())
#ici j'aimerai pouvoir afficher le contenue via (le contenue de ma variable ACTUALRATE) mais impossible
instantrate.Info()
instantrate.get_rate() |
Partager