Class: Vexapion::BaseExchanges

Inherits:
Object
  • Object
show all
Defined in:
lib/vexapion/base_exchanges.rb

Overview

Virtual (crypto) Currency Exchanges API wrapper class

Direct Known Subclasses

Bitflyer, Coincheck, Poloniex, Zaif

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, secret = nil) ⇒ BaseExchanges

:stopdoc:



9
10
11
12
13
14
15
16
17
# File 'lib/vexapion/base_exchanges.rb', line 9

def initialize(key = nil, secret = nil)
	@key = key
	@secret = secret
	@conn = HTTPClient.new
	base_time = Time.gm(2017, 1, 1, 0, 0, 0).to_i
	@nonce = (Time.now.to_i - base_time) * 100  #max 100req/s
	@verify_mode = nil
	set_min_interval(0.5)
end

Instance Method Details

#disconnectObject



19
20
21
# File 'lib/vexapion/base_exchanges.rb', line 19

def disconnect
	@conn.terminate
end

#do_command(uri, request) ⇒ Object

:stopdoc:



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vexapion/base_exchanges.rb', line 33

def do_command(uri, request)
	#response = nil
	#begin
		response = @conn.http_request(uri, request, @verify_mode)
	#rescue VexapionRuntimeError => e
	#	raise e
	#rescue HTTPError => e
	#	raise e
	#end

	response == '' ? '' : JSON.parse(response)
end

#get_nonceObject



46
47
48
# File 'lib/vexapion/base_exchanges.rb', line 46

def get_nonce
	@nonce += 1
end

#set_min_interval(sec) ⇒ Object

:startdoc:



24
25
26
# File 'lib/vexapion/base_exchanges.rb', line 24

def set_min_interval(sec)
	@conn.min_interval = sec
end

#set_verify_mode(mode) ⇒ Object



28
29
30
# File 'lib/vexapion/base_exchanges.rb', line 28

def set_verify_mode(mode)
	@verify_mode = mode
end