Module: Deribit

Defined in:
lib/deribit.rb,
lib/deribit/http.rb,
lib/deribit/client.rb,
lib/deribit/naming.rb,
lib/deribit/version.rb,
lib/deribit/websocket.rb,
lib/deribit/authentication.rb

Overview

Root module

Defined Under Namespace

Modules: Naming Classes: Authentication, Client, Error, Http, NotImplementedError, Websocket

Constant Summary collapse

TESTNET_HOST =
'test.deribit.com'
MAINNET_HOST =
'www.deribit.com'
VERSION =
'2.0.2'

Class Method Summary collapse

Class Method Details

.http_signature(env, timestamp, nonce, secret) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/deribit.rb', line 25

def self.http_signature(env, timestamp, nonce, secret)
  # RequestData = UPPERCASE(HTTP_METHOD()) + "\n" + URI() + "\n" + RequestBody + "\n";
  uri = env['url'].path.dup
  uri << '?' << env['url'].query if env['url'].query
  request_data = [env['method'].upcase, uri, env['body'], ''].join "\n"

  signature timestamp, nonce, request_data, secret
end

.signature(timestamp, nonce, data, secret) ⇒ Object



35
36
37
38
39
40
# File 'lib/deribit.rb', line 35

def self.signature(timestamp, nonce, data, secret)
  # StringToSign = Timestamp + "\n" + Nonce + "\n" + Data;
  # Signature = HEX_STRING( HMAC-SHA256( ClientSecret, StringToSign ) );
  string_to_sign = [timestamp, nonce, data].join "\n"
  ::OpenSSL::HMAC.hexdigest('SHA256', secret, string_to_sign)
end