-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Trading][Exchanges][Bybit] Add websocket feed
- Loading branch information
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 .bybit_websocket import BybitCryptofeedWebsocketConnector |
This file contains 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,44 @@ | ||
# 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 | ||
import cryptofeed.defines as cryptofeed_constants | ||
from octobot_trading.enums import WebsocketFeeds as Feeds | ||
|
||
|
||
class BybitCryptofeedWebsocketConnector(exchanges.CryptofeedWebsocketConnector): | ||
REQUIRED_ACTIVATED_TENTACLES = [] | ||
EXCHANGE_FEEDS = { | ||
Feeds.TRADES: cryptofeed_constants.TRADES, | ||
Feeds.KLINE: cryptofeed_constants.CANDLES, | ||
Feeds.TICKER: Feeds.UNSUPPORTED.value, | ||
Feeds.CANDLE: cryptofeed_constants.CANDLES, | ||
} | ||
|
||
@classmethod | ||
def get_name(cls): | ||
return 'bybit' | ||
|
||
@classmethod | ||
def get_feed_name(cls): | ||
return cryptofeed_constants.BYBIT | ||
|
||
@classmethod | ||
def is_handling_spot(cls) -> bool: | ||
return False # Soon | ||
|
||
@classmethod | ||
def is_handling_future(cls) -> bool: | ||
return True |
This file contains 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": ["BybitCryptofeedWebsocketConnector"], | ||
"tentacles-requirements": [] | ||
} |
This file contains 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. |
51 changes: 51 additions & 0 deletions
51
Trading/Exchange/bybit_websocket_feed/tests/_test_unauthenticated_mocked_feeds.py
This file contains 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,51 @@ | ||
# 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 pytest | ||
|
||
import octobot_commons.channels_name as channels_name | ||
import octobot_commons.enums as commons_enums | ||
import octobot_commons.tests as commons_tests | ||
import octobot_trading.exchanges as exchanges | ||
import octobot_trading.util.test_tools.exchanges_test_tools as exchanges_test_tools | ||
import octobot_trading.util.test_tools.websocket_test_tools as websocket_test_tools | ||
from ...binance_websocket_feed import BinanceCryptofeedWebsocketConnector | ||
|
||
# All test coroutines will be treated as marked. | ||
pytestmark = pytest.mark.asyncio | ||
|
||
|
||
async def test_start_spot_websocket(): | ||
config = commons_tests.load_test_config() | ||
exchange_manager_instance = await exchanges_test_tools.create_test_exchange_manager( | ||
config=config, exchange_name=BinanceCryptofeedWebsocketConnector.get_name()) | ||
|
||
await websocket_test_tools.test_unauthenticated_push_to_channel_coverage_websocket( | ||
websocket_exchange_class=exchanges.CryptofeedWebSocketExchange, | ||
websocket_connector_class=BinanceCryptofeedWebsocketConnector, | ||
exchange_manager=exchange_manager_instance, | ||
config=config, | ||
symbols=["BTC/USDT", "ETH/BTC", "ETH/USDT"], | ||
time_frames=[commons_enums.TimeFrames.ONE_MINUTE, | ||
commons_enums.TimeFrames.ONE_HOUR, | ||
commons_enums.TimeFrames.FOUR_HOURS], | ||
expected_pushed_channels={ | ||
channels_name.OctoBotTradingChannelsName.KLINE_CHANNEL.value, | ||
channels_name.OctoBotTradingChannelsName.OHLCV_CHANNEL.value | ||
}, | ||
time_before_assert=75 | ||
) | ||
await exchanges_test_tools.stop_test_exchange_manager(exchange_manager_instance) |