-
Notifications
You must be signed in to change notification settings - Fork 84
[Hyperliquid] add Hyperliquid tentacle #1476
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
824b0bd
[Hyperliquid] add Hyperliquid tentacle
GuillaumeDSM 7e6f488
[Bitfinex] rename bitfinex2 into bitfinex
GuillaumeDSM 8a25628
[WavesExchanges] fix market status
GuillaumeDSM 0e9f29f
[Kucoin] update order parsing for ccxt update
GuillaumeDSM e59ce22
[Exchanges] handle ExchangeCredentialsData
GuillaumeDSM 8aa8213
[Hyperliquid] handle auth
GuillaumeDSM 8247870
[Web] handle trades total cost with unavailable ref market converter
GuillaumeDSM 1fb717a
[Hyperliquid] fix min cost issues
GuillaumeDSM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from .hyperliquid_exchange import Hyperliquid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Drakkar-Software OctoBot-Tentacles | ||
| # Copyright (c) Drakkar-Software, All rights reserved. | ||
| # | ||
| # This library is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU Lesser General Public | ||
| # License as published by the Free Software Foundation; either | ||
| # version 3.0 of the License, or (at your option) any later version. | ||
| # | ||
| # This library is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public | ||
| # License along with this library. | ||
| import typing | ||
|
|
||
| import octobot_trading.exchanges as exchanges | ||
| import octobot_trading.enums as trading_enums | ||
|
|
||
|
|
||
| class HyperliquidConnector(exchanges.CCXTConnector): | ||
|
|
||
| def _client_factory( | ||
| self, | ||
| force_unauth, | ||
| keys_adapter: typing.Callable[[exchanges.ExchangeCredentialsData], exchanges.ExchangeCredentialsData]=None | ||
| ) -> tuple: | ||
| return super()._client_factory(force_unauth, keys_adapter=self._keys_adapter) | ||
|
|
||
| def _keys_adapter(self, creds: exchanges.ExchangeCredentialsData) -> exchanges.ExchangeCredentialsData: | ||
| # use api key and secret as wallet address and private key | ||
| creds.wallet_address = creds.api_key | ||
| creds.private_key = creds.secret | ||
| creds.api_key = creds.secret = None | ||
| return creds | ||
|
|
||
|
|
||
| class Hyperliquid(exchanges.RestExchange): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
| DESCRIPTION = "" | ||
| DEFAULT_CONNECTOR_CLASS = HyperliquidConnector | ||
|
|
||
| FIX_MARKET_STATUS = True | ||
| REQUIRE_ORDER_FEES_FROM_TRADES = True # set True when get_order is not giving fees on closed orders and fees | ||
| # should be fetched using recent trades. | ||
|
|
||
| @classmethod | ||
| def get_name(cls): | ||
| return 'hyperliquid' | ||
|
|
||
| def get_adapter_class(self): | ||
| return HyperLiquidCCXTAdapter | ||
|
|
||
|
|
||
| class HyperLiquidCCXTAdapter(exchanges.CCXTAdapter): | ||
|
|
||
| def fix_ticker(self, raw, **kwargs): | ||
| fixed = super().fix_ticker(raw, **kwargs) | ||
| fixed[trading_enums.ExchangeConstantsTickersColumns.TIMESTAMP.value] = \ | ||
| fixed.get(trading_enums.ExchangeConstantsTickersColumns.TIMESTAMP.value) or self.connector.client.seconds() | ||
| return fixed | ||
|
|
||
| def fix_market_status(self, raw, remove_price_limits=False, **kwargs): | ||
| fixed = super().fix_market_status(raw, remove_price_limits=remove_price_limits, **kwargs) | ||
| if not fixed: | ||
| return fixed | ||
| # hyperliquid min cost should be increased by 10% (a few cents above min cost is refused) | ||
| limits = fixed[trading_enums.ExchangeConstantsMarketStatusColumns.LIMITS.value] | ||
| limits[trading_enums.ExchangeConstantsMarketStatusColumns.LIMITS_COST.value][ | ||
| trading_enums.ExchangeConstantsMarketStatusColumns.LIMITS_COST_MIN.value | ||
| ] = limits[trading_enums.ExchangeConstantsMarketStatusColumns.LIMITS_COST.value][ | ||
| trading_enums.ExchangeConstantsMarketStatusColumns.LIMITS_COST_MIN.value | ||
| ] * 1.1 | ||
|
|
||
| return fixed | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "version": "1.2.0", | ||
| "origin_package": "OctoBot-Default-Tentacles", | ||
| "tentacles": ["Hyperliquid"], | ||
| "tentacles-requirements": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Hyperliquid is a basic RestExchange adaptation for Hyperliquid exchange. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Drakkar-Software OctoBot-Tentacles | ||
| # Copyright (c) Drakkar-Software, All rights reserved. | ||
| # | ||
| # This library is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU Lesser General Public | ||
| # License as published by the Free Software Foundation; either | ||
| # version 3.0 of the License, or (at your option) any later version. | ||
| # | ||
| # This library is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public | ||
| # License along with this library. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from .hyperliquid_websocket import HyperliquidCCXTWebsocketConnector |
34 changes: 34 additions & 0 deletions
34
Trading/Exchange/hyperliquid_websocket_feed/hyperliquid_websocket.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Drakkar-Software OctoBot-Tentacles | ||
| # Copyright (c) Drakkar-Software, All rights reserved. | ||
| # | ||
| # This library is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU Lesser General Public | ||
| # License as published by the Free Software Foundation; either | ||
| # version 3.0 of the License, or (at your option) any later version. | ||
| # | ||
| # This library is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| # Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public | ||
| # License along with this library. | ||
| import octobot_trading.exchanges as exchanges | ||
| from octobot_trading.enums import WebsocketFeeds as Feeds | ||
| import tentacles.Trading.Exchange.hyperliquid.hyperliquid_exchange as hyperliquid_exchange | ||
|
|
||
|
|
||
| class HyperliquidCCXTWebsocketConnector(exchanges.CCXTWebsocketConnector): | ||
| EXCHANGE_FEEDS = { | ||
| Feeds.TRADES: True, | ||
| Feeds.KLINE: True, | ||
| Feeds.TICKER: True, | ||
| Feeds.CANDLE: True, | ||
| } | ||
|
|
||
| @classmethod | ||
| def get_name(cls): | ||
| return hyperliquid_exchange.Hyperliquid.get_name() | ||
|
|
||
| def get_adapter_class(self, adapter_class): | ||
| return hyperliquid_exchange.HyperLiquidCCXTAdapter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "version": "1.2.0", | ||
| "origin_package": "OctoBot-Default-Tentacles", | ||
| "tentacles": ["HyperliquidCCXTWebsocketConnector"], | ||
| "tentacles-requirements": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