Skip to content

B2C2Client is a tool to interact with the B2C2 API

License

Notifications You must be signed in to change notification settings

ArizenHQ/b2c2-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

B2C2 Client

B2C2 Client is an interface to interact with the B2C2's API, the OTC liquidity provider.

Installation

Bundle and install the gem as a standalone

  • Clone the repository
  • Install Ruby 2.5.0
  • Execute bundle install

Configuration

You can pass multiple variables that will be used in the configuration.

As an initializer

B2C2Client.configure do |config|
  config.endpoint_url = 'URL'
  config.api_token = 'URL'
end

Directly in the application Instance

You can also pass any of those options inline when loading an instance of B2C2Client.

  B2C2Client.new({endpoint_url: 'URL', api_token: 'TOKEN'})

You must specify the environment variable B2C2_ENDPOINT_URL and B2C2_API_TOKEN or a MissingEndpointUrl exception will be raised:

Usage

For launch IRB and load + require automatically lib B2C2Client

$ bundle console
  params = {endpoint_url: 'your_endpoint_url', api_token: 'your_api_token'}
  client = B2C2Client.new(params).private

Where params is , the hash of the possible environment variables.

Then simply call the method you wish to perform:

  client.request_for_quote(query_parameters).perform

Where query_paramters are the possible parameters accepted by B2C2. Please visit the docs for more info.

List of endpoints :

Balance docs

  client.balance.perform

Instruments docs

  client.instruments.perform

Request For Quote docs

  quote = {client_rfq_id: SecureRandom.uuid,quantity: 1,side: 'buy',instrument: 'BTCUSD.SPOT'}
  response = client.request_for_quote(quote).perform

Trade docs

  # for a trade you need to do a Request For Quote before to get a rfq_id and price parameters
  rfq_id = response["rfq_id"]
  price = response["price"]

  trade = {rfq_id: rfq_id,quantity: 1,side: 'buy',instrument: 'BTCUSD.SPOT', price: price}
  client.trade(trade).perform

Environment Variables

Compulsory

(Can also be passed along with parameters)

B2C2_ENDPOINT_URL='URL'
ENDPOINT_API_TOKEN='URL'

Parameters

  • B2C2_ENDPOINT_URL: Endpoint Path for B2C2
  • ENDPOINT_API_TOKEN: API Token for B2C2

About

B2C2Client is a tool to interact with the B2C2 API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages