Open lohrann opened 4 years ago
Using buyraw:
expiration doesn't contain a random value. In your example, 1594476780000 is an Epoch Timestamp that is in milliseconds. To make it human readable you can convert it to ISO-8601 format.
from datetime import datetime
expiration = 1594476780000
print("Expiration:", datetime.fromtimestamp(expiration / 1e3).isoformat())
Hi,
So, I need to convert first, and after that send it from buyraw or buy?
Hello, I have the same issue, I tried the functions buy and buy_by_raw_expirations, but didn´t work both.
If you use buy_by_raw_expirations and the expired time obtain with get_live_deal, you need to divide by a thousand, and then use it, but if you use the buy function, you need to calculate the time between the expiration and the current time and calculate to which minute it correspond 1,2,3 ... Have in mind that there is an issue that hasn't been fixed yet #6 where I have posted my own fix
Look to my values: Binary - buy_by_raw_expirations: value: 2 - Par: EURUSD - Direction: put - Type: turbo - Expiration timestamp: 1594682580 - Expiration datetime: 2020-07-13 23:23:00
Binary - buy: value: 2 - Par: EURUSD - Direction: put - Timeframe: 1
Is there anything wrong?
Hi,
So, I need to convert first, and after that send it from buyraw or buy?
I didn't see it in deep, but it is probably the time the deal will expire. So, you have to construct a get_remaining_time function to return the value you should pass to buy function.
For example:
If the expiration time is 2020-07-13 23:23:00 and the time now is 2020-07-13 23:20:00 you should open a trade with 3 minutes as expiration time in your buy function.
@lohrann did you manage to fix the problem?
@isaacdalmarco no. I'm really confused.
Anyone to help me to find a real solution in code?
@lohrann I just got it!
There is a fix in buyv2 api:
From:
To:
I uninstalled this repo and installed that one with the fix: https://github.com/iqoptionapi/iqoptionapi
@isaacdalmarco I just tested it also, and it has the same bug as this repo, not your error though but if you change your date, for example I delayed my date one minute, and the buy and sell times were wrong. So be careful. I mention here my solution https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6#issuecomment-655899438 which it seems to be working ok at least for me, though I think is a little slower. But is ok, I prefer that than having to check my computers time
I just modify the class which the buy method is using (buyv3), changing what I commented before and i ended up with this
class Buyv3(Base):
name = "sendMessage"
def __call__(self, price, active, direction, duration, request_id):
tserver = int(self.api.timesync.server_timestamp)
if tserver%60 > 30:
exp = tserver - tserver%60 +60*(1+duration)
else:
exp = tserver - tserver%60 + (60*duration)
if duration <= 5:
option = 3 # "turbo"
else:
option = 1 # "binary"
data = {
"body": {"price": price,
"active_id": active,
"expired": int(exp),
"direction": direction.lower(),
"option_type_id": option,
"user_balance_id": int(global_value.balance_id)
},
"name": "binary-options.open-option",
"version": "1.0"
}
self.send_websocket_request(self.name, data, str(request_id))
I tested it in turbo and its working ok
Hi,
I want to copy the trades of the other traders on IQ Option.
I just using the get_live_deal to obtain the parameters, and I saw that the expiration is getting me issues.
On the JSON, it's just using expiration variable, that uses a random value (ex. 1594476780000).
That's the error when i use the buy option instead of buyraw (buyraw also sends me the same error), invalid request 4000: