binaryapi
binaryapi copied to clipboard
Error sending buy or sell
Hi
Me again
Now when I have sent some contracts, I get the error:
ERROR:root:**warning** 30late proposal sec(s)
This is really interesting
This error comes when the server does not reply back or maybe it replies in different format which the library is not setup properly (bug). need to see the code to identify more.
Sorry about the late reply.
My function to send contract:
def Operacion(tipo:str,monto:float,duracion:int):
success,contract_id,req_id = binary.buy(contract_type=tipo,
amount=monto,
symbol=csimb,
duration=duracion,
duration_unit='s')
return success,contract_id,req_id
Where:
if PredAct > PredAnt:
print(' [OPE] Enviando operación CALL\n')
oper = Operacion('CALL',MontoAct,55)
if oper[0] == True:
UltOper = 'Sí'
print(' [OPE] Operación CALL enviada con éxito!')
print(' Contrato = {}'.format(oper[1]))
print(' Símbolo = {}, Monto = {} {}\n'
.format(simb,MontoAct,moneda))
else:
UltOper = 'No'
print(' [ERR] La operación no ha sido enviada!, reintentando\n')
It happens aftes around 100 contracts sent
It feels like either you need to have a pinging thread (easy) or detect lost connection and restore.
About pinging: I think you can ping with binary.api.ping().
Make a thread with a function that periodically pings server. Maybe every n seconds. Where n >= 10
Not tested as I am not on my PC
ERROR:root:**warning** 30late proposal sec(s)
About this error. This error pops up when the library is expecting a response message(here proposal) from server and gets none after n seconds. Here n = 30.
Hi, thank you With auto_reconnect worked really fine few days, but now it's another error maybe realted:
ERROR:root:**error** reconnect() too many time please look log file
was this the last error you got? did not it reconnect with auto_reconnect?
by any chance, if you were there when the error happened. was there any issue with the binary server? I mean was it down or something Maybe you can modify the auto_reconnect into reconnecting back in x minutes. maybe 15/30/60 minutes.
As I don't have much experience with Binary using automated trading. I can't really tell much about long-term connectivity issues. the code for auto_reconnect came from another broker I was using for automated trading.
Thank you
The new one happens when I try send any request to binary, even with your examples just writing my token
Can you try to ping?
Make a thread that will periodically (every 10-30 seconds) ping the server. let me know if it soothes the issue.
Docs for Pinging: https://binaryapi.readthedocs.io/en/latest/api/ping.html
I am running:
binary = Binary(token=token, message_callback=message_handler)
print(binary.api.ping())
exit()
And nothing, same problem
Can you inspect the messages sent by the websocket?
you need to print all messages in message_handler.
when you request the server to buy a contract the server returns a message about your requests which contains success/fail information. you can read it in message_handler
Also take a look at this example: https://github.com/mdn522/binaryapi/blob/master/examples/propose_and_buy_contract.py
when I try sending a buy inside a message_callback it always fails the proposal.
And I see that the tick takes two seconds to appear, is there any way to be more real time?
when I try sending a buy inside a message_callback it always fails the proposal.
And I see that the tick takes two seconds to appear, is there any way to be more real time?
Tht's why I am doing it with websockets