Skip to main content

Bybit Trade Connector

Features​

crypto-bybitwsConnector Key
Instruments
FXFUTUREOPTION
Request Types
SUBMITCANCELREPLACE
Order Types
MARKETLIMIT
Time In Force
GTCIOCFOK
Order ID Mapper
SEQUENCE
✗
Order Status Request
✗
Cancel On Disconnect
✓
Commission
✓
Post Only
✓
Fast Cancel
✗
Fast Replace

Notes​

Bybit Server Location​

AWS Singapore, Availability Zone ID: apse1-az3

Commission​

Rate Limits​

Price and Quantity​

IMPORTANT

Both price and quantity should be adjusted according to price_filter and lot_size_filter.
Non-adjusted price or quantity will be silently adjusted on exchange side.

Post Only​

In Bybit API Post Only orders are represented via Bybit Time In Force.
When Post Only flag is defined in an order request, it takes precedence over the specified Time In Force.
If the Post Only flag is present, the request's Time In Force is ignored and the order is placed as Post Only.

Client Order ID​

Client Order ID (orderLinkId) should be unique, with a maximum length of 36 characters.

Source and format of the Client Order ID are controlled by the orderMapperType setting:

Order Mapper TypeClient Order ID sourceRules and Restrictions
SEQUENCEOrder request's sequence numbersequence is numeric. clientOrderIdPrefix setting can be used for customization.
COMPOSITEOrder request's sourceId and orderIdsourceId and orderId are concatenated with : delimiter.

Market Maker Protection​

Market Maker Protection (MMP) is an automated mechanism designed to protect market makers against liquidity risks and over-exposure. It prevents simultaneous trade executions on quotes provided by the market maker within a short time span.

Spot Margin Trading​

Spot Margin Trading (leverageMode = MARGIN) is available only for Unified Trading Account.

Position Mode​

Position mode can be switched for USDT perpetual and Inverse futures. In one-way mode, only one position (Buy or Sell) can be open at a time. In hedge mode, both Buy and Sell positions can be open simultaneously.

There are two ways to set position mode:

  • Per order - via custom order attribute: 6340
  • Per connector - via positionMode settings
ModepositionMode settingsTag 6340
One-Way ModeONE_WAY_MODE0
Buy side of both side modeBUY_BOTH_SIDE_MODE1
Sell side of both side modeSELL_BOTH_SIDE_MODE2

Position mode support by account and contract type:

ProductClassic accountUTA1.0UTA2.0
USDT perpetualSupport one-way & hedge-modeSupport one-way & hedge-modeSupport one-way & hedge-mode
USDC perpetualSupport one-way onlySupport one-way onlySupport one-way only
USDC futuresSupport one-way onlySupport one-way onlySupport one-way only
Inverse perpetualSupport one-way onlySupport one-way onlySupport one-way only
Inverse futuresSupport one-way & hedge-modeSupport one-way & hedge-modeSupport one-way only

Clock Sync Issue​

Bybit can respond with "Params Error" if machine clock is not synchronized.

{"type":"WS Message","content":{"success":false,"ret_msg":"Params Error","op":"auth","conn_id":"chled4kpqfhcpr4memcg-5zwa"}}

Symbology​

Instruments can be requested by category: spot, linear, inverse, option:
https://api.bybit.com/v5/market/instruments-info?limit=1000&category=spot

Configuration​

Connector settings​

ParameterDefault ValueDescription
restUrlwss://stream.bybit.com/v5/tradeTrade request WebSocket URL.
websocketUrlwss://stream.bybit.com/v5/privateOrder event WebSocket URL.
tradeWebsocketUrlwss://stream.bybit.com/v5/tradeTrade request WebSocket URL.
submitRecvWindow1sThe interval (in milliseconds) to specify how long an HTTP request is valid. Default is 1 second.
reduceOnlyfalseReduce Only flag.
leverageModeSPOTLeverage Mode. Valid for spot only. Valid values: SPOT - spot trading, MARGIN: - margin trading.
positionModeNONEPosition Mode. Valid values: NONE, ONE_WAY_MODE, BUY_BOTH_SIDE_MODE, SELL_BOTH_SIDE_MODE.
clientOrderIdPrefixOptional prefix for Client Order ID (aka orderLinkId). Applied only when orderMapperType is SEQUENCE.
orderMapperTypeSEQUENCEType of the mapper which is used to map order to Client Order ID. Supported values: COMPOSITE, SEQUENCE. See Client Order ID section for detailed explanation.
rpiTakerAccessfalseToggle RPI for Taker orders (IOC/FOK). true - order will be eligible to match against RPI quotes, false - not eligible.
useRPIfalseFlag to use RPI (Retail Price Improvement) as the Time In Force for Post Only orders.

Supported order attributes​

KeyDescription
186 value used for Post Only orders submission
6201Reduce Only flag. See Reduce Only Order
6470Offset attribute to determine offset direction. Possible values: OPEN or CLOSE. CLOSE means that order will be send with ReduceOnly flag.
6231Market Maker Protection flag, true means this order is a market maker protection order.
6241Leverage Mode. Whether to borrow. Valid for spot only. 0 - spot trading, 1: - margin trading.
6340Position Mode. Possible values: 0 - One-Way Mode, 1 - Buy side of both side mode, 2 - Sell side of both side mode.

Config sample​

connectors {
BYBIT: ${template.connector.crypto.bybitws} {
settings {
restUrl = "https://api.bybit.com"
websocketUrl = "wss://stream.bybit.com/v5/private"
tradeWebsocketUrl = "wss://stream.bybit.com/v5/trade"

apiKeys: [
{
apiKey = "<API_KEY>"
apiSecret = "<API_SECRET>"
}
]

leverageMode = SPOT # SPOT - spot trading, MARGIN: - margin trading.
positionMode = NONE # NONE, ONE_WAY_MODE, BUY_BOTH_SIDE_MODE, SELL_BOTH_SIDE_MODE
}
}
}