binaryapi icon indicating copy to clipboard operation
binaryapi copied to clipboard

Error sending buy or sell

Open JhonAndersonVelasco opened this issue 3 years ago • 14 comments

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

JhonAndersonVelasco avatar Aug 07 '22 19:08 JhonAndersonVelasco

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.

mdn522 avatar Aug 12 '22 12:08 mdn522

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

JhonAndersonVelasco avatar Aug 21 '22 19:08 JhonAndersonVelasco

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

mdn522 avatar Aug 21 '22 22:08 mdn522

Also check this example script about auto reconnect

auto_reconnect.py

mdn522 avatar Aug 21 '22 22:08 mdn522

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.

mdn522 avatar Aug 21 '22 22:08 mdn522

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

JhonAndersonVelasco avatar Sep 17 '22 01:09 JhonAndersonVelasco

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.

mdn522 avatar Sep 17 '22 05:09 mdn522

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.

mdn522 avatar Sep 17 '22 06:09 mdn522

Thank you

The new one happens when I try send any request to binary, even with your examples just writing my token

JhonAndersonVelasco avatar Sep 18 '22 17:09 JhonAndersonVelasco

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

mdn522 avatar Sep 19 '22 02:09 mdn522

I am running:

binary = Binary(token=token, message_callback=message_handler)
print(binary.api.ping())
exit()

And nothing, same problem

JhonAndersonVelasco avatar Sep 21 '22 05:09 JhonAndersonVelasco

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

mdn522 avatar Sep 21 '22 18:09 mdn522

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?

muriloneo avatar Dec 22 '22 22:12 muriloneo

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

JhonAndersonVelasco avatar Dec 23 '22 01:12 JhonAndersonVelasco