btcmrb 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2566a4ef1fb0d3202c78ce8c47ffc2de7aaaeac
4
- data.tar.gz: 4c73981d2d96c5fcdb12515b23407bdfd1a42e16
3
+ metadata.gz: ebdf3a922eb937c49d8ea58e6d265fab418872de
4
+ data.tar.gz: 5f29a4d10d323c358fadc07fd1a5d890deb66c17
5
5
  SHA512:
6
- metadata.gz: 4af5a8812bd5bb70875e0a85d0a53a930be60f4c7ac19f3273f3cdd9fe21759412ba3a2e67fffa7e09a3d55faede15c235e3be27302de9b30816470852262b81
7
- data.tar.gz: 7a3fee908a4b72773d373ba0002b7e89393e5b06d677a581f8979448e9fda11e59ac6fbdd8489a2ef373fc5b6ef6ee1760914c02675052123a02578095f619df
6
+ metadata.gz: 30cc022124c5f9913fd9d520cd9fdaeb43f24885a1d8dbb78be72ac21f986d412c4f495f05c5119a1b7bcfa35417181e7d73012d138a50655a9ffe106f71b549
7
+ data.tar.gz: ede7bd022cbf94cad45973d0deef93b604aee0b7a380c0f375d9369685ce5ae5f110a637a6bfd89130186d7288856fa96bcc97fc6fb7fc41ca62b46dc820ba8f
data/README.md CHANGED
@@ -12,7 +12,7 @@ $ gem install btcmrb
12
12
  ```
13
13
  Or in your application's Gemfile:
14
14
  ```
15
- gem 'btcmrb', '~> 0.1.3'
15
+ gem 'btcmrb', '~> 0.1.5'
16
16
  ```
17
17
  ### Create some environment variables
18
18
  https://btcmarkets.net/account/apikey
@@ -54,9 +54,37 @@ https://github.com/BTCMarkets/API/wiki/Trading-API
54
54
  ```ruby
55
55
  client = Btcmrb.new
56
56
  all_orders = Btcmrb::Order.all
57
- # this one doesn't work yet, not sure why not - would you care to submit a pull request?
58
57
  client.send_request(all_orders)
59
58
  # => {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}
