Canonical Namespaces
ATS offers extensive flexibility, allowing users to customize their trading systems by adding custom exchange classes, strategy classes, indicators, and fee structures. To streamline this customization process, ATS follows a standardized namespace definition convention.
Namespace Convention
The following naming conventions are used for defining namespaces for different types of custom classes:
Strategy:
strategies:<name of the strategy>
Example:strategies:my_strategy
forStrategy
class incustom_modules/strategies/my_exchange/strategy.py
Exchange:
exchanges:<name of the exchange>
Example:exchanges:my_exchange
forExchange
class incustom_modules/exchanges/my_exchange/exchange.py
Indicator:
indicators:<name of the indicator>
Example:indicators:my_indicator
forIndicator
class incustom_modules/indicators/my_indicator.py
Fee:
fees:<name of the fee class>
Example:fees:custom_fee
forFee
class incustom_modules/fees/my_fee.py
Generating a Path from Namespace
To dynamically resolve the path of a class from its namespace, ATS provides a utility function in the ats/utils/general/helpers
module.
The function get_class_from_namespace(namespace: str)
retrieves the corresponding class based on the given namespace.
Code Example
Here is how you can use the utility function to resolve a class from its namespace:
Key Notes
Namespace Validation: Ensure that the namespace is correctly formatted. It must contain at least two parts separated by a colon (
:
).Supported Namespace Types:
exchanges
for custom exchanges.strategies
for custom strategies.indicators
for custom indicators.fees
for custom fee structures.
Error Handling: If the namespace is invalid or the class is not found, the utility will raise appropriate exceptions (
Exception
orModuleNotFoundError
).
This standardized namespace convention and utility function simplify the process of adding custom classes, ensuring maintainability and reducing errors during development.
Last updated