fcoin_ruby_client 0.1.0
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 +7 -0
- data/.github/issue_template.md +12 -0
- data/.github/pull_request_template.md +12 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +12 -0
- data/.rubocop_todo.yml +431 -0
- data/.travis.yml +26 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +176 -0
- data/LICENSE.txt +21 -0
- data/README.md +204 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/fcoin +95 -0
- data/bin/setup +8 -0
- data/examples/cli/realtime_api.md +78 -0
- data/examples/cli/rest_api.md +149 -0
- data/examples/cli/setting.md +39 -0
- data/examples/realtime_api.rb +43 -0
- data/examples/rest_api.rb +47 -0
- data/fcoin_ruby_client.gemspec +39 -0
- data/lib/fcoin/api.rb +47 -0
- data/lib/fcoin/authorization.rb +83 -0
- data/lib/fcoin/cli/endpoint/accounts_task.rb +33 -0
- data/lib/fcoin/cli/endpoint/market_task.rb +98 -0
- data/lib/fcoin/cli/endpoint/orders_task.rb +196 -0
- data/lib/fcoin/cli/endpoint/public_task.rb +59 -0
- data/lib/fcoin/cli/realtime/endpoint_task.rb +107 -0
- data/lib/fcoin/cli.rb +77 -0
- data/lib/fcoin/client.rb +7 -0
- data/lib/fcoin/config/custom_settings.yml +171 -0
- data/lib/fcoin/config/settings.yml +10 -0
- data/lib/fcoin/configuration.rb +95 -0
- data/lib/fcoin/connection.rb +33 -0
- data/lib/fcoin/endpoint/accounts.rb +23 -0
- data/lib/fcoin/endpoint/market.rb +91 -0
- data/lib/fcoin/endpoint/orders.rb +171 -0
- data/lib/fcoin/endpoint/public.rb +51 -0
- data/lib/fcoin/endpoint/utility.rb +14 -0
- data/lib/fcoin/endpoint.rb +13 -0
- data/lib/fcoin/error.rb +4 -0
- data/lib/fcoin/faraday/fcoin_formatter.rb +17 -0
- data/lib/fcoin/formatter/base_formatter.rb +8 -0
- data/lib/fcoin/formatter/depth_formatter.rb +33 -0
- data/lib/fcoin/formatter/ticker_formatter.rb +34 -0
- data/lib/fcoin/formatter.rb +38 -0
- data/lib/fcoin/generators/locale.rb +18 -0
- data/lib/fcoin/generators/templates/locale/locales/en.yml +176 -0
- data/lib/fcoin/generators/templates/locale/locales/ja.yml +176 -0
- data/lib/fcoin/generators/templates/locale/locales/zh_CN.yml +176 -0
- data/lib/fcoin/generators/templates/validation/my_settings.yml +171 -0
- data/lib/fcoin/generators/validation.rb +18 -0
- data/lib/fcoin/realtime/api.rb +38 -0
- data/lib/fcoin/realtime/client.rb +9 -0
- data/lib/fcoin/realtime/endpoint.rb +160 -0
- data/lib/fcoin/realtime/formatter/base_formatter.rb +10 -0
- data/lib/fcoin/realtime/formatter/depth_formatter.rb +37 -0
- data/lib/fcoin/realtime/formatter/ticker_formatter.rb +36 -0
- data/lib/fcoin/realtime/formatter.rb +40 -0
- data/lib/fcoin/realtime/wss.rb +113 -0
- data/lib/fcoin/request.rb +73 -0
- data/lib/fcoin/validator/market_validator.rb +60 -0
- data/lib/fcoin/validator/orders/base_validator.rb +96 -0
- data/lib/fcoin/validator/orders/create_order_limit_validator.rb +54 -0
- data/lib/fcoin/validator/orders/create_order_market_validator.rb +95 -0
- data/lib/fcoin/validator/orders/order_list_validator.rb +33 -0
- data/lib/fcoin/validator/orders_validator.rb +69 -0
- data/lib/fcoin/validator/validator_utility.rb +24 -0
- data/lib/fcoin/validator.rb +58 -0
- data/lib/fcoin/version.rb +3 -0
- data/lib/fcoin.rb +11 -0
- metadata +353 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
require_relative '../../../fcoin'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module Fcoin
|
5
|
+
module EndPoint
|
6
|
+
class OrdersTask < Thor
|
7
|
+
# Create limit order
|
8
|
+
#
|
9
|
+
# curl: POST https://api.fcoin.com/v2/orders
|
10
|
+
#
|
11
|
+
# @note This method can not be invoked without authentication.
|
12
|
+
#
|
13
|
+
# @example Create an order to sell 0.010eth at a price of 1000usdt.
|
14
|
+
# export FCOIN_API_KEY='your_fcoin_api_key'
|
15
|
+
# export FCOIN_SECRET_KEY='your_fcoin_secret_key'
|
16
|
+
# ./bin/fcoin order create_limit --symbol ethusdt --side sell --price 1000 --amount 0.001
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# @see https://developer.fcoin.com/zh.html#4a3e521c3b
|
20
|
+
# @raise [ArgumentError] If the symbol or side or type or price or amount does not have.
|
21
|
+
# @raise [InvalidValueError] If symbol or side or type or price or amount is invalid.
|
22
|
+
# @param symbol [String] Transaction of pair.
|
23
|
+
# @param side [String] Direction of the transaction.
|
24
|
+
# @param type [String] Order type.
|
25
|
+
# @param price [Float]
|
26
|
+
# @param amount [Float]
|
27
|
+
# @return [JSON] Returns receipt contains order_id.
|
28
|
+
desc 'create_limit', 'Create limit order'
|
29
|
+
option :symbol, type: :string, required: true, desc: 'Transaction of pair'
|
30
|
+
option :side, type: :string, required: true, desc: 'Direction of the transaction'
|
31
|
+
option :price, type: :numeric, required: true
|
32
|
+
option :amount, type: :numeric, required: true
|
33
|
+
def create_limit
|
34
|
+
symbol = options[:symbol]
|
35
|
+
side = options[:side]
|
36
|
+
type = :limit
|
37
|
+
price = options[:price]
|
38
|
+
amount = options[:amount]
|
39
|
+
STDOUT.puts client.create_order_limit(symbol: symbol, side: side, type: type, price: price, amount: amount)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get order list.
|
43
|
+
#
|
44
|
+
# curl: GET https://api.fcoin.com/v2/orders
|
45
|
+
#
|
46
|
+
# @note This method can not be invoked without authentication.
|
47
|
+
#
|
48
|
+
# @example get the canceled order list of ethusdt limit 20 per page.
|
49
|
+
# export FCOIN_API_KEY='your_fcoin_api_key'
|
50
|
+
# export FCOIN_SECRET_KEY='your_fcoin_secret_key'
|
51
|
+
# ./bin/fcoin order_list --symbol ethusdt, --states canceled --per_page 20
|
52
|
+
#
|
53
|
+
#
|
54
|
+
# @see https://developer.fcoin.com/zh.html#9094989d10
|
55
|
+
# @raise [ArgumentError] If the symbol or states or per_page does not have.
|
56
|
+
# @raise [InvalidValueError] If symbol or states or per_page is invalid.
|
57
|
+
# @param symbol [String] Transaction of pair.
|
58
|
+
# @param states [String] Order states. states must be incldued in [submitted, partial_filled, canceled, partial_canceled, filled, pending_cancel]
|
59
|
+
# @param page_before [Integer] Query order before page number.
|
60
|
+
# @param page_after [Integer] Query order after page number.
|
61
|
+
# @param per_page [Integer] Order quantity per page. default is 20.
|
62
|
+
# @return [JSON] Returns order list.
|
63
|
+
desc 'list', 'Get order list'
|
64
|
+
option :symbol, type: :string, required: true, desc: 'Transaction of pair'
|
65
|
+
option :states, type: :string, required: true, desc: 'Order states. states must be incldued in [submitted, partial_filled, canceled, partial_canceled, filled, pending_cancel]'
|
66
|
+
option :page_before, type: :numeric, desc: 'Query order before page number', default: nil
|
67
|
+
option :page_after, type: :numeric, desc: 'Query order after page number', default: nil
|
68
|
+
option :per_page, type: :numeric, desc: 'Order quantity per page', default: 20
|
69
|
+
def list
|
70
|
+
symbol = options[:symbol]
|
71
|
+
states = options[:states]
|
72
|
+
page_before = options[:page_before]
|
73
|
+
page_after = options[:page_after]
|
74
|
+
per_page = options[:per_page]
|
75
|
+
STDOUT.puts client.order_list(symbol: symbol, states: states, page_before: page_before, page_after: page_after, per_page: per_page)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Query order.
|
79
|
+
#
|
80
|
+
# curl: GET https://api.fcoin.com/v2/orders/$order_id
|
81
|
+
#
|
82
|
+
# @note This method can not be invoked without authentication.
|
83
|
+
#
|
84
|
+
# @example query order specified by order_id.
|
85
|
+
# export FCOIN_API_KEY='your_fcoin_api_key'
|
86
|
+
# export FCOIN_SECRET_KEY='your_fcoin_secret_key'
|
87
|
+
# ./bin/fcoin order --order_id L7rbALEIoI0ymo3uOXBF4gT4Bl********jvptIv2U=
|
88
|
+
#
|
89
|
+
#
|
90
|
+
# @see https://developer.fcoin.com/zh.html#5faf03be01
|
91
|
+
# @raise [ArgumentError] If the order_id does not have.
|
92
|
+
# @param order_id [String]
|
93
|
+
# @return [JSON] Returns order specified by order_id.
|
94
|
+
desc 'reference', 'Ouery order'
|
95
|
+
option :order_id, type: :string, required: true
|
96
|
+
def reference
|
97
|
+
order_id = options[:order_id]
|
98
|
+
STDOUT.puts client.order(order_id: order_id)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Cancel order.
|
102
|
+
#
|
103
|
+
# curl: POST https://api.fcoin.com/v2/orders/$order_id/submit-cancel
|
104
|
+
#
|
105
|
+
# @note This method can not be invoked without authentication.
|
106
|
+
#
|
107
|
+
# @example cancel order specified by order_id.
|
108
|
+
# export FCOIN_API_KEY='your_fcoin_api_key'
|
109
|
+
# export FCOIN_SECRET_KEY='your_fcoin_secret_key'
|
110
|
+
# ./bin/fcoin cancel_order --order_id nMEC_VrW0LYlP4iCcWzmdL50jFrvNWZoaQxvZSjeUSA=
|
111
|
+
#
|
112
|
+
#
|
113
|
+
# @see https://developer.fcoin.com/zh.html#299126e3bf
|
114
|
+
# @raise [ArgumentError] If the order_id does not have.
|
115
|
+
# @param order_id [String]
|
116
|
+
# @return [JSON]
|
117
|
+
desc 'cancel', 'Cancel order'
|
118
|
+
option :order_id, type: :string, required: true
|
119
|
+
def cancel
|
120
|
+
order_id = options[:order_id]
|
121
|
+
STDOUT.puts client.cancel_order(order_id: order_id)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Query the transaction record for the specified by order_id.
|
125
|
+
#
|
126
|
+
# curl: GET https://api.fcoin.com/v2/orders/$order_id/match-results
|
127
|
+
#
|
128
|
+
# @note This method can not be invoked without authentication.
|
129
|
+
#
|
130
|
+
# @example Query the transaction record for the specified by order_id.
|
131
|
+
# export FCOIN_API_KEY='your_fcoin_api_key'
|
132
|
+
# export FCOIN_SECRET_KEY='your_fcoin_secret_key'
|
133
|
+
# ./bin/fcoin order_transaction --order_id kW3cRiXIGHG-cHNdter*********qfoMzbeHEQcqp4=
|
134
|
+
#
|
135
|
+
#
|
136
|
+
# @see https://developer.fcoin.com/zh.html#152112dfd6
|
137
|
+
# @raise [ArgumentError] If the order_id does not have.
|
138
|
+
# @param order_id [String]
|
139
|
+
# @return [JSON] Returns transaction record for the specified by order_id.
|
140
|
+
desc 'transaction', 'Query the transaction record for the specified by order_id'
|
141
|
+
option :order_id, type: :string, required: true
|
142
|
+
def transaction
|
143
|
+
order_id = options[:order_id]
|
144
|
+
STDOUT.puts client.order_transaction(order_id: order_id)
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
# TODO: After checking the operation, go to the public
|
150
|
+
#
|
151
|
+
# Create market order
|
152
|
+
#
|
153
|
+
# curl: POST https://api.fcoin.com/v2/orders
|
154
|
+
#
|
155
|
+
# @note This method can not be invoked without authentication.
|
156
|
+
#
|
157
|
+
# @example Create an order to sell 0.010eth at a price of 1000usdt.
|
158
|
+
# export FCOIN_API_KEY='your_fcoin_api_key'
|
159
|
+
# export FCOIN_SECRET_KEY='your_fcoin_secret_key'
|
160
|
+
# ./bin/fcoin order create_market --symbol ethusdt --side sell --amount 0.001
|
161
|
+
#
|
162
|
+
#
|
163
|
+
# @see https://developer.fcoin.com/zh.html#4a3e521c3b
|
164
|
+
# @raise [ArgumentError] If the symbol or side or type or price or amount does not have.
|
165
|
+
# @raise [InvalidValueError] If symbol or side or type or price or amount is invalid.
|
166
|
+
# @param symbol [String] Transaction of pair
|
167
|
+
# @param side [String] Direction of the transaction
|
168
|
+
# @param type [String] Order type
|
169
|
+
# @param amount [Float] This is valid if side is sell
|
170
|
+
# @param total [Float] This is valid if side is buy
|
171
|
+
# @return [JSON] Returns receipt contains order_id
|
172
|
+
desc 'create_market', 'Create market order'
|
173
|
+
option :symbol, type: :string, required: true, desc: 'Transaction of pair'
|
174
|
+
option :side, type: :string, required: true, desc: 'Direction of the transaction'
|
175
|
+
option :amount, type: :numeric
|
176
|
+
option :total, type: :numeric
|
177
|
+
def create_market
|
178
|
+
symbol = options[:symbol]
|
179
|
+
side = options[:side]
|
180
|
+
type = :market
|
181
|
+
amount = options[:amount]
|
182
|
+
total = options[:total]
|
183
|
+
case side.to_sym
|
184
|
+
when :sell
|
185
|
+
STDOUT.puts client.create_order_market(symbol: symbol, side: side, type: type, amount: amount)
|
186
|
+
when :buy
|
187
|
+
STDOUT.puts client.create_order_market(symbol: symbol, side: side, type: type, total: total)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def client
|
192
|
+
Fcoin::Client.new
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative '../../../fcoin'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module Fcoin
|
5
|
+
module EndPoint
|
6
|
+
class PublicTask < Thor
|
7
|
+
# Get server time
|
8
|
+
#
|
9
|
+
# curl: GET https://api.fcoin.com/v2/public/server-time
|
10
|
+
#
|
11
|
+
# @example get server time
|
12
|
+
# ./bin/fcoin public server_time #=> {"status":0,"data":1531562028166}
|
13
|
+
#
|
14
|
+
#
|
15
|
+
# @see https://developer.fcoin.com/zh.html#8aa898cda7
|
16
|
+
# @return [JSON]
|
17
|
+
desc 'server_time', 'Get server time'
|
18
|
+
def server_time
|
19
|
+
STDOUT.puts client.public_server_time
|
20
|
+
end
|
21
|
+
|
22
|
+
# Display available currency
|
23
|
+
#
|
24
|
+
# curl: GET https://api.fcoin.com/v2/public/currencies
|
25
|
+
#
|
26
|
+
# @example Display available currency
|
27
|
+
# ./bin/fcoin public currencies
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# @see https://developer.fcoin.com/zh.html#0fd2e492e6
|
31
|
+
# @return [JSON]
|
32
|
+
desc 'currencies', 'Display available currency'
|
33
|
+
def currencies
|
34
|
+
STDOUT.puts client.public_currencies
|
35
|
+
end
|
36
|
+
|
37
|
+
# Query available transaction pairs
|
38
|
+
#
|
39
|
+
# curl: GET https://api.fcoin.com/v2/public/symbols
|
40
|
+
#
|
41
|
+
# @example Query available transaction pairs
|
42
|
+
# ./bin/fcoin public symbols
|
43
|
+
#
|
44
|
+
#
|
45
|
+
# @see https://developer.fcoin.com/zh.html#a266e284f4
|
46
|
+
# @return [JSON]
|
47
|
+
desc 'symbols', 'Query available transaction pairs'
|
48
|
+
def symbols
|
49
|
+
STDOUT.puts client.public_symbols
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def client
|
55
|
+
@client = Fcoin::Client.new
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require_relative '../../../fcoin'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module Fcoin
|
5
|
+
module RealTime
|
6
|
+
class EndPointTask < Thor
|
7
|
+
# Subscribe to ticker information
|
8
|
+
#
|
9
|
+
# @example Subscribe to ticker information of ethusdt
|
10
|
+
# ./bin/fcoin subscribe ticker --symbol ethusdt
|
11
|
+
#
|
12
|
+
#
|
13
|
+
# @see https://developer.fcoin.com/zh.html#ticker
|
14
|
+
# @raise [ArgumentError] If the symbol does not have.
|
15
|
+
# @param symbol [String] Transaction pair.
|
16
|
+
# @yieldreturn Process block arguments
|
17
|
+
desc 'ticker', 'Subscribe to ticker information'
|
18
|
+
option :symbol, type: :string, required: true, desc: 'Transaction pair'
|
19
|
+
def ticker
|
20
|
+
# @see bin/fcoin
|
21
|
+
end
|
22
|
+
|
23
|
+
# Subscribe to depth information
|
24
|
+
#
|
25
|
+
# @example Subscribe to depth information of ethusdt specified by L20 level
|
26
|
+
# ./bin/fcoin subscribe depth --symbol ethusdt --level L20
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @see https://developer.fcoin.com/zh.html#50f4407ea4
|
30
|
+
# @raise [ArgumentError] If the symbol or level does not have.
|
31
|
+
# @raise [InvalidValueError] If symbol or level is invalid.
|
32
|
+
# @param symbol [String] Transaction pair.
|
33
|
+
# @param level [String] Level of depth chart. level must be included in [L20, L40, full].
|
34
|
+
# @yieldreturn Process block arguments.
|
35
|
+
desc 'depth', 'Subscribe to depth information'
|
36
|
+
option :symbol, type: :string, required: true, desc: 'Transaction pair'
|
37
|
+
option :level, type: :string, required: true, desc: 'Level of depth chart. level must be included in [L20, L40, full]'
|
38
|
+
def depth
|
39
|
+
# @see bin/fcoin
|
40
|
+
end
|
41
|
+
|
42
|
+
# Subscribe to trade information
|
43
|
+
#
|
44
|
+
# @example Subscribe to trade information of ethusdt limit 5
|
45
|
+
# ./bin/fcoin subscribe trade --symbol ethusdt --limit 5
|
46
|
+
#
|
47
|
+
#
|
48
|
+
# @see https://developer.fcoin.com/zh.html#6477a1394e
|
49
|
+
# @raise [ArgumentError] If the symbol or level does not have.
|
50
|
+
# @raise [InvalidValueError] If symbol or level is invalid.
|
51
|
+
# @param symbol [String] Transaction pair.
|
52
|
+
# @param limit [Integer]
|
53
|
+
# @yieldreturn Process block arguments
|
54
|
+
desc 'trade', 'Subscribe to trade information'
|
55
|
+
option :symbol, type: :string, required: true, desc: 'Transaction pair'
|
56
|
+
option :limit, type: :numeric, default: 20
|
57
|
+
def trade
|
58
|
+
# @see bin/fcoin
|
59
|
+
end
|
60
|
+
|
61
|
+
# Subscribe to candle information
|
62
|
+
#
|
63
|
+
# @example Subscribe to candle information of ethusdt limit 5
|
64
|
+
# ./bin/fcoin subscribe candle --symbol ethusdt --resolution MN --limit 5
|
65
|
+
#
|
66
|
+
#
|
67
|
+
# @see https://developer.fcoin.com/zh.html#candle
|
68
|
+
# @raise [ArgumentError] If the symbol or resolution does not have.
|
69
|
+
# @raise [InvalidValueError] If symbol or resolution is invalid.
|
70
|
+
# @param symbol [String] Transaction pair.
|
71
|
+
# @param resolution [String] period of candles chart. resolution must be included in [M1, M3, M5, M15, M30, H1, H4, H6, D1, W1, MN].
|
72
|
+
# @param limit [Integer]
|
73
|
+
# @yieldreturn Process block arguments
|
74
|
+
desc 'candle', 'Subscribe to candle information'
|
75
|
+
option :symbol, type: :string, required: true, desc: 'Transaction pair'
|
76
|
+
option :resolution, type: :string, required: true, desc: 'period of candles chart. resolution must be included in [M1, M3, M5, M15, M30, H1, H4, H6, D1, W1, MN]'
|
77
|
+
option :limit, type: :numeric, default: 20
|
78
|
+
def candle
|
79
|
+
# @see bin/fcoin
|
80
|
+
end
|
81
|
+
|
82
|
+
# Subscribe to topics
|
83
|
+
#
|
84
|
+
# @example Subscribe to topics
|
85
|
+
# ./bin/fcoin subscribe topics
|
86
|
+
#
|
87
|
+
#
|
88
|
+
# @yieldreturn Process block arguments
|
89
|
+
desc 'topics', 'Subscribe to topics'
|
90
|
+
def topics
|
91
|
+
# @see bin/fcoin
|
92
|
+
end
|
93
|
+
|
94
|
+
# Subscribe to server time
|
95
|
+
#
|
96
|
+
# @example Subscribe to Subscribe to server time
|
97
|
+
# ./bin/fcoin subscribe hello
|
98
|
+
#
|
99
|
+
#
|
100
|
+
# @yieldreturn Process block arguments
|
101
|
+
desc 'hello', 'Subscribe to server time'
|
102
|
+
def hello
|
103
|
+
# @see bin/fcoin
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/fcoin/cli.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative '../fcoin'
|
2
|
+
require_relative 'cli/endpoint/accounts_task'
|
3
|
+
require_relative 'cli/endpoint/market_task'
|
4
|
+
require_relative 'cli/endpoint/orders_task'
|
5
|
+
require_relative 'cli/endpoint/public_task'
|
6
|
+
require_relative 'cli/realtime/endpoint_task'
|
7
|
+
|
8
|
+
require 'thor'
|
9
|
+
|
10
|
+
module Fcoin
|
11
|
+
class ValidationTask < Thor
|
12
|
+
# Create validation setting file
|
13
|
+
#
|
14
|
+
# @example Create validation setting file in ./config
|
15
|
+
# ./bin/fcoin validation init --path ./config
|
16
|
+
# create
|
17
|
+
# create my_settings.yml
|
18
|
+
#
|
19
|
+
#
|
20
|
+
# @see https://nandovieira.com/creating-generators-and-executables-with-thor
|
21
|
+
# @option [String] :path(./) Specify path where you want to create a configuration file for validation
|
22
|
+
desc 'init', 'Create validation setting file'
|
23
|
+
option :path, type: :string, desc: "Path that you want to copy validation setting file"
|
24
|
+
def init
|
25
|
+
generator = Generators::Validation.new
|
26
|
+
generator.destination_root = options[:path] || '.'
|
27
|
+
generator.invoke_all
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class LocaleTask < Thor
|
32
|
+
# Create locale file. For example, use in rails project and so on.
|
33
|
+
#
|
34
|
+
# @example Create locale file in ./config
|
35
|
+
# ./bin/fcoin locale init --path ./config
|
36
|
+
# exist
|
37
|
+
# create .DS_Store
|
38
|
+
# create locales/en.yml
|
39
|
+
# create locales/ja.yml
|
40
|
+
# create locales/zh_CN.yml
|
41
|
+
#
|
42
|
+
#
|
43
|
+
# @option [String] :path(./) Specify path where you want to create locales file for using rails project and so on.
|
44
|
+
desc 'init', 'Create locale file'
|
45
|
+
option :path, type: :string, desc: 'Path that you want to copy locale file'
|
46
|
+
def init
|
47
|
+
generator = Generators::Locale.new
|
48
|
+
generator.destination_root = options[:path] || '.'
|
49
|
+
generator.invoke_all
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class CLI < Thor
|
54
|
+
# Print Version
|
55
|
+
#
|
56
|
+
# @example Print current version
|
57
|
+
# ./bin/fcoin version
|
58
|
+
# fconi_ruby_client v0.1.0
|
59
|
+
desc 'version', 'Print Version'
|
60
|
+
def version
|
61
|
+
STDOUT.puts "fconi_ruby_client v#{Fcoin::VERSION}"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Register as command of cli
|
65
|
+
#
|
66
|
+
# @see https://stackoverflow.com/questions/5663519/namespacing-thor-commands-in-a-standalone-ruby-executable
|
67
|
+
register(Fcoin::ValidationTask, 'validation', 'validation', 'Validation Setting')
|
68
|
+
register(Fcoin::LocaleTask, 'locale', 'locale', 'Locale Setting')
|
69
|
+
# REST API
|
70
|
+
register(Fcoin::EndPoint::AccountsTask, 'account', 'account', 'Get Account Information')
|
71
|
+
register(Fcoin::EndPoint::MarketTask, 'market', 'market', 'Get Market Information')
|
72
|
+
register(Fcoin::EndPoint::OrdersTask, 'order', 'order', 'Operate Order')
|
73
|
+
register(Fcoin::EndPoint::PublicTask, 'public', 'public', 'Get Public Information')
|
74
|
+
# Websocket API
|
75
|
+
register(Fcoin::RealTime::EndPointTask, 'subscribe', 'subscribe', 'Subscribe topic')
|
76
|
+
end
|
77
|
+
end
|
data/lib/fcoin/client.rb
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
---
|
2
|
+
fcoin:
|
3
|
+
validation:
|
4
|
+
limit:
|
5
|
+
sell:
|
6
|
+
mainboard_A:
|
7
|
+
- { symbol: 'btcusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
8
|
+
- { symbol: 'ethusdt', amount: { min: 0.001, max: 10000 }, price: { min: 1, max: 10000 } }
|
9
|
+
- { symbol: 'bchusdt', amount: { min: 0.001, max: 5000 }, price: { min: 1, max: 10000 } }
|
10
|
+
- { symbol: 'ltcusdt', amount: { min: 0.001, max: 40000 }, price: { min: 1, max: 10000 } }
|
11
|
+
- { symbol: 'etcusdt', amount: { min: 0.001, max: 400000 },price: { min: 1, max: 10000 } }
|
12
|
+
- { symbol: 'xrpusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
13
|
+
mainboard_B:
|
14
|
+
- { symbol: 'ftusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
15
|
+
- { symbol: 'ftbtc', amount: { min: 1, max: 10000 }, price: { min: 0.0000001, max: 10000 } }
|
16
|
+
- { symbol: 'fteth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
17
|
+
- { symbol: 'zipeth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
18
|
+
- { symbol: 'omgeth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
19
|
+
- { symbol: 'btmusdt',amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
20
|
+
- { symbol: 'zrxeth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
21
|
+
- { symbol: 'bnbusdt',amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
22
|
+
- { symbol: 'zipusdt',amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
23
|
+
- { symbol: 'fieth', amount: { min: 1, max: 10000 }, price: { min: 0.0000011, max: 10000 } }
|
24
|
+
- { symbol: 'fiusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
25
|
+
gpm:
|
26
|
+
- { symbol: 'fcandyusdt', amount: { min: 0.001, max: 10000 }, price: { min: 1, max: 10000 } }
|
27
|
+
- { symbol: 'icxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
28
|
+
- { symbol: 'zileth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
29
|
+
- { symbol: 'aeeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
30
|
+
- { symbol: '777eth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
31
|
+
- { symbol: 'guseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
32
|
+
- { symbol: 'cccxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
33
|
+
- { symbol: 'bancaeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
34
|
+
- { symbol: 'praeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
35
|
+
- { symbol: 'dcceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
36
|
+
- { symbol: 'ssseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
37
|
+
- { symbol: 'mdteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
38
|
+
- { symbol: 'tsteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
39
|
+
- { symbol: 'pmdeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
40
|
+
- { symbol: 'rteeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
41
|
+
- { symbol: 'xpseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
42
|
+
- { symbol: 'tcteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
43
|
+
- { symbol: 'dwseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
44
|
+
- { symbol: 'ngoteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
45
|
+
- { symbol: 'ateth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
46
|
+
- { symbol: 'soceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
47
|
+
- { symbol: 'blzeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
48
|
+
- { symbol: 'ocneth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
49
|
+
- { symbol: 'datxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
50
|
+
- { symbol: 'gtceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
51
|
+
- { symbol: 'leteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
52
|
+
- { symbol: 'dageth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
53
|
+
- { symbol: 'yeeeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
54
|
+
- { symbol: 'aaaeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
55
|
+
- { symbol: 'nceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
56
|
+
- { symbol: 'arpeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
57
|
+
- { symbol: 'grameth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
58
|
+
- { symbol: 'ifoodeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
59
|
+
- { symbol: 'hpceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
60
|
+
- { symbol: 'sgcceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
61
|
+
- { symbol: '3dbeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
62
|
+
- { symbol: 'xmxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
63
|
+
- { symbol: 'rcteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
64
|
+
- { symbol: 'citeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
65
|
+
- { symbol: 'eeseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
66
|
+
- { symbol: 'faireth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
67
|
+
- { symbol: 'brmeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
68
|
+
- { symbol: 'sdaeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
69
|
+
- { symbol: 'cbreth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
70
|
+
buy:
|
71
|
+
mainboard_A:
|
72
|
+
- { symbol: 'btcusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
73
|
+
- { symbol: 'ethusdt', amount: { min: 0.001, max: 10000 }, price: { min: 1, max: 10000 } }
|
74
|
+
- { symbol: 'bchusdt', amount: { min: 0.001, max: 5000 }, price: { min: 1, max: 10000 } }
|
75
|
+
- { symbol: 'ltcusdt', amount: { min: 0.001, max: 40000 }, price: { min: 1, max: 10000 } }
|
76
|
+
- { symbol: 'etcusdt', amount: { min: 0.001, max: 400000 },price: { min: 1, max: 10000 } }
|
77
|
+
- { symbol: 'xrpusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
78
|
+
mainboard_B:
|
79
|
+
- { symbol: 'ftusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
80
|
+
- { symbol: 'ftbtc', amount: { min: 1, max: 10000 }, price: { min: 0.0000001, max: 10000 } }
|
81
|
+
- { symbol: 'fteth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
82
|
+
- { symbol: 'zipeth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
83
|
+
- { symbol: 'omgeth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
84
|
+
- { symbol: 'btmusdt',amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
85
|
+
- { symbol: 'zrxeth', amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
86
|
+
- { symbol: 'bnbusdt',amount: { min: 1, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
87
|
+
- { symbol: 'zipusdt',amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
88
|
+
- { symbol: 'fieth', amount: { min: 1, max: 10000 }, price: { min: 0.0000011, max: 10000 } }
|
89
|
+
- { symbol: 'fiusdt', amount: { min: 1, max: 10000 }, price: { min: 1, max: 10000 } }
|
90
|
+
gpm:
|
91
|
+
- { symbol: 'fcandyusdt', amount: { min: 0.001, max: 10000 }, price: { min: 1, max: 10000 } }
|
92
|
+
- { symbol: 'icxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
93
|
+
- { symbol: 'zileth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
94
|
+
- { symbol: 'aeeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
95
|
+
- { symbol: '777eth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
96
|
+
- { symbol: 'guseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
97
|
+
- { symbol: 'cccxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
98
|
+
- { symbol: 'bancaeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
99
|
+
- { symbol: 'praeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
100
|
+
- { symbol: 'dcceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
101
|
+
- { symbol: 'ssseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
102
|
+
- { symbol: 'mdteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
103
|
+
- { symbol: 'tsteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
104
|
+
- { symbol: 'pmdeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
105
|
+
- { symbol: 'rteeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
106
|
+
- { symbol: 'xpseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
107
|
+
- { symbol: 'tcteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
108
|
+
- { symbol: 'dwseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
109
|
+
- { symbol: 'ngoteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
110
|
+
- { symbol: 'ateth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
111
|
+
- { symbol: 'soceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
112
|
+
- { symbol: 'blzeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
113
|
+
- { symbol: 'ocneth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
114
|
+
- { symbol: 'datxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
115
|
+
- { symbol: 'gtceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
116
|
+
- { symbol: 'leteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
117
|
+
- { symbol: 'dageth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
118
|
+
- { symbol: 'yeeeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
119
|
+
- { symbol: 'aaaeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
120
|
+
- { symbol: 'nceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
121
|
+
- { symbol: 'arpeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
122
|
+
- { symbol: 'grameth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
123
|
+
- { symbol: 'ifoodeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
124
|
+
- { symbol: 'hpceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
125
|
+
- { symbol: 'sgcceth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
126
|
+
- { symbol: '3dbeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
127
|
+
- { symbol: 'xmxeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
128
|
+
- { symbol: 'rcteth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
129
|
+
- { symbol: 'citeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
130
|
+
- { symbol: 'eeseth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
131
|
+
- { symbol: 'faireth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
132
|
+
- { symbol: 'brmeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
133
|
+
- { symbol: 'sdaeth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
134
|
+
- { symbol: 'cbreth', amount: { min: 0.01, max: 10000 }, price: { min: 0.000001, max: 10000 } }
|
135
|
+
market:
|
136
|
+
valid:
|
137
|
+
sell:
|
138
|
+
mainboard_A:
|
139
|
+
- { symbol: 'btcusdt', amount: { min: 1, max: 10000 } }
|
140
|
+
- { symbol: 'ethusdt', amount: { min: 0.001, max: 10000 } }
|
141
|
+
- { symbol: 'bchusdt', amount: { min: 0.001, max: 5000 } }
|
142
|
+
- { symbol: 'ltcusdt', amount: { min: 0.001, max: 40000 } }
|
143
|
+
- { symbol: 'etcusdt', amount: { min: 0.001, max: 400000 } }
|
144
|
+
- { symbol: 'xrpusdt', amount: { min: 1, max: 10000 } }
|
145
|
+
mainboard_B:
|
146
|
+
gpm:
|
147
|
+
buy:
|
148
|
+
mainboard_A:
|
149
|
+
- { symbol: 'btcusdt', total: { min: 1, max: 10000 } }
|
150
|
+
- { symbol: 'ethusdt', total: { min: 0.001, max: 10000 } }
|
151
|
+
- { symbol: 'bchusdt', total: { min: 0.001, max: 5000 } }
|
152
|
+
- { symbol: 'ltcusdt', total: { min: 0.001, max: 40000 } }
|
153
|
+
- { symbol: 'etcusdt', total: { min: 0.001, max: 400000 } }
|
154
|
+
- { symbol: 'xrpusdt', total: { min: 1, max: 10000 } }
|
155
|
+
mainboard_B:
|
156
|
+
gpm:
|
157
|
+
invalid:
|
158
|
+
sell:
|
159
|
+
mainboard_A:
|
160
|
+
mainboard_B:
|
161
|
+
- fiusdt
|
162
|
+
- fieth
|
163
|
+
gpm:
|
164
|
+
- fcandyusdt
|
165
|
+
buy:
|
166
|
+
mainboard_A:
|
167
|
+
mainboard_B:
|
168
|
+
- fiusdt
|
169
|
+
- fieth
|
170
|
+
gpm:
|
171
|
+
- fcandyusdt
|
@@ -0,0 +1,10 @@
|
|
1
|
+
---
|
2
|
+
fcoin:
|
3
|
+
validation:
|
4
|
+
params:
|
5
|
+
side: [buy, sell]
|
6
|
+
type: [limit, market]
|
7
|
+
resolution: [M1, M3, M5, M15, M30, H1, H4, H6, D1, W1, MN]
|
8
|
+
level: [L20, L100, full]
|
9
|
+
states: [submitted, partial_filled, canceled, partial_canceled, filled, pending_cancel]
|
10
|
+
|