fcoin_ruby_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.github/issue_template.md +12 -0
  3. data/.github/pull_request_template.md +12 -0
  4. data/.gitignore +13 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +12 -0
  7. data/.rubocop_todo.yml +431 -0
  8. data/.travis.yml +26 -0
  9. data/CHANGELOG.md +2 -0
  10. data/Gemfile +6 -0
  11. data/Gemfile.lock +176 -0
  12. data/LICENSE.txt +21 -0
  13. data/README.md +204 -0
  14. data/Rakefile +6 -0
  15. data/bin/console +14 -0
  16. data/bin/fcoin +95 -0
  17. data/bin/setup +8 -0
  18. data/examples/cli/realtime_api.md +78 -0
  19. data/examples/cli/rest_api.md +149 -0
  20. data/examples/cli/setting.md +39 -0
  21. data/examples/realtime_api.rb +43 -0
  22. data/examples/rest_api.rb +47 -0
  23. data/fcoin_ruby_client.gemspec +39 -0
  24. data/lib/fcoin/api.rb +47 -0
  25. data/lib/fcoin/authorization.rb +83 -0
  26. data/lib/fcoin/cli/endpoint/accounts_task.rb +33 -0
  27. data/lib/fcoin/cli/endpoint/market_task.rb +98 -0
  28. data/lib/fcoin/cli/endpoint/orders_task.rb +196 -0
  29. data/lib/fcoin/cli/endpoint/public_task.rb +59 -0
  30. data/lib/fcoin/cli/realtime/endpoint_task.rb +107 -0
  31. data/lib/fcoin/cli.rb +77 -0
  32. data/lib/fcoin/client.rb +7 -0
  33. data/lib/fcoin/config/custom_settings.yml +171 -0
  34. data/lib/fcoin/config/settings.yml +10 -0
  35. data/lib/fcoin/configuration.rb +95 -0
  36. data/lib/fcoin/connection.rb +33 -0
  37. data/lib/fcoin/endpoint/accounts.rb +23 -0
  38. data/lib/fcoin/endpoint/market.rb +91 -0
  39. data/lib/fcoin/endpoint/orders.rb +171 -0
  40. data/lib/fcoin/endpoint/public.rb +51 -0
  41. data/lib/fcoin/endpoint/utility.rb +14 -0
  42. data/lib/fcoin/endpoint.rb +13 -0
  43. data/lib/fcoin/error.rb +4 -0
  44. data/lib/fcoin/faraday/fcoin_formatter.rb +17 -0
  45. data/lib/fcoin/formatter/base_formatter.rb +8 -0
  46. data/lib/fcoin/formatter/depth_formatter.rb +33 -0
  47. data/lib/fcoin/formatter/ticker_formatter.rb +34 -0
  48. data/lib/fcoin/formatter.rb +38 -0
  49. data/lib/fcoin/generators/locale.rb +18 -0
  50. data/lib/fcoin/generators/templates/locale/locales/en.yml +176 -0
  51. data/lib/fcoin/generators/templates/locale/locales/ja.yml +176 -0
  52. data/lib/fcoin/generators/templates/locale/locales/zh_CN.yml +176 -0
  53. data/lib/fcoin/generators/templates/validation/my_settings.yml +171 -0
  54. data/lib/fcoin/generators/validation.rb +18 -0
  55. data/lib/fcoin/realtime/api.rb +38 -0
  56. data/lib/fcoin/realtime/client.rb +9 -0
  57. data/lib/fcoin/realtime/endpoint.rb +160 -0
  58. data/lib/fcoin/realtime/formatter/base_formatter.rb +10 -0
  59. data/lib/fcoin/realtime/formatter/depth_formatter.rb +37 -0
  60. data/lib/fcoin/realtime/formatter/ticker_formatter.rb +36 -0
  61. data/lib/fcoin/realtime/formatter.rb +40 -0
  62. data/lib/fcoin/realtime/wss.rb +113 -0
  63. data/lib/fcoin/request.rb +73 -0
  64. data/lib/fcoin/validator/market_validator.rb +60 -0
  65. data/lib/fcoin/validator/orders/base_validator.rb +96 -0
  66. data/lib/fcoin/validator/orders/create_order_limit_validator.rb +54 -0
  67. data/lib/fcoin/validator/orders/create_order_market_validator.rb +95 -0
  68. data/lib/fcoin/validator/orders/order_list_validator.rb +33 -0
  69. data/lib/fcoin/validator/orders_validator.rb +69 -0
  70. data/lib/fcoin/validator/validator_utility.rb +24 -0
  71. data/lib/fcoin/validator.rb +58 -0
  72. data/lib/fcoin/version.rb +3 -0
  73. data/lib/fcoin.rb +11 -0
  74. metadata +353 -0
