mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 15:24:21 +01:00
subscriptions: make generate sub_id more unique
This commit is contained in:
committed by
Jacob Plaster
parent
afbb4a670c
commit
3eb02910d2
@@ -4,7 +4,15 @@ Module used to describe all of the different data types
|
||||
|
||||
import time
|
||||
import json
|
||||
from random import randint
|
||||
|
||||
def generate_sub_id():
|
||||
"""
|
||||
Generates a unique id in the form of 12345566-12334556
|
||||
"""
|
||||
prefix = str(int(round(time.time() * 1000)))
|
||||
suffix = str(randint(0, 9999999))
|
||||
return "{}-{}".format(prefix, suffix)
|
||||
|
||||
class Subscription:
|
||||
"""
|
||||
@@ -23,7 +31,7 @@ class Subscription:
|
||||
self.chan_id = None
|
||||
if timeframe:
|
||||
self.key = 'trade:{}:{}'.format(self.timeframe, self.symbol)
|
||||
self.sub_id = int(round(time.time() * 1000))
|
||||
self.sub_id = generate_sub_id()
|
||||
self.send_payload = self._generate_payload(**kwargs)
|
||||
|
||||
def confirm_subscription(self, chan_id):
|
||||
|
||||
Reference in New Issue
Block a user