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

Fix persisting Kraken trades in QuestDB #1039

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Cryptofeed was originally created by Bryant Moscon, but many others have contrib
* [Jonggyun Kim](https://github.com/gyunt) - <truth0233@gmail.com>
* [QuasarDB](https://quasar.ai/)
* [Thomas Bouamoud](https://github.com/thomasbs17) - <thomasbs17@yahoo.fr>
* [Carlo Eugster](https://github.com/carloe) - <carlo@relaun.ch>
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Update: transitioned from Coinbase Pro (retired) to Coinbase Advanced Trade
* Feature: Bybit spot support
* Update: Bybit migrate to API V5 for public streams
* Bugfix: Handle None ids for Kraken trades in QuestDB

### 2.4.0 (2024-01-07)
* Update: Fix tests
Expand Down
7 changes: 5 additions & 2 deletions cryptofeed/backends/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ class TradeQuest(QuestCallback, BackendCallback):
async def write(self, data):
timestamp = data["timestamp"]
received_timestamp_int = int(data["receipt_timestamp"] * 1_000_000)
id_field = f'id={data["id"]}i,' if data["id"] is not None else ''
timestamp_int = int(timestamp * 1_000_000_000) if timestamp is not None else received_timestamp_int * 1000
update = f'{self.key}-{data["exchange"]},symbol={data["symbol"]},side={data["side"]},type={data["type"]} ' \
f'price={data["price"]},amount={data["amount"]},id={data["id"]}i,receipt_timestamp={received_timestamp_int}t {timestamp_int}'
update = (
f'{self.key}-{data["exchange"]},symbol={data["symbol"]},side={data["side"]},type={data["type"]} '
f'price={data["price"]},amount={data["amount"]},{id_field}receipt_timestamp={received_timestamp_int}t {timestamp_int}'
)
await self.queue.put(update)


Expand Down
Loading