Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error sending buy or sell #37

Open
JhonAndersonVelasco opened this issue Aug 7, 2022 · 14 comments
Open

Error sending buy or sell #37

JhonAndersonVelasco opened this issue Aug 7, 2022 · 14 comments

Comments

@JhonAndersonVelasco
Copy link

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

@mdn522
Copy link
Owner

mdn522 commented Aug 12, 2022

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.

@JhonAndersonVelasco
Copy link
Author

JhonAndersonVelasco commented Aug 21, 2022

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

@mdn522
Copy link
Owner

mdn522 commented Aug 21, 2022

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
Copy link
Owner

mdn522 commented Aug 21, 2022

Also check this example script about auto reconnect

auto_reconnect.py

@mdn522
Copy link
Owner

mdn522 commented Aug 21, 2022

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.

@JhonAndersonVelasco
Copy link
Author

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

@mdn522
Copy link
Owner

mdn522 commented Sep 17, 2022

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
Copy link
Owner

mdn522 commented Sep 17, 2022

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.

@JhonAndersonVelasco
Copy link
Author

Thank you

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

@mdn522
Copy link
Owner

mdn522 commented Sep 19, 2022

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

@JhonAndersonVelasco
Copy link
Author

I am running:

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

And nothing, same problem

@mdn522
Copy link
Owner

mdn522 commented Sep 21, 2022

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

@muriloneo
Copy link

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?

@JhonAndersonVelasco
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants