diff --git a/nautilus_trader/__init__.py b/nautilus_trader/__init__.py index 5f75908b251b..f99514935db7 100644 --- a/nautilus_trader/__init__.py +++ b/nautilus_trader/__init__.py @@ -26,6 +26,13 @@ PACKAGE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PYPROJECT_PATH = os.path.join(PACKAGE_ROOT, "pyproject.toml") +try: + __version__ = toml.load(PYPROJECT_PATH)["tool"]["poetry"]["version"] +except FileNotFoundError: # pragma: no cover + __version__ = "latest" + +USER_AGENT = f"NautilusTrader/{__version__}" + def clean_version_string(version: str) -> str: """ @@ -61,9 +68,3 @@ def get_package_version_installed(package_name: str) -> str: Return the package version installed for the given `package_name`. """ return version(package_name) - - -try: - __version__ = toml.load(PYPROJECT_PATH)["tool"]["poetry"]["version"] -except FileNotFoundError: # pragma: no cover - __version__ = "latest" diff --git a/nautilus_trader/adapters/betfair/client.py b/nautilus_trader/adapters/betfair/client.py index 474809c7d8d4..4448c8340518 100644 --- a/nautilus_trader/adapters/betfair/client.py +++ b/nautilus_trader/adapters/betfair/client.py @@ -13,7 +13,6 @@ # limitations under the License. # ------------------------------------------------------------------------------------------------- - from betfair_parser.endpoints import ENDPOINTS from betfair_parser.spec.accounts.operations import GetAccountDetails from betfair_parser.spec.accounts.operations import GetAccountFunds @@ -58,6 +57,7 @@ from betfair_parser.spec.navigation import Menu from betfair_parser.spec.navigation import Navigation +import nautilus_trader from nautilus_trader.common.logging import Logger from nautilus_trader.common.logging import LoggerAdapter from nautilus_trader.core.nautilus_pyo3 import HttpClient @@ -128,6 +128,7 @@ def reset_headers(self): self._headers = { "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": nautilus_trader.USER_AGENT, "X-Application": self.app_key, } diff --git a/nautilus_trader/adapters/betfair/config.py b/nautilus_trader/adapters/betfair/config.py index de1631f90e28..3c1e760220f1 100644 --- a/nautilus_trader/adapters/betfair/config.py +++ b/nautilus_trader/adapters/betfair/config.py @@ -13,7 +13,6 @@ # limitations under the License. # ------------------------------------------------------------------------------------------------- - from nautilus_trader.adapters.betfair.providers import BetfairInstrumentProviderConfig from nautilus_trader.config import LiveDataClientConfig from nautilus_trader.config import LiveExecClientConfig diff --git a/nautilus_trader/adapters/binance/http/client.py b/nautilus_trader/adapters/binance/http/client.py index 2b3700e23c92..983fe8d872af 100644 --- a/nautilus_trader/adapters/binance/http/client.py +++ b/nautilus_trader/adapters/binance/http/client.py @@ -73,7 +73,7 @@ def __init__( self._secret: str = secret self._headers: dict[str, Any] = { "Content-Type": "application/json", - "User-Agent": "nautilus-trader/" + nautilus_trader.__version__, + "User-Agent": nautilus_trader.USER_AGENT, "X-MBX-APIKEY": key, } self._client = HttpClient( diff --git a/nautilus_trader/adapters/bybit/http/client.py b/nautilus_trader/adapters/bybit/http/client.py index 9b4f5d7dc6a1..d4d61ad2fee4 100644 --- a/nautilus_trader/adapters/bybit/http/client.py +++ b/nautilus_trader/adapters/bybit/http/client.py @@ -68,7 +68,7 @@ def __init__( self._base_url: str = base_url self._headers: dict[str, Any] = { "Content-Type": "application/json", - "User-Agent": "nautilus-trader/" + nautilus_trader.__version__, + "User-Agent": nautilus_trader.USER_AGENT, "X-BAPI-API-KEY": self._api_key, } self._client = HttpClient( diff --git a/nautilus_trader/adapters/databento/common.py b/nautilus_trader/adapters/databento/common.py index 1d66966fc57e..9c0e20863e7c 100644 --- a/nautilus_trader/adapters/databento/common.py +++ b/nautilus_trader/adapters/databento/common.py @@ -17,6 +17,7 @@ import databento +import nautilus_trader from nautilus_trader.adapters.databento.types import DatabentoPublisher from nautilus_trader.core.correctness import PyCondition from nautilus_trader.model.data import BarType @@ -27,6 +28,11 @@ from nautilus_trader.model.identifiers import Venue +# Update Databento user-agent constant value with NautilusTrader version +if nautilus_trader.USER_AGENT not in databento.common.system.USER_AGENT: + databento.common.system.USER_AGENT += f" {nautilus_trader.USER_AGENT}" + + def check_file_path(path: Path) -> None: """ Check that the file at the given `path` exists and is not empty.