quantlab.acquisition.base.register_source#

quantlab.acquisition.base.register_source(descriptor)[source]#

Register descriptor and return it unchanged.

Call it around a module-level descriptor defined beside the acquisition class it describes, so the module-level name is the descriptor itself.

Parameters:
descriptorSourceDescriptor

The vendor’s descriptor.

Returns:
SourceDescriptor

descriptor itself.

Raises:
ValueError

If descriptor.capabilities is empty, or if a descriptor for the same vendor is already registered. A second market or frequency for a vendor is another Capability on its existing descriptor, not a second descriptor.

Examples

Defined beside the acquisition class it describes:

EXAMPLE_SOURCE = register_source(
    SourceDescriptor(
        vendor="example",
        display_name="Example Vendor",
        symbol_batch_cls=ExampleAcquisition,
        config_factory=functools.partial(
            stock_acquisition_config, vendor="example"
        ),
        capabilities=(
            Capability(market="us_equity", frequency="1d"),
        ),
        required_env=("EXAMPLE_API_KEY",),
    )
)