coin-market 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -0
- data/lib/coin/market.rb +75 -9
- data/lib/coin/market/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98876bf133d99f9c6b3c09e5a36ff41ed17da55b
|
4
|
+
data.tar.gz: 4fce98bbbdd18561490fd3074fb46e04d0fc12ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66f9843a1a9643f217988d524bcc62a3e23121f591435adcb06a8b711af5c6a63dc0fb9e46e8396441990947ffa26b5ec658d18b093de74ca521421b237b020f
|
7
|
+
data.tar.gz: ecd5191bdfa147df13e9d1188d8df055d7d1a149cba83c4a31c2845b9c4c0452708c1d5f294722c4d5fb321c9b8a867d65ca79ebbcc62e3dfce3c316a3aab11c
|
data/README.md
CHANGED
@@ -66,6 +66,68 @@ korbit.get_ticker_detailed_eth_krw
|
|
66
66
|
"change"=>"-50",
|
67
67
|
"changePercent"=>"-0.01"}
|
68
68
|
|
69
|
+
# orderbook
|
70
|
+
korbit.get_orderbook_btc_krw
|
71
|
+
=> {"timestamp"=>1512420519036,
|
72
|
+
"bids"=>
|
73
|
+
[["13446500", "0.37482849", "1"],
|
74
|
+
["13446000", "0.00167337", "1"],
|
75
|
+
["13439500", "0.02678672", "1"],
|
76
|
+
["13439000", "2.54171968", "1"],
|
77
|
+
["13438000", "0.00167436", "1"],
|
78
|
+
["13437500", "0.00167442", "1"],
|
79
|
+
["13436000", "0.00167461", "1"],
|
80
|
+
"asks"=>
|
81
|
+
[["13452000", "1.1448576", "1"],
|
82
|
+
["13453000", "0.61177253", "1"],
|
83
|
+
["13453500", "0.012", "1"],
|
84
|
+
["13455000", "2.39762373", "1"],
|
85
|
+
["13456000", "0.86662262", "1"],
|
86
|
+
["13500000", "103.77050183", "1"]]}
|
87
|
+
|
88
|
+
|
89
|
+
# transactions
|
90
|
+
korbit.get_transactions_btc_krw
|
91
|
+
=> [{"timestamp"=>1512421657884, "tid"=>"3625525", "price"=>"13452000", "amount"=>"0.2766"},
|
92
|
+
{"timestamp"=>1512421646922, "tid"=>"3625524", "price"=>"13452000", "amount"=>"0.117910928534759084"},
|
93
|
+
{"timestamp"=>1512421646778, "tid"=>"3625523", "price"=>"13452000", "amount"=>"0.532089071465240916"},
|
94
|
+
{"timestamp"=>1512421635783, "tid"=>"3625522", "price"=>"13452000", "amount"=>"0.149"},
|
95
|
+
{"timestamp"=>1512421600472, "tid"=>"3625521", "price"=>"13452000", "amount"=>"0.090656038534759084"},
|
96
|
+
{"timestamp"=>1512421600350, "tid"=>"3625520", "price"=>"13451500", "amount"=>"0.038343961465240916"},
|
97
|
+
{"timestamp"=>1512421587120, "tid"=>"3625519", "price"=>"13451500", "amount"=>"0.088465970337880534"},
|
98
|
+
{"timestamp"=>1512421586840, "tid"=>"3625518", "price"=>"13450000", "amount"=>"0.005"},
|
99
|
+
{"timestamp"=>1512421586711, "tid"=>"3625517", "price"=>"13450000", "amount"=>"0.251872720315241636"},
|
100
|
+
{"timestamp"=>1512421575845, "tid"=>"3625516", "price"=>"13450000", "amount"=>"0.756"},
|
101
|
+
{"timestamp"=>1512421568508, "tid"=>"3625515", "price"=>"13450000", "amount"=>"0.0218"},
|
102
|
+
{"timestamp"=>1512421561156, "tid"=>"3625514", "price"=>"13450000", "amount"=>"1.149"},
|
103
|
+
{"timestamp"=>1512421545846, "tid"=>"3625513", "price"=>"13450000", "amount"=>"1.0583"},
|
104
|
+
|
105
|
+
|
106
|
+
# constants
|
107
|
+
korbit.get_constants_btc_krw
|
108
|
+
=> {"minKrwWithdrawal"=>1000,
|
109
|
+
"maxKrwWithdrawal"=>5000000000,
|
110
|
+
"krwWithdrawalFee"=>1000,
|
111
|
+
"btcWithdrawalFee"=>0.001,
|
112
|
+
"minBtcWithdrawal"=>0.0001,
|
113
|
+
"maxBtcWithdrawal"=>5,
|
114
|
+
"minBtcOrder"=>0.001,
|
115
|
+
"maxBtcOrder"=>100,
|
116
|
+
"minBtcPrice"=>1000,
|
117
|
+
"maxBtcPrice"=>100000000,
|
118
|
+
"minTradableLevel"=>2,
|
119
|
+
"btcTickSize"=>500,
|
120
|
+
"minEthOrder"=>0.01,
|
121
|
+
"maxEthOrder"=>1000,
|
122
|
+
"minEthPrice"=>1000,
|
123
|
+
"maxEthPrice"=>100000000,
|
124
|
+
"ethTickSize"=>50,
|
125
|
+
"minEtcOrder"=>0.1,
|
126
|
+
"maxEtcOrder"=>20000,
|
127
|
+
"minEtcPrice"=>100,
|
128
|
+
"maxEtcPrice"=>100000000,
|
129
|
+
"etcTickSize"=>10}
|
130
|
+
|
69
131
|
|
70
132
|
```
|
71
133
|
|
data/lib/coin/market.rb
CHANGED
@@ -16,7 +16,10 @@ module Coin
|
|
16
16
|
class Korbit
|
17
17
|
GET_TICKER = "https://api.korbit.co.kr/v1/ticker"
|
18
18
|
GET_TICKER_DETAILED = "https://api.korbit.co.kr/v1/ticker/detailed"
|
19
|
-
|
19
|
+
GET_ORDERBOOK = "https://api.korbit.co.kr/v1/orderbook"
|
20
|
+
GET_TRANSACTIONS = "https://api.korbit.co.kr/v1/transactions"
|
21
|
+
GET_CONSTANTS = "https://api.korbit.co.kr/v1/constants"
|
22
|
+
|
20
23
|
def self.create_method(currency)
|
21
24
|
define_method "get_ticker_#{currency}" do
|
22
25
|
get_ticker(currency)
|
@@ -25,6 +28,18 @@ module Coin
|
|
25
28
|
define_method "get_ticker_detailed_#{currency}" do
|
26
29
|
get_ticker_detailed(currency)
|
27
30
|
end
|
31
|
+
|
32
|
+
define_method "get_orderbook_#{currency}" do
|
33
|
+
get_orderbook(currency)
|
34
|
+
end
|
35
|
+
|
36
|
+
define_method "get_transactions_#{currency}" do
|
37
|
+
get_transactions(currency)
|
38
|
+
end
|
39
|
+
|
40
|
+
define_method "get_constants_#{currency}" do
|
41
|
+
get_constants(currency)
|
42
|
+
end
|
28
43
|
end
|
29
44
|
|
30
45
|
create_method(BTC_KRW)
|
@@ -32,10 +47,48 @@ module Coin
|
|
32
47
|
create_method(ETC_KRW)
|
33
48
|
create_method(XRP_KRW)
|
34
49
|
create_method(BCH_KRW)
|
50
|
+
|
51
|
+
def get_constants(currency_pair)
|
52
|
+
unless is_supported_currency_pair(currency_pair)
|
53
|
+
raise Exceptions::CannotSupportException, __method__ + currency_pair
|
54
|
+
end
|
55
|
+
|
56
|
+
transactions = _process_api(get_constants_with_currency_pair(currency_pair))
|
57
|
+
|
58
|
+
if transactions.nil?
|
59
|
+
raise Exceptions::NetworkException, __method__ + currency_pair
|
60
|
+
end
|
61
|
+
transactions
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_transactions(currency_pair)
|
65
|
+
unless is_supported_currency_pair(currency_pair)
|
66
|
+
raise Exceptions::CannotSupportException, __method__ + currency_pair
|
67
|
+
end
|
68
|
+
|
69
|
+
transactions = _process_api(get_transactions_with_currency_pair(currency_pair))
|
70
|
+
|
71
|
+
if transactions.nil?
|
72
|
+
raise Exceptions::NetworkException, __method__ + currency_pair
|
73
|
+
end
|
74
|
+
transactions
|
75
|
+
end
|
35
76
|
|
77
|
+
def get_orderbook(currency_pair)
|
78
|
+
unless is_supported_currency_pair(currency_pair)
|
79
|
+
raise Exceptions::CannotSupportException, __method__ + currency_pair
|
80
|
+
end
|
81
|
+
|
82
|
+
orderbook = _process_api(get_orderbook_with_currency_pair(currency_pair))
|
83
|
+
|
84
|
+
if orderbook.nil?
|
85
|
+
raise Exceptions::NetworkException, __method__ + currency_pair
|
86
|
+
end
|
87
|
+
orderbook
|
88
|
+
end
|
36
89
|
|
37
90
|
def get_ticker_detailed(currency_pair)
|
38
|
-
unless
|
91
|
+
unless is_supported_currency_pair(currency_pair)
|
39
92
|
raise Exceptions::CannotSupportException, __method__ + currency_pair
|
40
93
|
end
|
41
94
|
|
@@ -47,13 +100,8 @@ module Coin
|
|
47
100
|
ticker
|
48
101
|
end
|
49
102
|
|
50
|
-
def _process_api(url)
|
51
|
-
http_response = RestClient.get(url)
|
52
|
-
JSON.parse(http_response.body)
|
53
|
-
end
|
54
|
-
|
55
103
|
def get_ticker(currency_pair)
|
56
|
-
unless
|
104
|
+
unless is_supported_currency_pair(currency_pair)
|
57
105
|
raise Exceptions::CannotSupportException, __method__ + currency_pair
|
58
106
|
end
|
59
107
|
|
@@ -67,6 +115,11 @@ module Coin
|
|
67
115
|
|
68
116
|
private
|
69
117
|
|
118
|
+
def _process_api(url)
|
119
|
+
http_response = RestClient.get(url)
|
120
|
+
JSON.parse(http_response.body)
|
121
|
+
end
|
122
|
+
|
70
123
|
def get_ticker_with_currency_pair(currency_pair)
|
71
124
|
GET_TICKER + "?=currency_pair=" + currency_pair
|
72
125
|
end
|
@@ -74,11 +127,24 @@ module Coin
|
|
74
127
|
def get_ticker_detailed_with_currency_pair(currency_pair)
|
75
128
|
GET_TICKER_DETAILED + "?=currency_pair=" + currency_pair
|
76
129
|
end
|
130
|
+
|
131
|
+
def get_orderbook_with_currency_pair(currency_pair)
|
132
|
+
GET_ORDERBOOK + "?=currency_pair=" + currency_pair
|
133
|
+
end
|
134
|
+
|
135
|
+
def get_transactions_with_currency_pair(currency_pair)
|
136
|
+
GET_TRANSACTIONS + "?=currency_pair=" + currency_pair
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_constants_with_currency_pair(currency_pair)
|
140
|
+
GET_CONSTANTS + "?=currency_pair=" + currency_pair
|
141
|
+
end
|
77
142
|
|
78
|
-
def
|
143
|
+
def is_supported_currency_pair(currency_pair)
|
79
144
|
SUPPORT_CURRENCY.include?(currency_pair)
|
80
145
|
end
|
81
146
|
|
147
|
+
|
82
148
|
end
|
83
149
|
end
|
84
150
|
end
|
data/lib/coin/market/version.rb
CHANGED