Skip to content
Open
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
2 changes: 2 additions & 0 deletions packages/trading/octobot_trading/exchanges/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
BacktestingExchangeConfig,
ExchangeProxyConfig,
ExchangeCredentialsData,
ExchangeTradingProvider,
)
from octobot_trading.exchanges import traders
from octobot_trading.exchanges.traders import (
Expand Down Expand Up @@ -158,6 +159,7 @@
"BacktestingExchangeConfig",
"ExchangeProxyConfig",
"ExchangeCredentialsData",
"ExchangeTradingProvider",
"ExchangeManager",
"ExchangeBuilder",
"create_exchange_builder_instance",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ def adapt_deposit_address(self, raw, **kwargs) -> dict:
fixed = self.fix_deposit_address(raw, **kwargs)
return self.parse_deposit_address(fixed, **kwargs)

@_adapter
def adapt_exchange_trading_providers(self, raw, **kwargs) -> list:
fixed = self.fix_exchange_trading_providers(raw, **kwargs)
return self.parse_exchange_trading_providers(fixed, **kwargs)

def get_uniformized_timestamp(self, timestamp) -> float:
# override if the exchange time is not a second timestamp or millisecond
if timestamp is not None and timestamp > 16728292300: # Friday 5 February 2500 11:51:40
Expand Down Expand Up @@ -297,3 +302,10 @@ def fix_deposit_address(self, raw, **kwargs) -> dict:

def parse_deposit_address(self, fixed, **kwargs) -> dict:
raise NotImplementedError("parse_deposit_address is not implemented")

def fix_exchange_trading_providers(self, raw, **kwargs):
# add generic logic if necessary
return raw

def parse_exchange_trading_providers(self, fixed, **kwargs) -> list:
raise NotImplementedError("parse_exchange_trading_providers is not implemented")
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@
from octobot_trading.exchanges.config.exchange_credentials_data import (
ExchangeCredentialsData,
)
from octobot_trading.exchanges.config.exchange_trading_provider import (
ExchangeTradingProvider,
)

__all__ = [
"ExchangeConfig",
"BacktestingExchangeConfig",
"ExchangeProxyConfig",
"ExchangeCredentialsData",
"ExchangeTradingProvider",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Drakkar-Software OctoBot-Trading
# 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 dataclasses
import typing


@dataclasses.dataclass
class ExchangeTradingProvider:
"""
Sometimes used by exchanges to identify the provider of a trade, when not the exchange itself.
"""
name: str
rating: typing.Optional[str] = None
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,15 @@ async def get_dex_pairs(self, symbols: list[str], **kwargs: dict) -> list[dict]:
await self.client.ob_fetch_dex_pairs(symbols, **kwargs)
)

async def get_exchange_trading_providers(self, **kwargs: dict) -> list:
if not self.client.has.get('obGetExchangeTradingProviders'):
raise octobot_trading.errors.NotSupported(
"This exchange doesn't support obGetExchangeTradingProviders"
)
return self.adapter.adapt_exchange_trading_providers(
await self.client.ob_get_exchange_trading_providers(**kwargs)
)

@ccxt_client_util.converted_ccxt_common_errors
async def get_account_id(self, **kwargs: dict) -> str:
if not self.client.has.get('fetchAccountId'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ def get_market_status(self, symbol, price_example=None, with_fixer=True):
async def get_dex_pairs(self, symbols: list[str], **kwargs: dict) -> list[dict]:
return await self.connector.get_dex_pairs(symbols, **kwargs)

async def get_exchange_trading_providers(self, **kwargs: dict) -> list:
return await self.connector.get_exchange_trading_providers(**kwargs)

def uses_demo_trading_instead_of_sandbox(self, exchange_type: enums.ExchangeTypes) -> bool:
return self.connector.uses_demo_trading_instead_of_sandbox(exchange_type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,23 +1019,24 @@ async def assert_get_recent_trades(self, limit=50):
)
self.ensure_elements_order(recent_trades, trading_enums.ExchangeConstantsTickersColumns.TIMESTAMP.value)

async def get_price_ticker(self, symbol: typing.Optional[str] = None):
async def get_price_ticker(self, symbol: typing.Optional[str] = None, **kwargs: dict):
async with self.get_exchange_manager() as exchange_manager:
return await exchange_manager.exchange.get_price_ticker(symbol or self.SYMBOL)
return await exchange_manager.exchange.get_price_ticker(symbol or self.SYMBOL, **kwargs)

async def assert_get_price_ticker(
self,
extra_checks: typing.Optional[typing.Callable[[dict], None]] = None,
*,
symbol: typing.Optional[str] = None,
ticker_expectations: typing.Optional[TickerRequiredExpectations] = None,
**kwargs: dict,
):
symbol = symbol or self.SYMBOL
async with self.get_exchange_manager() as exchange_manager:
no_volume_in_ticker = exchange_manager.exchange.get_option_value(
trading_enums.ExchangeClientOptions.NO_VOLUME_IN_TICKER
)
ticker = await exchange_manager.exchange.get_price_ticker(symbol)
ticker = await exchange_manager.exchange.get_price_ticker(symbol, **kwargs)
self._check_ticker(
ticker, symbol, extra_checks=extra_checks, no_volume_in_ticker=no_volume_in_ticker,
)
Expand Down
Loading