-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1ad9e5
commit 181efe5
Showing
7 changed files
with
105 additions
and
39 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
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
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
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
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
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
54 changes: 54 additions & 0 deletions
54
tests/integration_tests/adapters/bybit/sandbox/sandbox_instrument_provider.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,54 @@ | ||
# ------------------------------------------------------------------------------------------------- | ||
# Copyright (C) 2015-2024 Nautech Systems Pty Ltd. All rights reserved. | ||
# https://nautechsystems.io | ||
# | ||
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License"); | ||
# You may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ------------------------------------------------------------------------------------------------- | ||
|
||
import os | ||
|
||
import pytest | ||
|
||
from nautilus_trader.adapters.bybit.common.enums import BybitInstrumentType | ||
from nautilus_trader.adapters.bybit.factories import get_bybit_http_client | ||
from nautilus_trader.adapters.bybit.provider import BybitInstrumentProvider | ||
from nautilus_trader.common.component import LiveClock | ||
from nautilus_trader.model.identifiers import InstrumentId | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_bybit_instrument_provider(): | ||
clock = LiveClock() | ||
client = get_bybit_http_client( | ||
clock=clock, | ||
key=os.getenv("BYBIT_API_KEY"), | ||
secret=os.getenv("BYBIT_API_SECRET"), | ||
is_testnet=False, | ||
) | ||
|
||
provider = BybitInstrumentProvider( | ||
client=client, | ||
clock=clock, | ||
instrument_types=[ | ||
BybitInstrumentType.SPOT, | ||
BybitInstrumentType.LINEAR, | ||
BybitInstrumentType.OPTION, | ||
# BybitInstrumentType.INVERSE, # Supported? | ||
], | ||
) | ||
|
||
# await provider.load_all_async() | ||
ethusdt_linear = InstrumentId.from_str("ETHUSDT-LINEAR.BYBIT") | ||
await provider.load_ids_async(instrument_ids=[ethusdt_linear]) | ||
await provider.load_all_async() | ||
|
||
print(provider.list_all()) | ||
print(provider.count) |