IbkrApi.Config (ibkr_api v1.0.3)

View Source

Configuration settings for the IBKR API client.

This module provides functions to access configuration values with sensible defaults. Values can be overridden in your application configuration.

Example Configuration

config :ibkr_api,
  host: "https://localhost",
  port: "5050",
  rate_limits: [
    global: [limit: 45, time_window_ms: 1_000],
    endpoints: [
      iserver_marketdata_snapshot: [limit: 9, time_window_ms: 1_000],
      # ... other endpoint-specific limits
    ]
  ]

Summary

Functions

Returns the base URL for the IBKR API.

Returns the default rate limit configuration.

Returns the configured host or the default value.

Returns the configured port or the default value.

Returns the rate limiting configuration.

Returns the rate limit configuration for a specific endpoint or global limit.

Validates the rate limit configuration.

Functions

base_url()

Returns the base URL for the IBKR API.

default_rate_limits()

@spec default_rate_limits() :: keyword()

Returns the default rate limit configuration.

host()

Returns the configured host or the default value.

port()

Returns the configured port or the default value.

rate_limit()

@spec rate_limit() :: keyword()

Returns the rate limiting configuration.

Rate limits can be configured via application environment:

config :ibkr_api, :rate_limits,
  global: [limit: 50, time_window_ms: 1_000],
  endpoints: [
    iserver_marketdata_snapshot: [limit: 10, time_window_ms: 1_000],
    iserver_scanner_run: [limit: 1, time_window_ms: 1_000]
  ]

If no configuration is provided, defaults are returned.

rate_limit(key)

Returns the rate limit configuration for a specific endpoint or global limit.

Parameters

  • key: Atom representing either :global or an endpoint name like :iserver_marketdata_snapshot

Returns

  • %{limit: integer, time_window_ms: integer} containing rate limit configuration

validate_rate_limits(config)

@spec validate_rate_limits(keyword()) :: {:ok, keyword()} | {:error, any()}

Validates the rate limit configuration.

Returns {:ok, validated_config} if the configuration is valid, or {:error, error} if the configuration is invalid.