verata-veritatis / pybit

Python3 API connector for Bybit's HTTP and Websockets APIs.
MIT License
117 stars 193 forks source link

Add signature_window to WebSocket def _auth() #67

Open ImaRicklePick opened 2 years ago

ImaRicklePick commented 2 years ago

63 Solution for the issue described there

dextertd commented 2 years ago

This is not a good way to solve this issue. Ideally, it should be solved at the root, which is by syncing the computer's clock (which python's time module relies on). I don't think it should be addressed in code, as it disguises the problem, which could cause other issues later on that would be difficult to diagnose.

If one was to address it in code, it should be done in one of the following ways:

  1. use an attribute like signature_window shown here, but add the difference to the current time instead of removing the millisecond conversion as done by this PR. It should look something like
    expires = int((time.time() + 1) * 1000 + self.signature_window
  2. create a method which queries for bybit's server time and automatically calculates the difference and adjusts expires accordingly (in the same way as in the above example)

But I don't think these are real solutions and I don't want to encourage their use... However, I am open to persuasion.