The Bjarkan SOR SDK uses two main configurations: Orderbook Configuration and Trades Configuration. These configurations define the exchanges, trading pairs, and other essential parameters for your trading activities.
You configure the SDK using the set_config
method:
This method returns a dictionary with the status and a message:
The orderbook configuration defines parameters for fetching and processing orderbook data.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
aggregated | bool | No | False | Whether to aggregate orderbooks across exchanges |
exchanges | List[str] | Yes | - | List of exchange IDs to connect to |
sandbox_mode | Dict[str, bool] | No | {} | Dictionary of exchange IDs to sandbox mode flags |
symbols | List[str] | Yes | - | List of symbols to monitor |
depth | int | Yes | - | Number of price levels to include |
fees_bps | Dict[str, Union[float, Dict[str, float]]] | No | None | Exchange fee rates in basis points |
weighting | Dict[str, Dict[str, float]] | No | None | VWAP weighting configuration |
group | Dict[str, str] | No | None | Symbol grouping configuration |
The fees_bps
parameter allows you to account for exchange fees in orderbook prices. This is essential for accurate cross-exchange price comparisons and arbitrage detection.
Fees are specified in basis points (1 bp = 0.01%). You can set:
"binance": 9.8
"okx": {"BTC/USDT": 7, "ETH/USDT": 8}
The SDK applies these fees to the orderbook data as follows:
adjusted_price = original_price / (1 + fee)
adjusted_price = original_price * (1 + fee)
If the fees_bps
parameter is omitted, no fee adjustments will be applied.
The group
parameter allows you to treat different but related symbols as equivalent. This is useful for stablecoins or similar assets where you want to combine liquidity.
This will combine orderbooks for BTC/USDT and BTC/USDC into a single view.
The weighting
parameter enables Volume Weighted Average Price (VWAP) calculations. This calculates what price you would pay/receive when executing a specific order size, accounting for slippage.
VWAP is calculated by taking the sum of the price times the volume for each order up to the specified target amount, then dividing by the total volume.
Let’s consider a simplified order book for BTC/USDT with a target of 1 BTC:
The VWAP calculation for each exchange would be:
Binance VWAP (1 BTC target):
Coinbase VWAP (1 BTC target):
The resulting VWAP orderbook would look like:
The trades configuration defines parameters for streaming real-time trade data.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
exchanges | List[str] | Yes | - | List of exchange IDs to connect to |
sandbox_mode | Dict[str, bool] | No | {} | Dictionary of exchange IDs to sandbox mode flags |
symbols | List[str] | Yes | - | List of symbols to monitor |
fees_bps | Dict[str, Union[float, Dict[str, float]]] | No | None | Exchange fee rates in basis points |
size | Dict[str, Dict[str, float]] | No | None | Minimum trade size filters |
The size
parameter allows you to filter trades by minimum size. This is particularly useful for:
You can specify minimum sizes in two ways:
"BTC/USDT": {"BTC": 0.1}
(only trades ≥ 0.1 BTC)"ETH/USDT": {"USDT": 10000}
(only trades with value ≥ $10,000)For testing without using real funds, you can enable sandbox/testnet mode for specific exchanges:
This setting applies to both orderbook data collection and order execution. Make sure your API keys are configured for the respective exchange testnet environments when using sandbox mode.
After setting your configurations, you need to explicitly start the data streams:
To stop a running stream:
set_config()
aggregated=True
and contain only one symbolset_config()
for each typeBy properly configuring the Bjarkan SOR SDK, you can customize its behavior to suit your specific trading strategies and requirements. The flexibility of the configuration system allows you to fine-tune data collection, filtering, and execution parameters across multiple exchanges.
The Bjarkan SOR SDK uses two main configurations: Orderbook Configuration and Trades Configuration. These configurations define the exchanges, trading pairs, and other essential parameters for your trading activities.
You configure the SDK using the set_config
method:
This method returns a dictionary with the status and a message:
The orderbook configuration defines parameters for fetching and processing orderbook data.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
aggregated | bool | No | False | Whether to aggregate orderbooks across exchanges |
exchanges | List[str] | Yes | - | List of exchange IDs to connect to |
sandbox_mode | Dict[str, bool] | No | {} | Dictionary of exchange IDs to sandbox mode flags |
symbols | List[str] | Yes | - | List of symbols to monitor |
depth | int | Yes | - | Number of price levels to include |
fees_bps | Dict[str, Union[float, Dict[str, float]]] | No | None | Exchange fee rates in basis points |
weighting | Dict[str, Dict[str, float]] | No | None | VWAP weighting configuration |
group | Dict[str, str] | No | None | Symbol grouping configuration |
The fees_bps
parameter allows you to account for exchange fees in orderbook prices. This is essential for accurate cross-exchange price comparisons and arbitrage detection.
Fees are specified in basis points (1 bp = 0.01%). You can set:
"binance": 9.8
"okx": {"BTC/USDT": 7, "ETH/USDT": 8}
The SDK applies these fees to the orderbook data as follows:
adjusted_price = original_price / (1 + fee)
adjusted_price = original_price * (1 + fee)
If the fees_bps
parameter is omitted, no fee adjustments will be applied.
The group
parameter allows you to treat different but related symbols as equivalent. This is useful for stablecoins or similar assets where you want to combine liquidity.
This will combine orderbooks for BTC/USDT and BTC/USDC into a single view.
The weighting
parameter enables Volume Weighted Average Price (VWAP) calculations. This calculates what price you would pay/receive when executing a specific order size, accounting for slippage.
VWAP is calculated by taking the sum of the price times the volume for each order up to the specified target amount, then dividing by the total volume.
Let’s consider a simplified order book for BTC/USDT with a target of 1 BTC:
The VWAP calculation for each exchange would be:
Binance VWAP (1 BTC target):
Coinbase VWAP (1 BTC target):
The resulting VWAP orderbook would look like:
The trades configuration defines parameters for streaming real-time trade data.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
exchanges | List[str] | Yes | - | List of exchange IDs to connect to |
sandbox_mode | Dict[str, bool] | No | {} | Dictionary of exchange IDs to sandbox mode flags |
symbols | List[str] | Yes | - | List of symbols to monitor |
fees_bps | Dict[str, Union[float, Dict[str, float]]] | No | None | Exchange fee rates in basis points |
size | Dict[str, Dict[str, float]] | No | None | Minimum trade size filters |
The size
parameter allows you to filter trades by minimum size. This is particularly useful for:
You can specify minimum sizes in two ways:
"BTC/USDT": {"BTC": 0.1}
(only trades ≥ 0.1 BTC)"ETH/USDT": {"USDT": 10000}
(only trades with value ≥ $10,000)For testing without using real funds, you can enable sandbox/testnet mode for specific exchanges:
This setting applies to both orderbook data collection and order execution. Make sure your API keys are configured for the respective exchange testnet environments when using sandbox mode.
After setting your configurations, you need to explicitly start the data streams:
To stop a running stream:
set_config()
aggregated=True
and contain only one symbolset_config()
for each typeBy properly configuring the Bjarkan SOR SDK, you can customize its behavior to suit your specific trading strategies and requirements. The flexibility of the configuration system allows you to fine-tune data collection, filtering, and execution parameters across multiple exchanges.