Store data from a variable that changes value at each instant

Asked

Viewed 205 times

0

Hello, I’m trying to solve a problem that involves your questions. I’m using a python api to get data from the IQ Option investment platform, but I’m unable to work with the data.

If I do dados = I_want_money.get_realtime_candles("EURUSD", 1) the variable dados is alternating its value every second, for example:

print(dados)

defaultdict(, {1573598084: {'active_id': 1, 'size': 1, 'at': 1573598085007490313, 'from': 1573598084, 'to': 1573598085, 'id': 45579603, 'open': 1.10109, 'close': 1.10109, 'min': 1.10109, 'max': 1.101105, 'Ask': 1.10115, 'Bid': 1.10103, 'volume': 4, 'Phase': ’T'}})

print(dados)

defaultdict(, {1573598085: {'active_id': 1, 'size': 1, 'at': 1573598086007376567, 'from': 1573598085, 'to': 1573598086, 'id': 45579604, 'open': 1.101095, 'close': 1.1011, 'min': 1.101095, 'max': 1.1011, 'Ask': 1.10116, 'Bid': 1.10104, 'volume': 2, 'Phase'’T'}})

print(dados)

defaultdict(, {1573598086: {'active_id': 1, 'size': 1, 'at': 1573598087007314295, 'from': 1573598086, 'to': 1573598087, 'id': 45579605, 'open': 1.101105, 'close': 1.10111, 'min': 1.101105, 'max': 1.10111, 'Ask': 1.10117, 'Bid': 1.10105, 'volume': 2, 'Phase': ’T'}})

So if I do for example aux = dados the variable aux will behave in the same way.

Another problem is that the variable to which I assign this data becomes the type dict, so if I can’t get for example dados[volume].

How do for example to store in a vector every second the data of dados in the field max ?

  • 1

    From what I read in the library documentation, communication is done via websockets, so the library updates the data in real time. This question is not about python, but about using the IQ Option API. (I don’t know the API so I can’t help)

1 answer

0

Well you can do the following, every second, assign the values that "data" receive and put in a list.

values = []
while 1:
    dados = I_want_money.get_realtime_candles("EURUSD", 1)
    values.append(dados)

    if len(values) == 30:
        break

print(values)

In this list you can access the values freely

Browser other questions tagged

You are not signed in. Login or sign up in order to post.