@@ -0,0 +1,149 @@
1
+ # REST API CLI
2
+
3
+ In development, please use the `./bin/fcoin`.<br>
4
+ In Actual, please use the `bundle exec fcoin`.
5
+
6
+ ## All
7
+ ```bash
8
+ $ ./bin/fcoin
9
+ Commands:
10
+ fcoin account # Get Account Information
11
+ fcoin help [COMMAND] # Describe available commands or one specific command
12
+ fcoin locale # Locale Setting
13
+ fcoin market # Get Market Information
14
+ fcoin order # Operate Order
15
+ fcoin public # Get Public Information
16
+ fcoin subscribe # Subscribe topic
17
+ fcoin validation # Validation Setting
18
+ fcoin version # Print Version
19
+
20
+ ```
21
+
22
+ __If you want to validate__
23
+
24
+ ```bash
25
+ $ # For more settings
26
+ $ # @see https://github.com/yukihirop/fcoin_ruby_client#validation
27
+ $ ./bin/fcoin validation init --path ./config
28
+ create
29
+ create my_settings.yml
30
+ $ export VALIDATION_SETTING_PATH='/path/to/your/my_settings.yml'
31
+ ```
32
+
33
+ ## Public
34
+ ```bash
35
+ $ ./bin/fcoin public
36
+ Commands:
37
+ fcoin public currencies # Display available currency
38
+ fcoin public help [COMMAND] # Describe subcommands or one specific subcommand
39
+ fcoin public server_time # Get server time
40
+ fcoin public symbols # Query available transaction pairs
41
+
42
+ ```
43
+
44
+ ```bash
45
+ $ # Get server time
46
+ $ ./bin/fcoin public server_time
47
+ {"status":0,"data":1533311785257}
48
+ $
49
+ $ # Display available currency
50
+ $ ./bin/fcoin public currencies
51
+ {"status":0,"data":["btc","eth","bch","ltc","eos","usdt","ft_frozen","ft","zip","etc","omg","btm","zrx","xrp","bnb","gtc","fi","zil","icx","ae","777","gus","cccx","banca","pra","dcc","sss","mdt","tst","pmd","rte","xps","tct","dws","ngot","at","soc","blz","ocn","datx","let","dag","yee","aaa","nc","ait","arp","gram","tbcoin","ifood","hpc","sgcc","lxt","3db","drink1","drink","drct","ionc","xmx","rct","cit","ees","fair","brm","sda","cbr","tkt","vct","biz","show","pai","sec","lovc","mst","iov","ejoy","iht","iic","fbc","fota","dagt","wte","tos","oas","fres","gene","maya","mesh","icc","scl","cofi","but","zsc","jac","vns","aidoc","ccc","fuel","edu","beauty","mof","dta","cps","msc","latx","dscoin","dscb","boc","18t","newos","mxm","idxe","pnt","vpp","lmm","rnt","hotc","fff","dht","fbee","vlc","wicc","mot","bcv","baic","ruff","ink","ges","sac","see","dpn","smt","musk","ptt","mith","lth","wmch","cwv","jll","bhpc","unc","int","insur","pun","facc","osch","uto","btmc","cnmc","fcandy","dacc","fti","bbc","orme","tcash","mitx","pok","icst","gu","iota","ft1808","ft1810_i","zpr","nrc","kan","dac","eai","ifish","tat","you","win","fish","box","cosm","loom","kcash","rrc","olt","agi","kora","skm","bto","uuu","gse","bft","abt","mds","ors","vaac","lba","knc","gto","bfdt","est","gnx","iost","hpb","xin","cai","tac","risk","vnt","vboom","ugc","ole","bkbt","cpc","qos"]}
52
+ $
53
+ $ # Query available transaction pairs
54
+ $ ./bin/fcoin public symbols
55
+ {"status":0,"data":[{"name":"btcusdt","base_currency":"btc","quote_currency":"usdt","price_decimal":2,"amount_decimal":4},{"name":"ethusdt","base_currency":"eth","quote_currency":"usdt","price_decimal":2,"amount_decimal":4},{"name":"bchusdt","base_currency":"bch","quote_currency":"usdt","price_decimal":2,"amount_decimal":4},{"name":"ltcusdt","base_currency":"ltc","quote_currency":"usdt","price_decimal":2,"amount_decimal":4},{"name":"ftusdt","base_currency":"ft","quote_currency":"usdt","price_decimal":6,"amount_decimal":2},{"name":"fteth","base_currency":"ft","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"zipeth","base_currency":"zip","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"etcusdt","base_currency":"etc","quote_currency":"usdt","price_decimal":2,"amount_decimal":4},{"name":"ftbtc","base_currency":"ft","quote_currency":"btc","price_decimal":8,"amount_decimal":2},{"name":"omgeth","base_currency":"omg","quote_currency":"eth","price_decimal":6,"amount_decimal":4},{"name":"btmusdt","base_currency":"btm","quote_currency":"usdt","price_decimal":4,"amount_decimal":2},{"name":"zrxeth","base_currency":"zrx","quote_currency":"eth","price_decimal":6,"amount_decimal":2},{"name":"bnbusdt","base_currency":"bnb","quote_currency":"usdt","price_decimal":4,"amount_decimal":2},{"name":"zipusdt","base_currency":"zip","quote_currency":"usdt","price_decimal":6,"amount_decimal":2},{"name":"xrpusdt","base_currency":"xrp","quote_currency":"usdt","price_decimal":4,"amount_decimal":2},{"name":"fieth","base_currency":"fi","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"fiusdt","base_currency":"fi","quote_currency":"usdt","price_decimal":6,"amount_decimal":2},{"name":"icxeth","base_currency":"icx","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"zileth","base_currency":"zil","quote_currency":"eth","price_decimal":6,"amount_decimal":4},{"name":"aeeth","base_currency":"ae","quote_currency":"eth","price_decimal":6,"amount_decimal":2},{"name":"777eth","base_currency":"777","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"guseth","base_currency":"gus","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"cccxeth","base_currency":"cccx","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"bancaeth","base_currency":"banca","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"praeth","base_currency":"pra","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"dcceth","base_currency":"dcc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ssseth","base_currency":"sss","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"mdteth","base_currency":"mdt","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"tsteth","base_currency":"tst","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"pmdeth","base_currency":"pmd","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"rteeth","base_currency":"rte","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"xpseth","base_currency":"xps","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"tcteth","base_currency":"tct","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"dwseth","base_currency":"dws","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ngoteth","base_currency":"ngot","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ateth","base_currency":"at","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"soceth","base_currency":"soc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"blzeth","base_currency":"blz","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ocneth","base_currency":"ocn","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"datxeth","base_currency":"datx","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"gtceth","base_currency":"gtc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"leteth","base_currency":"let","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"dageth","base_currency":"dag","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"yeeeth","base_currency":"yee","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"aaaeth","base_currency":"aaa","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"nceth","base_currency":"nc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"aiteth","base_currency":"ait","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"arpeth","base_currency":"arp","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"grameth","base_currency":"gram","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ifoodeth","base_currency":"ifood","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"hpceth","base_currency":"hpc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"sgcceth","base_currency":"sgcc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"3dbeth","base_currency":"3db","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"xmxeth","base_currency":"xmx","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"rcteth","base_currency":"rct","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"citeth","base_currency":"cit","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"eeseth","base_currency":"ees","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"faireth","base_currency":"fair","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"brmeth","base_currency":"brm","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"sdaeth","base_currency":"sda","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"cbreth","base_currency":"cbr","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"tkteth","base_currency":"tkt","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"vcteth","base_currency":"vct","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"bizeth","base_currency":"biz","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"showeth","base_currency":"show","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"paieth","base_currency":"pai","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ioveth","base_currency":"iov","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ihteth","base_currency":"iht","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"fotaeth","base_currency":"fota","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ejoyeth","base_currency":"ejoy","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"iiceth","base_currency":"iic","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"wteeth","base_currency":"wte","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"freseth","base_currency":"fres","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"mesheth","base_currency":"mesh","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"icceth","base_currency":"icc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ionceth","base_currency":"ionc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"drcteth","base_currency":"drct","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"oaseth","base_currency":"oas","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"buteth","base_currency":"but","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"aidoceth","base_currency":"aidoc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"cofieth","base_currency":"cofi","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"lxteth","base_currency":"lxt","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"edueth","base_currency":"edu","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"dtaeth","base_currency":"dta","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"msceth","base_currency":"msc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"geneeth","base_currency":"gene","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ccceth","base_currency":"ccc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"dscoineth","base_currency":"dscoin","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"boceth","base_currency":"boc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"toseth","base_currency":"tos","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"fueleth","base_currency":"fuel","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"pnteth","base_currency":"pnt","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"seceth","base_currency":"sec","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"mofeth","base_currency":"mof","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"rnteth","base_currency":"rnt","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"wicceth","base_currency":"wicc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"fffeth","base_currency":"fff","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"cpseth","base_currency":"cps","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"zsceth","base_currency":"zsc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"latxeth","base_currency":"latx","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"dhteth","base_currency":"dht","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"seeeth","base_currency":"see","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"inketh","base_currency":"ink","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"saceth","base_currency":"sac","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"scleth","base_currency":"scl","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"mitheth","base_currency":"mith","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"smteth","base_currency":"smt","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"fcandyusdt","base_currency":"fcandy","quote_currency":"usdt","price_decimal":8,"amount_decimal":2},{"name":"newoseth","base_currency":"newos","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"hotceth","base_currency":"hotc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ptteth","base_currency":"ptt","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"dpneth","base_currency":"dpn","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ltheth","base_currency":"lth","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"jlleth","base_currency":"jll","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"utoeth","base_currency":"uto","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"777usdt","base_currency":"777","quote_currency":"usdt","price_decimal":8,"amount_decimal":2},{"name":"xpsusdt","base_currency":"xps","quote_currency":"usdt","price_decimal":8,"amount_decimal":2},{"name":"prausdt","base_currency":"pra","quote_currency":"usdt","price_decimal":8,"amount_decimal":2},{"name":"hpcusdt","base_currency":"hpc","quote_currency":"usdt","price_decimal":8,"amount_decimal":2},{"name":"vppeth","base_currency":"vpp","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"oscheth","base_currency":"osch","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"guusdt","base_currency":"gu","quote_currency":"usdt","price_decimal":8,"amount_decimal":2},{"name":"ft1808usdt","base_currency":"ft1808","quote_currency":"usdt","price_decimal":6,"amount_decimal":2},{"name":"ruffeth","base_currency":"ruff","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"baiceth","base_currency":"baic","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ormeeth","base_currency":"orme","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"puneth","base_currency":"pun","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"facceth","base_currency":"facc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"cwveth","base_currency":"cwv","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"lmmeth","base_currency":"lmm","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"vlceth","base_currency":"vlc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"icsteth","base_currency":"icst","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ftft1808","base_currency":"ft","quote_currency":"ft1808","price_decimal":6,"amount_decimal":2},{"name":"iotausdt","base_currency":"iota","quote_currency":"usdt","price_decimal":4,"amount_decimal":2},{"name":"drink1eth","base_currency":"drink1","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"drinketh","base_currency":"drink","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"musketh","base_currency":"musk","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"mxmeth","base_currency":"mxm","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"mitxeth","base_currency":"mitx","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ft1810_iusdt","base_currency":"ft1810_i","quote_currency":"usdt","price_decimal":6,"amount_decimal":2},{"name":"ftft1810_i","base_currency":"ft","quote_currency":"ft1810_i","price_decimal":6,"amount_decimal":2},{"name":"inteth","base_currency":"int","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"btmceth","base_currency":"btmc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"cnmceth","base_currency":"cnmc","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"ftieth","base_currency":"fti","quote_currency":"eth","price_decimal":8,"amount_decimal":2},{"name":"eosusdt","base_currency":"eos","quote_currency":"usdt","price_decimal":4,"amount_decimal":4}]}
56
+ ```
57
+
58
+ ## Market
59
+ ```bash
60
+ $ ./bin/fcoin market
61
+ Commands:
62
+ fcoin market candles --resolution=RESOLUTION --symbol=SYMBOL # Returns candles info of symbol specified by resolution
63
+ fcoin market depth --level=LEVEL --symbol=SYMBOL # Returns depth info of symbol specified by level
64
+ fcoin market help [COMMAND] # Describe subcommands or one specific subcommand
65
+ fcoin market ticker --symbol=SYMBOL # Returns ticker info of symbol
66
+ fcoin market trades --symbol=SYMBOL # Returns trades info of symbol
67
+
68
+ ```
69
+
70
+ ```bash
71
+ $ # Returns ticker info of symbol
72
+ $ ./bin/fcoin market ticker --symbol ethusdt
73
+ {"status":0,"data":{"ticker":{"latest_price":414.02,"most_recent_trade_vol":0.0902,"max_buy_price":414.02,"max_buy_amount":1.8507,"min_sell_price":414.03,"min_sell_amount":0.5,"trade_price_yesterday":412.04,"highest_price_today":415.31,"lowest_price_today":397.61,"symbol_base_vol_today":20506.814864234,"symbol_base_price_today":8368527.290918281},"type":"ticker.ethusdt","seq":105330258}}
74
+
75
+ $ # Returns depth info of symbol specified by level
76
+ $ ./bin/fcoin market depth --symbol ethusdt --level L20
77
+ {"status":0,"data":{"bids":[{"price":414.06,"amount":0.015},{"price":414.05,"amount":0.045},{"price":414.02,"amount":0.4694},{"price":414.0,"amount":0.1042},{"price":413.94,"amount":0.0084},{"price":413.93,"amount":0.4181},{"price":413.91,"amount":0.0025},{"price":413.9,"amount":0.0242},{"price":413.81,"amount":0.0036},{"price":413.8,"amount":0.04},{"price":413.71,"amount":0.1499},{"price":413.7,"amount":0.095},{"price":413.68,"amount":0.0558},{"price":413.67,"amount":0.0803},{"price":413.66,"amount":0.0684},{"price":413.62,"amount":0.0617},{"price":413.6,"amount":0.9768},{"price":413.59,"amount":0.0469},{"price":413.5,"amount":1.6528},{"price":413.41,"amount":0.0541}],"asks":[{"price":414.08,"amount":0.1742},{"price":414.09,"amount":0.1153},{"price":414.1,"amount":0.0201},{"price":414.11,"amount":0.1566},{"price":414.13,"amount":0.1332},{"price":414.15,"amount":0.2891},{"price":414.16,"amount":0.0951},{"price":414.23,"amount":0.4024},{"price":414.27,"amount":0.0283},{"price":414.3,"amount":0.005},{"price":414.31,"amount":0.0072},{"price":414.32,"amount":0.0035},{"price":414.35,"amount":0.0072},{"price":414.36,"amount":0.0025},{"price":414.46,"amount":0.0638},{"price":414.49,"amount":1.2057},{"price":414.5,"amount":0.005},{"price":414.51,"amount":0.0105},{"price":414.53,"amount":0.0015},{"price":414.6,"amount":0.06}],"ts":1533312373012,"seq":105330896,"type":"depth.L20.ethusdt"}}
78
+
79
+ $ # Returns trades info of symbol
80
+ $ ./bin/fcoin market trades --symbol ethusdt
81
+ {"status":0,"data":[{"amount":0.0371,"ts":1533312528424,"id":105331864002,"side":"buy","price":413.8}]}
82
+
83
+ $ # Returns candles info of symbol specified by resolution
84
+ $ ./bin/fcoin market candles --symbol ethusdt --resolution MN
85
+ {"status":0,"data":[{"open":430.1,"close":413.84,"high":435.93,"quote_vol":48966834.28889369,"id":1533052800,"count":357474,"low":397.61,"seq":10533250500000,"base_vol":116515.627401974},{"id":1530374400,"seq":10277314000000,"high":516.09,"low":418.29,"open":449.1,"close":430.1,"count":6460281,"base_vol":3214156.779928503,"quote_vol":1481280928.4282734},{"id":1527782400,"seq":7385778300000,"high":555.13,"low":406.11,"open":523.97,"close":449.04,"count":20382481,"base_vol":28258854.226292703,"quote_vol":13579650310.735054},{"id":1525104000,"seq":2847062700000,"high":582.99,"low":559.66,"open":563.23,"close":575.77,"count":4617,"base_vol":4159.317883344,"quote_vol":2380070.431548223}]}
86
+ ```
87
+
88
+ ## Order
89
+
90
+ __Please authenticate before command execution__
91
+ ```bash
92
+ export FCOIN_API_KEY='your_fcoin_api_key'
93
+ export FCOIN_SECRET_KEY='your_fcoin_secret_key'
94
+ ```
95
+
96
+ ```bash
97
+ $ ./bin/fcoin order
98
+ Commands:
99
+ fcoin order cancel --order-id=ORDER_ID # Cancel order
100
+ fcoin order create_limit --amount=N --price=N --side=SIDE --symbol=SYMBOL # Create limit order
101
+ fcoin order help [COMMAND] --side=SIDE --symbol=SYMBOL # Describe subcommands or one specific subcommand
102
+ fcoin order list --states=STATES --symbol=SYMBOL # Get order list
103
+ fcoin order reference --order-id=ORDER_ID # Ouery order
104
+ fcoin order transaction --order-id=ORDER_ID # Query the transaction record for the specified by order_id
105
+
106
+ ```
107
+
108
+ ```bash
109
+ $ # Create limit order
110
+ $ ./bin/fcoin order create_limit --symbol ftusdt --side sell --price 1 --amount 3
111
+ {"status":0,"data":"6SlFV7PSsxYu0FduMlYwghCgLgjeD_AiT5loT-ZFl2s="}
112
+
113
+ $ # Ouery order
114
+ $ ./bin/fcoin order reference --order-id 6SlFV7PSsxYu0FduMlYwghCgLgjeD_AiT5loT-ZFl2s=
115
+ {"status":0,"data":{"id":"6SlFV7PSsxYu0FduMlYwghCgLgjeD_AiT5loT-ZFl2s=","symbol":"ftusdt","amount":"3.000000000000000000","price":"1.000000000000000000","created_at":1533313517068,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"api","state":"submitted"}}
116
+
117
+ $ # Query the transaction record
118
+ $ ./bin/fcoin order transaction --order-id 6SlFV7PSsxYu0FduMlYwghCgLgjeD_AiT5loT-ZFl2s=
119
+ {"status":0,"data":[]}
120
+
121
+ $ # Cancel order
122
+ $ ./bin/fcoin order cancel --order-id 6SlFV7PSsxYu0FduMlYwghCgLgjeD_AiT5loT-ZFl2s=
123
+ {"status":0} # cancel is success
124
+
125
+ $ # Get order list
126
+ $ ./bin/fcoin order list --symbol ethusdt --states canceled
127
+ {"status":0,"data":[{"id":"nMEC_VrW0LYlP4iCcWzmdL50jFrvNWZoaQxvZSjeUSA=","symbol":"ethusdt","amount":"0.001000000000000000","price":"1000.000000000000000000","created_at":1531732778736,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"api","state":"canceled"},{"id":"V6WE1JJCUwvqJFgCjfT5lA37ioU_xOYi6_NSrtOVOsw=","symbol":"ethusdt","amount":"0.001000000000000000","price":"1000.000000000000000000","created_at":1531732713230,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"api","state":"canceled"},{"id":"R0moy92q4Qaf_GDEQ6Y1IKCgl5wwJM2bz_Zyacp-Ek8=","symbol":"ethusdt","amount":"0.001000000000000000","price":"1000.000000000000000000","created_at":1531714333569,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"api","state":"canceled"},{"id":"L7rbALEIoI0ymo3uOXBF4gT4BlyTxgHhGoZjvptIv2U=","symbol":"ethusdt","amount":"0.001000000000000000","price":"1000.000000000000000000","created_at":1531714218130,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"api","state":"canceled"},{"id":"32ZZCBEpPz2J9oFIJ4RMTIbypltjrVD9PAdYxQTHhUE=","symbol":"ethusdt","amount":"0.001000000000000000","price":"1000.000000000000000000","created_at":1531714092732,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"api","state":"canceled"},{"id":"VotO2IKI2opgyKRd1lhR5bYj9zNZ398IW85gcBNPisU=","symbol":"ethusdt","amount":"0.001000000000000000","price":"1000.000000000000000000","created_at":1531712709955,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"api","state":"canceled"},{"id":"tYH6LczJxaVe_WhsLOzOk4YM53hK2q169nYn9ReiwGM=","symbol":"ethusdt","amount":"0.001000000000000000","price":"1000.000000000000000000","created_at":1531675732267,"type":"limit","side":"sell","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"web","state":"canceled"},{"id":"U50WtZkmIh_bbuVKoipAMayCIy0A7qk4hBLxpDvKdPk=","symbol":"ethusdt","amount":"0.025800000000000000","price":"491.100000000000000000","created_at":1529665880201,"type":"limit","side":"buy","filled_amount":"0.000000000000000000","executed_value":"0.000000000000000000","fill_fees":"0.000000000000000000","source":"web","state":"canceled"}]}
128
+ ```
129
+
130
+ ## Account
131
+
132
+ __Please authenticate before command execution__
133
+ ```bash
134
+ export FCOIN_API_KEY='your_fcoin_api_key'
135
+ export FCOIN_SECRET_KEY='your_fcoin_secret_key'
136
+ ```
137
+
138
+ ```bash
139
+ $ ./bin/fcoin account
140
+ Commands:
141
+ fcoin account balance # Get account info
142
+ fcoin account help [COMMAND] # Describe subcommands or one specific subcommand
143
+
144
+ ```
145
+
146
+ ```bash
147
+ $ ./bin/fcoin account balance
148
+ # Do not display because it is personal information
149
+ ```
@@ -0,0 +1,39 @@
1
+ # Setting CLI
2
+
3
+ In development, please use the `./bin/fcoin`.<br>
4
+ In Actual, please use the `bundle exec fcoin`.
5
+
6
+ ## All
7
+ ```bash
8
+ $ ./bin/fcoin
9
+ Commands:
10
+ fcoin account # Get Account Information
11
+ fcoin help [COMMAND] # Describe available commands or one specific command
12
+ fcoin locale # Locale Setting
13
+ fcoin market # Get Market Information
14
+ fcoin order # Operate Order
15
+ fcoin public # Get Public Information
16
+ fcoin subscribe # Subscribe topic
17
+ fcoin validation # Validation Setting
18
+ fcoin version # Print Version
19
+
20
+ ```
21
+
22
+ ## Validation
23
+ ```bash
24
+ $ # Create validation setting file
25
+ $ ./bin/fcoin validation init --path ./config
26
+ create
27
+ create my_settings.yml
28
+ ```
29
+
30
+ ## Locale
31
+ ```bash
32
+ $ # Create locale file
33
+ $ ./bin/fcoin locale init --path ./config
34
+ exist
35
+ create .DS_Store
36
+ create locales/en.yml
37
+ create locales/ja.yml
38
+ create locales/zh_CN.yml
39
+ ```
@@ -0,0 +1,43 @@
1
+ require 'bundler/setup'
2
+ require './lib/fcoin.rb'
3
+ require 'pry'
4
+
5
+ Fcoin.configure do |config|
6
+ config.api_key = ENV['FCOIN_API_KEY']
7
+ config.secret_key = ENV['FCOIN_SECRET_KEY']
8
+ config.skip_validation = false
9
+ ## Please execute 「bundle exec fcoin validation init --path ./config」
10
+ config.validation_setting_path = File.expand_path('../../config/my_settings.yml', __FILE__)
11
+ end
12
+
13
+ client = Fcoin::RealTime::Client.new
14
+ # client = Fcoin::RealTime::Client.new(api_key: 'hoge', secret_key: 'fuga')
15
+ # or
16
+ # client = Fcoin::Client.new.realtime
17
+
18
+
19
+ client.on_ticker(symbol: :ethusdt) do |data|
20
+ puts data
21
+ end
22
+
23
+ client.on_depth(symbol: :ethusdt, level: :L20) do |data|
24
+ puts data
25
+ end
26
+
27
+ client.on_trade(symbol: :ethusdt, limit: 5) do |data|
28
+ puts data
29
+ end
30
+
31
+ client.on_candle(symbol: :ethusdt, resolution: :M1, limit: 5) do |data|
32
+ puts data
33
+ end
34
+
35
+ client.on_topics do |data|
36
+ puts data
37
+ end
38
+
39
+ client.on_hello do |data|
40
+ puts data
41
+ end
42
+
43
+ client.subscribe
@@ -0,0 +1,47 @@
1
+ require 'bundler/setup'
2
+ require './lib/fcoin.rb'
3
+ require 'pry'
4
+
5
+ Fcoin.configure do |config|
6
+ config.api_key = ENV['FCOIN_API_KEY']
7
+ config.secret_key = ENV['FCOIN_SECRET_KEY']
8
+ config.skip_validation = false
9
+ ## Please execute 「bundle exec fcoin validation init --path ./config」
10
+ config.validation_setting_path = File.expand_path('../../config/my_settings.yml', __FILE__)
11
+ end
12
+
13
+ client = Fcoin::Client.new
14
+ # client = Fcoin::Client.new(api_key: 'hoge', secret_key: 'fuga')
15
+
16
+ ## public
17
+ puts client.public_server_time
18
+ puts client.public_currencies
19
+ puts client.public_symbols
20
+
21
+
22
+ ## market
23
+ puts client.market_ticker(symbol: :ethusdt)
24
+ puts client.market_depth(level: :L20 ,symbol: :ethusdt)
25
+ puts client.market_trades(symbol: :ethusdt)
26
+ puts client.market_candles(symbol: :ethusdt, resolution: :M1)
27
+
28
+
29
+ ## accounts
30
+ puts client.accounts_balance
31
+
32
+
33
+ ## orders
34
+ # client.create_order_limit(symbol: :ethusdt, side: :sell, type: :limit, price: 1000, amount: 0.001)
35
+ puts client.order_list(symbol: :ethusdt, states: :canceled, page_before: nil, page_after: nil, per_page: 20)
36
+ # puts client.order_list(symbol: :ethusdt, states: 'canceled', page_before: nil, page_after: nil, per_page: 20)
37
+
38
+
39
+ puts client.order(order_id: "L7rbALEIoI0ymo3uOXBF4gT4Bl********jvptIv2U=")
40
+ # alias method
41
+ # client.reference_order(order_id: "L7rbALEIoI0ymo3uOXBF4gT4Bl********jvptIv2U=")
42
+
43
+ puts client.cancel_order(order_id: "nMEC_VrW0LYlP4iCcWzmdL50jFrvNWZoaQxvZSjeUSA=")
44
+
45
+ puts client.order_match_results(order_id: "kW3cRiXIGHG-cHNdter*********qfoMzbeHEQcqp4=")
46
+ # alias method
47
+ # client.order_transaction(order_id: "kW3cRiXIGHG-cHNdter*********qfoMzbeHEQcqp4=")
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "fcoin/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fcoin_ruby_client"
7
+ spec.version = Fcoin::VERSION
8
+ spec.authors = ["yukihirop"]
9
+ spec.email = ["yfsidejob@gmail.com"]
10
+
11
+ spec.summary = %q{A Ruby wrapper for Fcoin API}
12
+ spec.description = %q{A Ruby wrapper for Fcoin API}
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.16.a"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "pry"
25
+ spec.add_development_dependency "webmock"
26
+ spec.add_development_dependency "vcr"
27
+ spec.add_development_dependency "yard"
28
+ spec.add_development_dependency "rubocop"
29
+ spec.add_development_dependency "onkcop"
30
+ spec.add_development_dependency "simplecov"
31
+ spec.add_development_dependency "coveralls"
32
+
33
+ spec.add_runtime_dependency "faraday"
34
+ spec.add_runtime_dependency "faraday_middleware"
35
+ spec.add_runtime_dependency "activesupport"
36
+ spec.add_runtime_dependency "faye-websocket"
37
+ spec.add_runtime_dependency "config"
38
+ spec.add_runtime_dependency "thor"
39
+ end
data/lib/fcoin/api.rb ADDED
@@ -0,0 +1,47 @@
1
+ require_relative 'connection'
2
+ require_relative 'request'
3
+ require_relative 'endpoint'
4
+ require_relative 'error'
5
+ require_relative 'realtime/api'
6
+ require 'active_support'
7
+ require 'active_support/core_ext'
8
+
9
+ module Fcoin
10
+ class API
11
+ include Connection
12
+ include Request
13
+ include Endpoint
14
+
15
+ # @param [Hash] options the options to setting Fcoin Setting. For example, Authorization, Validation and so on.
16
+ # @option options [String] :adapter(Faraday.default_adapter)
17
+ # @option options [String] :endpoint(https://api.fcoin.com/v2/) REST API endpoint
18
+ # @option options [String] :wss_endpoint(wss://api.fcoin.com/v2/ws) Websocket endpoint
19
+ # @option options [String] :user_agent
20
+ # @option options [String] :proxy(nil)
21
+ # @option options [String] :ca_path
22
+ # @option options [String] :ca_file
23
+ # @option options [Array<Faraday::Middleware>] :middlewares request faraday middlewares
24
+ # @option options [String] :api_key
25
+ # @option options [String] :secret_key
26
+ # @option options [Boolean] :skip_validation(true)
27
+ # @option options [String] :validation_setting_path configuration file path for validation
28
+ def initialize(options={})
29
+ self.merged_options = Fcoin.options.merge(options)
30
+ Configuration::VALID_OPTIONS_KEYS.each do |key|
31
+ send("#{key}=", merged_options[key])
32
+ end
33
+ end
34
+
35
+ # Build realtime client
36
+ #
37
+ # @see RealTime::Client
38
+ # @return [Fcoin::RealTime::Client]
39
+ def realtime
40
+ RealTime::Client.new(merged_options)
41
+ end
42
+
43
+ private
44
+
45
+ attr_accessor *Configuration::VALID_OPTIONS_KEYS, :merged_options
46
+ end
47
+ end
@@ -0,0 +1,83 @@
1
+ require 'openssl'
2
+ require 'base64'
3
+ require 'active_support'
4
+ require 'active_support/core_ext'
5
+
6
+ module Fcoin
7
+ class Authorization
8
+ # @param http_method [String]
9
+ # @param path [String]
10
+ # @param payload [Hash]
11
+ # @param endpoint [String]
12
+ # @api_key [String]
13
+ # @secret_key [String]
14
+ def initialize(http_method:, path:, payload:, endpoint:, api_key:, secret_key:)
15
+ self.http_method = http_method
16
+ self.path = path
17
+ self.payload = payload
18
+ self.endpoint = endpoint
19
+ self.api_key = api_key
20
+ self.secret_key = secret_key
21
+ end
22
+
23
+ # Header required for authentication
24
+ #
25
+ # @see https://developer.fcoin.com/zh.html#32c808cbe5
26
+ def original_headers
27
+ {
28
+ 'FC-ACCESS-KEY' => api_key,
29
+ 'FC-ACCESS-SIGNATURE' => encoded_signature,
30
+ 'FC-ACCESS-TIMESTAMP' => timestamp
31
+ }
32
+ end
33
+
34
+ private
35
+
36
+ attr_accessor :http_method, :path, :payload, :endpoint, :api_key, :secret_key
37
+
38
+ def encoded_signature
39
+ base64_signature = Base64.strict_encode64(signature)
40
+ Base64.strict_encode64(OpenSSL::HMAC.digest('sha1', secret_key.to_s, base64_signature))
41
+ end
42
+
43
+ # @example HTTP_METHOD + HTTP_REQUEST_URI + TIMESTAMP + POST_BODY
44
+ # POSThttps://api.fcoin.com/v2/orders1523069544359amount=100.0&price=100.0&side=buy&symbol=btcusdt&type=limit
45
+ #
46
+ # @see https://developer.fcoin.com/zh.html#api
47
+ def signature
48
+ if http_method == :get && query_string.present?
49
+ http_method.upcase.to_s + full_url.to_s + '?' +query_string.to_s + timestamp.to_s
50
+ else
51
+ http_method.upcase.to_s + full_url.to_s + timestamp.to_s + payload_string.to_s
52
+ end
53
+ end
54
+
55
+ def full_url
56
+ endpoint.to_s + path.to_s
57
+ end
58
+
59
+ # digits number: 13
60
+ #
61
+ # @note When accessing the API with the UNIX EPOCH timestamp, the time difference between the server and the server must be less than 30 seconds.
62
+ #
63
+ # @example
64
+ # 1531632081423
65
+ #
66
+ #
67
+ # @see https://developer.fcoin.com/zh.html#api
68
+ def timestamp
69
+ # digits number: 13
70
+ # e.x.) 1531632081423
71
+ @timestamp ||= Time.now.strftime('%s%L').to_i.to_s
72
+ end
73
+
74
+ # sort by alphabet ASC
75
+ #
76
+ # @see https://developer.fcoin.com/jp.html?javascript#
77
+ def query_string
78
+ query_string = Hash[ payload.sort ].to_query
79
+ query_string.blank? ? '' : query_string
80
+ end
81
+ alias :payload_string :query_string
82
+ end
83
+ end
@@ -0,0 +1,33 @@
1
+ require_relative '../../../fcoin'
2
+ require 'thor'
3
+
4
+ module Fcoin
5
+ module EndPoint
6
+ class AccountsTask < Thor
7
+ # Get account info.
8
+ #
9
+ # curl: GET https://api.fcoin.com/v2/accounts/balance
10
+ #
11
+ # @note This method can not be invoked without authentication.
12
+ #
13
+ # @example get account info
14
+ # export FCOIN_API_KEY='your_fcoin_api_key'
15
+ # export FCOIN_SECRET_KEY='your_fcoin_secret_key'
16
+ # ./bin/fcoin accounts balance
17
+ #
18
+ #
19
+ # @see https://developer.fcoin.com/zh.html#486f6037ed
20
+ # @return [JSON]
21
+ desc 'balance', 'Get account info'
22
+ def balance
23
+ STDOUT.puts client.accounts_balance
24
+ end
25
+
26
+ private
27
+
28
+ def client
29
+ Fcoin::Client.new
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,98 @@
1
+ require_relative '../../../fcoin'
2
+ require 'thor'
3
+
4
+ module Fcoin
5
+ module EndPoint
6
+ class MarketTask < Thor
7
+ # Returns ticker info of symbol.
8
+ #
9
+ # curl: GET https://api.fcoin.com/v2/market/ticker/$symbol
10
+ #
11
+ # @example get ethusdt ticker info
12
+ # ./bin/fcoin market ticker --symbol ethusdt
13
+ #
14
+ #
15
+ # @see https://developer.fcoin.com/zh.html#ticker
16
+ # @raise [ArgumentError] If the symbol does not have.
17
+ # @param symbol [String] Transaction pairs.
18
+ # @return [JSON] Returns ticker info.
19
+ desc 'ticker', 'Returns ticker info of symbol'
20
+ option :symbol, type: :string, required: true, desc: 'Transaction pairs'
21
+ def ticker
22
+ symbol = options[:symbol]
23
+ STDOUT.puts client.market_ticker(symbol: symbol)
24
+ end
25
+
26
+ # Returns depth info of symbol specified by level.
27
+ #
28
+ # curl: GET https://api.fcoin.com/v2/market/depth/$level/$symbol
29
+ #
30
+ # @example get ethusdt depth info specified by L20 level.
31
+ # ./bin/fcoin market depth --symbol ethusdt --level L20
32
+ #
33
+ #
34
+ # @see https://developer.fcoin.com/zh.html#50f4407ea4
35
+ # @raise [ArgumentError] If the symbol or level does not have.
36
+ # @raise [InvalidValueError] If symbol or level is invalid.
37
+ # @param symbol [String] Transaction pairs.
38
+ # @param level [String] Level of depth chart. level must be included in [L20, L40, full].
39
+ # @return [JSON] Returns depth info.
40
+ desc 'depth', 'Returns depth info of symbol specified by level'
41
+ option :symbol, type: :string, required: true, desc: 'Transaction pairs'
42
+ option :level, type: :string, required: true, desc: 'Level of depth chart. level must be included in [L20, L40, full]'
43
+ def depth
44
+ symbol = options[:symbol]
45
+ level = options[:level]
46
+ STDOUT.puts client.market_depth(symbol: symbol, level: level)
47
+ end
48
+
49
+ # Returns trades info of symbol.
50
+ #
51
+ # curl: GET https://api.fcoin.com/v2/market/trades/$symbol
52
+ #
53
+ # @example get ethusdt trades info.
54
+ # ./bin/fcoin market trades --symbol ethusdt
55
+ #
56
+ #
57
+ # @see https://developer.fcoin.com/zh.html#6477a1394e
58
+ # @raise [ArgumentError] If the symbol does not have.
59
+ # @param symbol [String] Transaction pairs.
60
+ # @return [JSON] Returns trades info.
61
+ desc 'trades', 'Returns trades info of symbol'
62
+ option :symbol, type: :string, required: true, desc: 'Transaction pairs'
63
+ def trades
64
+ symbol = options[:symbol]
65
+ STDOUT.puts client.market_trades(symbol: symbol)
66
+ end
67
+
68
+ # Returns candles info of symbol specified by resolution.
69
+ #
70
+ # curl: GET https://api.fcoin.com/v2/market/candles/$resolution/$symbol
71
+ #
72
+ # @example get monthly(MN) ethusdt candles info.
73
+ # ./bin/fcoin market candles --symbol ethusdt --resolution D1
74
+ #
75
+ #
76
+ # @see https://developer.fcoin.com/zh.html#candle
77
+ # @raise [ArgumentError] If the symbol or resolution does not have.
78
+ # @raise [InvalidValueError] If symbol or resolution is invalid.
79
+ # @param symbol [String or Symbol] Transaction pairs.
80
+ # @param resolution [String or Symbol] period of candles chart. resolution must be included in [M1, M3, M5, M15, M30, H1, H4, H6, D1, W1, MN].
81
+ # @return [JSON] Returns candles info.
82
+ desc 'candles', 'Returns candles info of symbol specified by resolution'
83
+ option :symbol, type: :string, required: true, desc: 'Transaction pairs'
84
+ 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]'
85
+ def candles
86
+ symbol = options[:symbol]
87
+ resolution = options[:resolution]
88
+ STDOUT.puts client.market_candles(symbol: symbol, resolution: resolution)
89
+ end
90
+
91
+ private
92
+
93
+ def client
94
+ @client = Fcoin::Client.new
95
+ end
96
+ end
97
+ end
98
+ end