Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title = "bybit-connector-ruby gitleaks configuration"

[extend]
useDefault = true

[[rules]]
id = "generic-api-key"

[[rules.allowlists]]
description = "Allow documented source commit SHAs in the changelog"
condition = "AND"
regexTarget = "line"
regexes = ['''^\s*-\s+(OpenAPI|Docs):\s+`[0-9a-f]{40}`\s*$''']
paths = ['''(^|/)CHANGELOG\.md$''']
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.2] - 2026-10-13

### Added
- `AccountService#demo_apply_money(...)`
- `AccountService#get_option_asset_info(...)`
- `AccountService#get_pay_info(...)`
- `AccountService#get_trade_info_for_analysis(...)`
- `AssetService#limit_order_callback(...)`
- `CryptoLoanService#get_fixed_available_inventory(...)`
- `CryptoLoanService#get_fixed_repayment_history(...)`
- `CryptoLoanService#supply_fixed(...)`
- `CryptoLoanService#get_flexible_available_inventory(...)`
- `EarnService#list_auto_savings(...)`
- `EarnService#edit_earn_auto_savings(...)`
- `MarketService#get_option_base_coins(...)`
- `PositionService#get_symbol_info(...)`
- `SpotMarginService#get_trade_coin_state(...)`
- `SpotMarginService#query_fixed_available_inventory(...)`
- `SpotMarginService#account_fixed_borrow(...)`
- `SpotMarginService#query_fixed_borrow_contracts(...)`
- `SpotMarginService#query_fixed_borrow_orders(...)`
- `SpotMarginService#query_fixed_borrow_market(...)`
- `SpotMarginService#renew_fixed_borrow(...)`
- `SpotMarginService#get_trade_flexible_available_inventory(...)`
- `SpotMarginService#get_trade_auto_repay_mode(...)`
- `SpotMarginService#query_borrow_liability(...)`
- `SpotMarginService#get_trade_max_borrowable(...)`
- `SpotMarginService#get_trade_repayment_available_amount(...)`
- `SpotMarginService#set_auto_repay_mode(...)`
- `SpotMarginService#spot_margin_set_leverage(...)`
- `SpotMarginService#get_trade_state(...)`
- `SpotMarginService#spot_margin_switch_mode(...)`
- `UserService#query_referral_code(...)`

### Sources
- OpenAPI: `08130d57323d390dea58f15418758e2667c74ce6`
- Docs: `59e3d457dea6b419a14987c19a3aabf4ffb38238`

## [0.1.1] - 2026-07-22

Expand Down
50 changes: 50 additions & 0 deletions lib/bybit/rest_api/account_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,56 @@ def upgrade_to_uta_pro(**kwargs)
params = Bybit::Utils::WireKeys.camelize(params)
@session.sign_request(method: :post, path: '/v5/account/upgrade-to-uta', body: params)
end

# Apply demo funds
#
# POST /v5/account/demo-apply-money
#
# @option kwargs [Integer] :adjust_type Adjustment type, 0-add funds, 1-deduct funds
# @option kwargs [Array] :uta_demo_apply_money Fund application config list
# @note This endpoint requires `base_url: 'https://api-demo.bybit.com'`.
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/demo
def demo_apply_money(**kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs)
@session.sign_request(method: :post, path: '/v5/account/demo-apply-money', body: params)
end

# Get Option Asset Info
#
# GET /v5/account/option-asset-info
#
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/account/option-asset-info
def get_option_asset_info
@session.sign_request(method: :get, path: '/v5/account/option-asset-info')
end

# Get Pay Info
#
# GET /v5/account/pay-info
#
# @option kwargs [String] :coin Coin name, e.g. `USDT`, `BTC`. If not passed, returns all repayment info.
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/account/pay-info
def get_pay_info(**kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs)
@session.sign_request(method: :get, path: '/v5/account/pay-info', params: params)
end

