Module: Bybit

Defined in:
lib/bybit/client.rb,
lib/bybit/error.rb,
lib/bybit/session.rb,
lib/bybit/version.rb,
lib/bybit/configuration.rb,
lib/bybit/authentication.rb,
lib/bybit/utils/wire_keys.rb,
lib/bybit/rest_api/bot_service.rb,
lib/bybit/rest_api/p2p_service.rb,
lib/bybit/rest_api/rfq_service.rb,
lib/bybit/rest_api/base_service.rb,
lib/bybit/rest_api/earn_service.rb,
lib/bybit/rest_api/user_service.rb,
lib/bybit/rest_api/asset_service.rb,
lib/bybit/rest_api/trade_service.rb,
lib/bybit/rest_api/broker_service.rb,
lib/bybit/rest_api/market_service.rb,
lib/bybit/rest_api/account_service.rb,
lib/bybit/rest_api/position_service.rb,
lib/bybit/rest_api/affiliate_service.rb,
lib/bybit/rest_api/crypto_loan_service.rb,
lib/bybit/rest_api/spot_margin_service.rb

Overview

gen-sdk-ruby:service-requires:end

Defined Under Namespace

Modules: Authentication, RestApi, Utils Classes: ApiError, AuthError, Client, ClientError, Configuration, ConfigurationError, Error, NetworkError, ParseError, RateLimitError, ServerError, Session, TimeoutError, TransportError

Constant Summary collapse

AUTH_RET_CODES =
[10_002, 10_003, 10_004, 10_005, 10_007, 10_009, 10_010, 10_029].freeze
RATE_LIMIT_RET_CODES =
[10_006, 10_018].freeze
VERSION =
'0.1.0'
BASE_URL_MAINNET =
'https://api.bybit.com'
BASE_URL_TESTNET =
'https://api-testnet.bybit.com'
DEFAULT_RECV_WINDOW =
'5000'
DEFAULT_TIMEOUT =
10

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



25
26
27
# File 'lib/bybit/client.rb', line 25

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.api_error_from(response, http_status: nil) ⇒ Object

Route a V5 response with retCode != 0 to the most specific error subclass.



60
61
62
63
64
65
66
# File 'lib/bybit/error.rb', line 60

def self.api_error_from(response, http_status: nil)
  code = response['retCode']
  return AuthError.new(response, http_status: http_status)      if AUTH_RET_CODES.include?(code)
  return RateLimitError.new(response, http_status: http_status) if RATE_LIMIT_RET_CODES.include?(code)

  ApiError.new(response, http_status: http_status)
end

.configure {|configuration| ... } ⇒ Object

Yields:



29
30
31
# File 'lib/bybit/client.rb', line 29

def configure
  yield configuration
end