59
+
60
+ client = Btcmrb.new
61
+ open_orders = Btcmrb::Order.open_orders
62
+ client.send_request(open_orders)
63
+ # => {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}
64
+
65
+ client = Btcmrb.new
66
+ trade_history = Btcmrb::Order.trade_history
67
+ client.send_request(trade_history)
68
+ # => TBC
69
+
70
+ # A single order
71
+ client = Btcmrb.new
72
+ order_detail = Btcmrb::Order.show(123456789)
73
+ client.send_request(order_detail)
74
+ # => TBC
75
+
76
+ # Multiple orders
77
+ client = Btcmrb.new
78
+ order_detail = Btcmrb::Order.show(123456789,987654321)
79
+ client.send_request(order_detail)
80
+ # => TBC
81
+
82
+ # TODO: Create New Orders
83
+
84
+ client = Btcmrb.new
85
+ order_to_cancel = Btcmrb::Order.cancel(123456789)
86
+ client.send_request(order_to_cancel)
87
+ # => TBC
60
88
  ```
61
89
 
62
90
 
data/lib/btcmrb/client.rb CHANGED
@@ -45,11 +45,11 @@ module Btcmrb
45
45
  private
46
46
 
47
47
  def create_timestamp
48
- (Time.now.to_f * 1000).to_i.to_s
48
+ DateTime.now.strftime('%Q')
49
49
  end
50
50
 
51
51
  def format_request(options)
52
- default = options[:uri] + "\n" + options[:timestamp] + "\n"#+ '{"currency":"AUD", "instrument":"BTC", "limit":"10"}'
52
+ default = options[:uri] + "\n" + options[:timestamp] + "\n"
53
53
  unless options[:body].empty?
54
54
  default = default + options[:body].to_json.to_s
55
55
  end
@@ -75,13 +75,10 @@ module Btcmrb
75
75
 
76
76
  if options[:authentication] && options[:method] == "POST"
77
77
  HTTParty.post(BASE_URI + uri, :headers => headers, :body => options[:body].to_json)
78
-
79
78
  elsif options[:authentication] && options[:method] == "GET"
80
79
  HTTParty.get(BASE_URI + uri, :headers => headers)
81
-
82
80
  else
83
81
  HTTParty.get(BASE_URI + uri)
84
-
85
82
  end
86
83
  end
87
84
 
data/lib/btcmrb/order.rb CHANGED
@@ -8,34 +8,32 @@ module Btcmrb
8
8
  # {"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}
9
9
  # {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}
10
10
 
11
-
12
11
  # Implementation
13
12
  {
14
13
  :uri => "/order/history",
15
- :body => {:currency => "AUD", :instrument => "BTC", :limit => 10},
14
+ :body => {:currency => "AUD", :instrument => "BTC", :limit => 10,"since":1},
16
15
  :verb => "POST",
17
16
  :auth => true
18
17
  }
19
18
  end
20
19
 
21
20
  # Similar to Index, but only returns open orders
22
- def open
21
+ def self.open_orders
23
22
  # Documentation
24
23
  # POST "/order/open"
25
24
  # {"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}
26
25
  # {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}
27
26
 
28
-
29
27
  # Implementation
30
- # {
31
- # :uri => "/order/open",
32
- # :body => {"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}, # Sample Body
33
- # :verb => "POST",
34
- # :auth => true
35
- # }
28
+ {
29
+ :uri => "/order/open",
30
+ :body => {"currency":"AUD","instrument":"BTC","limit":10,"since":1},
31
+ :verb => "POST",
32
+ :auth => true
33
+ }
36
34
  end
37
35
 
38
- def trade_history
36
+ def self.trade_history
39
37
  # Documentation
40
38
  # POST "/order/trade/history"
41
39
  # since parameter - a trade id.
@@ -43,30 +41,31 @@ module Btcmrb
43
41
 
44
42
 
45
43
  # Implementation
46
- # {
47
- # :uri => "/order/trade/history",
48
- # :body => {"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}, # Sample Body
49
- # :verb => "POST",
50
- # :auth => true
51
- # }
44
+ {
45
+ :uri => "/order/trade/history",
46
+ :body => {"currency":"AUD","instrument":"BTC","limit":10,"since":1},
47
+ :verb => "POST",
48
+ :auth => true
49
+ }
52
50
  end
53
51
 
54
- def show
52
+ def self.show(*ids)
55
53
  # Documentation
56
54
  # POST "/order/detail"
57
55
  # {"orderIds":[6840125478]}
58
56
 
59
57
 
60
58
  # Implementation
61
- # {
62
- # :uri => "/order/detail",
63
- # :body => {"orderIds":[6840125478]}, # Sample Body
64
- # :verb => "POST",
65
- # :auth => true
66
- # }
59
+ {
60
+ :uri => "/order/detail",
61
+ :body => {"orderIds":ids},
62
+ :verb => "POST",
63
+ :auth => true
64
+ }
67
65
  end
68
66
 
69
- def create
67
+ def self.create
68
+ raise NotImplementedError
70
69
  # Documentation
71
70
  # POST "/order/create"
72
71
  # The clientRequestId is not currently used but must be specified. Any string is valid.
@@ -85,19 +84,19 @@ module Btcmrb
85
84
  # }
86
85
  end
87
86
 
88
- def cancel
87
+ def self.cancel(id)
89
88
  # Documentation
90
89
  # POST "/order/cancel"
91
90
  # {"orderIds":[6840125478]}
92
91
  # => {"success":true,"errorCode":null,"errorMessage":null,"responses":[{"success":false,"errorCode":3,"errorMessage":"order does not exist.","id":6840125478}]}
93
92
 
94
93
  # Implementation
95
- # {
96
- # :uri => "/order/cancel",
97
- # :body => {"orderIds":[6840125478]}, # Sample Body
98
- # :verb => "POST",
99
- # :auth => true
100
- # }
94
+ {
95
+ :uri => "/order/cancel",
96
+ :body => {"orderIds":id},
97
+ :verb => "POST",
98
+ :auth => true
99
+ }
101
100
  end
102
101
 
103
102
  end
@@ -1,3 +1,3 @@
1
1
  module Btcmrb
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: btcmrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Tennant