# Get Trade Info For Analysis
#
# GET /v5/account/trade-info-for-analysis
#
# @param symbol [String] Trading pair, e.g. `BTCUSDT`, `ETHUSDT`.
# @option kwargs [Integer] :start_time Query start time in milliseconds timestamp.
# @option kwargs [Integer] :end_time Query end time in milliseconds timestamp.
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/account/trade-info-for-analysis
def get_trade_info_for_analysis(symbol:, **kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(symbol: symbol))
@session.sign_request(method: :get, path: '/v5/account/trade-info-for-analysis', params: params)
end
end
end
end
17 changes: 17 additions & 0 deletions lib/bybit/rest_api/asset_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,23 @@ def small_asset_quote(**kwargs)
params = Bybit::Utils::WireKeys.camelize(params)
@session.sign_request(method: :post, path: '/v5/asset/covert/get-quote', body: params)
end

# Limit order callback notification
#
# POST /v5/asset/exchange/limit-order/callback
#
# @param exchange_tx_id [String] Convert order number
# @param option_type [Integer] Callback type: 1=filled, 2=canceled, 3=failed
# @param time_stamp [Integer] Callback timestamp (milliseconds)
# @param sign [String] Callback signature data
# @param app_id [String] appId of callback business, currently only supports: TimeResearch
# @option kwargs [String] :error_code Error code on failure
# @note This endpoint is generated from the Bybit OpenAPI specification and is not in the public documentation.
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
def limit_order_callback(exchange_tx_id:, option_type:, time_stamp:, sign:, app_id:, **kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(exchangeTxId: exchange_tx_id, optionType: option_type, timeStamp: time_stamp, sign: sign, appId: app_id))
@session.sign_request(method: :post, path: '/v5/asset/exchange/limit-order/callback', body: params)
end
end
end
end
60 changes: 60 additions & 0 deletions lib/bybit/rest_api/crypto_loan_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,66 @@ def repay_flexible_with_collateral(loan_currency:, collateral_coin:, amount:, **
params = Bybit::Utils::WireKeys.camelize(params)
@session.sign_request(method: :post, path: '/v5/crypto-loan-flexible/repay-collateral', body: params)
end

# Get Available Inventory
#
# GET /v5/crypto-loan-fixed/available-inventory
#
# @param currency [String] Coin name, uppercase only
# @param term [String] Fixed term 7: 7 days; 14: 14 days; 30: 30 days; 90: 90 days; 180: 180 days
# @param annual_rate [String] Customizable annual interest rate, e.g., 0.02 means 2%
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/fixed/available-inventory
def get_fixed_available_inventory(currency:, term:, annual_rate:)
params = Bybit::Utils::WireKeys.camelize({ currency: currency, term: term, annualRate: annual_rate })
@session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/available-inventory', params: params)
end

# Get Repayment History
#
# GET /v5/crypto-loan-fixed/repayment-history
#
# @option kwargs [String] :repay_id Repayment ID
# @option kwargs [String] :loan_currency Loan currency filter
# @option kwargs [String] :limit Page size
# @option kwargs [String] :cursor Page cursor
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/fixed/repay-history
def get_fixed_repayment_history(**kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs)
@session.sign_request(method: :get, path: '/v5/crypto-loan-fixed/repayment-history', params: params)
end

# Create Supply Order
#
# POST /v5/crypto-loan-fixed/supply
#
# @param order_currency [String] Currency to lend
# @param order_amount [String] Amount to lend
# @param annual_rate [String] Annual interest rate
# @param term [String] Term in days (7, 14, 30, 90, 180)
# @option kwargs [String] :available_source Fund source for supply order:
# - `0`: Funding account (default)
# - `1`: Flexible savings
# - `2`: Mixed (funding account + flexible savings)
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/fixed/supply
def supply_fixed(order_currency:, order_amount:, annual_rate:, term:, **kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(orderCurrency: order_currency, orderAmount: order_amount, annualRate: annual_rate, term: term))
@session.sign_request(method: :post, path: '/v5/crypto-loan-fixed/supply', body: params)
end

# Get Available Inventory
#
# GET /v5/crypto-loan-flexible/available-inventory
#
# @param currency [String] Coin name, uppercase only
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/new-crypto-loan/flexible/available-inventory
def get_flexible_available_inventory(currency:)
params = Bybit::Utils::WireKeys.camelize({ currency: currency })
@session.sign_request(method: :get, path: '/v5/crypto-loan-flexible/available-inventory', params: params)
end
end
end
end
31 changes: 31 additions & 0 deletions lib/bybit/rest_api/earn_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,37 @@ def set_fixed_term_auto_invest(product_id:, category:, position_id:, status:, **
params = Bybit::Utils::WireKeys.camelize(params)
@session.sign_request(method: :post, path: '/v5/earn/fixed-term/position/auto-invest', body: params)
end

# Get Auto Savings Settings
#
# GET /v5/earn/flexible-saving/auto-savings
#
# @option kwargs [Array] :coins Coin names to query, for example `coins=BTC&coins=ETH`. Omit for all supported coins.
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/finance/earn/flexible-saving/auto-savings
def list_auto_savings(**kwargs)
coins = kwargs[:coins]
if coins.is_a?(Array) && coins.length > 50
raise Bybit::ConfigurationError,
'coins supports at most 50 values'
end
params = Bybit::Utils::WireKeys.camelize(kwargs)
@session.sign_request(method: :get, path: '/v5/earn/flexible-saving/auto-savings', params: params)
end

# Edit Auto Savings Settings
#
# POST /v5/earn/flexible-saving/auto-savings
#
# @param is_selected [Boolean] Whether to enable auto savings
# @option kwargs [String] :coin Coin to change; omit or pass an empty string to change the global setting
# @option kwargs [Boolean] :purchase_immediately When enabling, asynchronously attempt to subscribe the available Funding Account balance; ignored when disabling
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/finance/earn/flexible-saving/auto-savings
def edit_earn_auto_savings(is_selected:, **kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(isSelected: is_selected))
@session.sign_request(method: :post, path: '/v5/earn/flexible-saving/auto-savings', body: params)
end
end
end
end
17 changes: 17 additions & 0 deletions lib/bybit/rest_api/market_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,23 @@ def get_tickers(category:, **kwargs)
params = Bybit::Utils::WireKeys.camelize(params)
@session.public_request(path: '/v5/market/tickers', params: params)
end

# Get Option Base Coins
#
# GET /v5/market/option-base-coins
#
# @option kwargs [String] :underlying_type Underlying asset type. Supports comma-separated values, e.g. `0,2`.
# - `0`: Crypto
# - `1`: Commodity
# - `2`: Stock
# - `3`: Forex
# - `4`: Oil
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/market/option-base-coins
def get_option_base_coins(**kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs)
@session.public_request(path: '/v5/market/option-base-coins', params: params)
end
end
end
end
15 changes: 15 additions & 0 deletions lib/bybit/rest_api/position_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ def switch_position_mode(category:, mode:, **kwargs)
params = Bybit::Utils::WireKeys.camelize(params)
@session.sign_request(method: :post, path: '/v5/position/switch-mode', body: params)
end

# Get Futures Leverage
#
# GET /v5/position/symbol-info
#
# @param category [String] Product type:
# - `linear`: USDT perpetual, USDC contract
# - `inverse`: Inverse perpetual, Inverse futures
# @option kwargs [String] :symbol Symbol name, e.g. `BTCUSDT`, uppercase only
# @return [Hash] Bybit V5 ApiResponse envelope (retCode / retMsg / result / retExtInfo / time).
# @see https://bybit-exchange.github.io/docs/v5/position/batch-lvg
def get_symbol_info(category:, **kwargs)
params = Bybit::Utils::WireKeys.camelize(kwargs.merge(category: category))
@session.sign_request(method: :get, path: '/v5/position/symbol-info', params: params)
end
end
end
end
Loading
Loading