stocks_exchange_api_client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +50 -0
- data/Gemfile +16 -0
- data/LICENSE +21 -0
- data/README.md +118 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/stocks_exchange_api_client.rb +67 -0
- data/lib/stocks_exchange_api_client/configuration.rb +18 -0
- data/lib/stocks_exchange_api_client/errors/configuration_error.rb +9 -0
- data/lib/stocks_exchange_api_client/private.rb +157 -0
- data/lib/stocks_exchange_api_client/public.rb +65 -0
- data/lib/stocks_exchange_api_client/version.rb +3 -0
- data/stocks_exchange_api_client.gemspec +34 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33c35f2afd5742b6eb1f090955fe97e7451178b8fba53ca4da4f7c6095229083
|
4
|
+
data.tar.gz: c7a1ec2fba349d2a7afc29646f73c665f656ba124fa8f8479c8f0d0d0a4efab0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e5f6050b7d27fd29e26e71e601119455b839ffa797dc8fbd73f3f37e4ffcbb1b0550e029103852ec7ece7bd215ebaa2b47784fc255e9581012b0438d848aaf8
|
7
|
+
data.tar.gz: 587beb58785ba872d6cc5b0978c38dff43cade7ca4cedcd4e4fd9303005e74d58a7ea5bcb51dfbbd2ed30e84dfe99790ab111cd14b30fd15a82f09be5c71439b
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'pry'
|
8
|
+
gem 'rake'
|
9
|
+
gem 'openssl'
|
10
|
+
gem 'httparty'
|
11
|
+
gem 'json'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'rspec'
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Stocks Exchange
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Stocks.Exchange (Ruby API client)
|
2
|
+
Stocks.Exchange provides all the core exchange functionality, and additional merchant tools available via the HTTP API where all returned messages are in JSON. It's much easier to work with the API by using one of the clients provided by Stocks.Exchange, so while this page describes the API in case you want or need to build your own client, the examples use the Ruby client.
|
3
|
+
## Requirements
|
4
|
+
- Ruby >= 2.5.1
|
5
|
+
## Dependent Libraries
|
6
|
+
- gem 'pry'
|
7
|
+
- gem 'rake'
|
8
|
+
- gem 'openssl'
|
9
|
+
- gem 'httparty'
|
10
|
+
- gem 'json'
|
11
|
+
|
12
|
+
## General
|
13
|
+
The base URL for all the requests other than public methods is
|
14
|
+
```
|
15
|
+
https://app.stocks.exchange/api2
|
16
|
+
```
|
17
|
+
|
18
|
+
## Getting started
|
19
|
+
-[Documentation](http://help.stocks.exchange/api-integration).
|
20
|
+
|
21
|
+
To get started with the Ruby API client, here's a snippet for creating a client with existing credentials:
|
22
|
+
> In order to use the API functions, you must have an API key and API secret, which is generated in the user profile.
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
```bash
|
26
|
+
gem install stocks_exchange_api_client
|
27
|
+
```
|
28
|
+
|
29
|
+
After install use for example this code!
|
30
|
+
|
31
|
+
### Example
|
32
|
+
```ruby
|
33
|
+
require 'stocks_exchange_api_client'
|
34
|
+
|
35
|
+
StocksExchangeApiClient.configure do |conf|
|
36
|
+
conf.url = 'https://app.stocks.exchange/api2'
|
37
|
+
conf.api_key = '' # Your Api Key
|
38
|
+
conf.api_secret = '' # Your Api Secret
|
39
|
+
end
|
40
|
+
# Get information about your account
|
41
|
+
puts StocksExchangeApiClient::Private.get_info
|
42
|
+
|
43
|
+
# Get information about active orders.
|
44
|
+
# Params: pair, count, order, type, owner, since, end
|
45
|
+
puts StocksExchangeApiClient::Private.active_order
|
46
|
+
|
47
|
+
# Create orders for the purchase and sale.
|
48
|
+
# Params: type, pair, amount, rate
|
49
|
+
puts StocksExchangeApiClient::Private.trade('BUY', 'LTC_BTC', 0.1, 0.00002)
|
50
|
+
|
51
|
+
# Cancel selected order.
|
52
|
+
# Params: order_id
|
53
|
+
puts StocksExchangeApiClient::Private.cancel_order(2761025)
|
54
|
+
|
55
|
+
# Get information about all orders.
|
56
|
+
# Params: pair, count, order, status, owner, since, end
|
57
|
+
puts StocksExchangeApiClient::Private.trade_history
|
58
|
+
|
59
|
+
# Get information about all closed orders from Register
|
60
|
+
# Params: currency, since, end
|
61
|
+
puts StocksExchangeApiClient::Private.trade_register_history
|
62
|
+
|
63
|
+
# Get information about all orders User
|
64
|
+
# Params: since, end
|
65
|
+
puts StocksExchangeApiClient::Private.user_history
|
66
|
+
|
67
|
+
# Get information about your deposits and withdrawals.
|
68
|
+
# Params: currency, count, order, operation, status
|
69
|
+
puts StocksExchangeApiClient::Private.trans_history
|
70
|
+
|
71
|
+
# Get information about trade statistic.
|
72
|
+
# Params: currency, count, order, operation, status, since, end
|
73
|
+
puts StocksExchangeApiClient::Private.grafic
|
74
|
+
|
75
|
+
# Generate currency wallet address.
|
76
|
+
# Params: currency
|
77
|
+
puts StocksExchangeApiClient::Private.generate_wallets('ONION')
|
78
|
+
|
79
|
+
# Get information about your wallet to deposit funds.
|
80
|
+
# Params: currency
|
81
|
+
puts StocksExchangeApiClient::Private.deposit('ETH')
|
82
|
+
|
83
|
+
# Withdraw your funds.
|
84
|
+
# Params: currency, address, amount
|
85
|
+
puts StocksExchangeApiClient::Private.withdraw('EAG', '12345', 1.001)
|
86
|
+
|
87
|
+
# Get all available currencies with additional info.
|
88
|
+
puts StocksExchangeApiClient::Public.currencies
|
89
|
+
|
90
|
+
# Get all available currency pairs with additional info.
|
91
|
+
puts StocksExchangeApiClient::Public.markets
|
92
|
+
|
93
|
+
# Get currency pair with additional info.
|
94
|
+
# Params Currency1 and Currency2
|
95
|
+
puts StocksExchangeApiClient::Public.markets_summary('BTC', 'USDT')
|
96
|
+
|
97
|
+
# Use it to get the recommended retail exchange rates for all currency pairs.
|
98
|
+
puts StocksExchangeApiClient::Public.ticker
|
99
|
+
|
100
|
+
# Use it to get the new retail exchange rates for all currency pairs.
|
101
|
+
puts StocksExchangeApiClient::Public.prices
|
102
|
+
|
103
|
+
# Used to retrieve the latest trades that have occurred for a specific market.
|
104
|
+
# Params Pair
|
105
|
+
puts StocksExchangeApiClient::Public.trade_history('BTC_USDT')
|
106
|
+
|
107
|
+
# Used to get retrieve the orderbook for a given market.
|
108
|
+
# Params Pair
|
109
|
+
puts StocksExchangeApiClient::Public.order_book('BTC_USDT')
|
110
|
+
```
|
111
|
+
## Common Errors
|
112
|
+
### Here is a list with common errors and their descriptions:
|
113
|
+
1. Invalid Key - not generated key or the key does not correspond to the a user
|
114
|
+
2. Invalid Sign - bad hash-code
|
115
|
+
3. Invalid Nonce - wrong or empty parameter Nonce
|
116
|
+
4. Duplicate Request - parameter Nonce is not unique
|
117
|
+
5. Invalid Method - this method is wrong or missing
|
118
|
+
6. The credentials are invalid - not valid Api Key or Sign
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'stocks_exchange_api_client'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'httparty'
|
3
|
+
require 'json'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
|
7
|
+
# Version
|
8
|
+
require 'stocks_exchange_api_client/version'
|
9
|
+
|
10
|
+
# Private API method
|
11
|
+
require 'stocks_exchange_api_client/private'
|
12
|
+
|
13
|
+
# Public API method
|
14
|
+
require 'stocks_exchange_api_client/public'
|
15
|
+
|
16
|
+
# Configuration
|
17
|
+
require 'stocks_exchange_api_client/configuration'
|
18
|
+
|
19
|
+
|
20
|
+
module StocksExchangeApiClient
|
21
|
+
|
22
|
+
METHOD_NAME = {
|
23
|
+
get_info: 'GetInfo',
|
24
|
+
active_orders: 'ActiveOrders',
|
25
|
+
trade: 'Trade',
|
26
|
+
cancel_order: 'CancelOrder',
|
27
|
+
trade_history: 'TradeHistory',
|
28
|
+
trade_register_history: 'TradeRegisterHistory',
|
29
|
+
user_history: 'UserHistory',
|
30
|
+
trans_history: 'TransHistory',
|
31
|
+
grafic: 'Grafic',
|
32
|
+
generate_wallets: 'GenerateWallets',
|
33
|
+
deposit: 'Deposit',
|
34
|
+
withdraw: 'Withdraw'
|
35
|
+
}.freeze
|
36
|
+
|
37
|
+
HEX_ALGORITHM = 'sha512'
|
38
|
+
|
39
|
+
class << self
|
40
|
+
|
41
|
+
def configure
|
42
|
+
yield(configuration)
|
43
|
+
end
|
44
|
+
|
45
|
+
def make_api_request(method = :post, params = {}, type)
|
46
|
+
configuration.validate!
|
47
|
+
if method == :post
|
48
|
+
params.merge!({method: type, nonce: Time.now.to_i})
|
49
|
+
encode_www_form = URI.encode_www_form(params)
|
50
|
+
sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new(HEX_ALGORITHM), configuration.api_secret, encode_www_form)
|
51
|
+
response = JSON.parse(
|
52
|
+
HTTParty.post(configuration.url, body: params, headers: {
|
53
|
+
:Sign => sign,
|
54
|
+
:Key => configuration.api_key
|
55
|
+
}).body)
|
56
|
+
OpenStruct.new(response)
|
57
|
+
end
|
58
|
+
if method == :get
|
59
|
+
JSON.parse(HTTParty.get("#{configuration.url}/#{type}").body)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def configuration
|
64
|
+
@configuration ||= Configuration.new
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module StocksExchangeApiClient
|
2
|
+
|
3
|
+
class Configuration
|
4
|
+
|
5
|
+
URL = 'https://app.stocks.exchange/api2'
|
6
|
+
|
7
|
+
attr_accessor :url, :api_key, :api_secret
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@url ||= URL
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate!
|
14
|
+
raise Errors::ConfigurationError unless api_key && api_secret
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module StocksExchangeApiClient
|
2
|
+
module Errors
|
3
|
+
class ConfigurationError < StandardError
|
4
|
+
def initialize
|
5
|
+
super 'Not all config vars were set. Stocks Exchange requires API key and API secret. Get this fields on url https://app.stocks.exchange/en/profile/settings'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
module StocksExchangeApiClient
|
2
|
+
ASC = 'ASC'.freeze
|
3
|
+
|
4
|
+
ALL = 'ALL'.freeze
|
5
|
+
|
6
|
+
MAX_COUNT = 50
|
7
|
+
|
8
|
+
STATUS_ORDER = {
|
9
|
+
pending: 1,
|
10
|
+
processing: 2,
|
11
|
+
finished: 3,
|
12
|
+
canceled: 4
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
STATUS_ORDER_HUMAN_NAME = {
|
16
|
+
1 => 'PENDING',
|
17
|
+
2 => 'PROCESSING',
|
18
|
+
3 => 'FINISHED',
|
19
|
+
4 => 'CANCELED'
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
OWNER = {
|
23
|
+
all: 'ALL',
|
24
|
+
own: 'OWN'
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
INTERVAL = {
|
28
|
+
day: '1D',
|
29
|
+
month: '1M',
|
30
|
+
three_month: '3M',
|
31
|
+
year: '1Y'
|
32
|
+
}.freeze
|
33
|
+
|
34
|
+
DEFAULT_PAIRS = 'ETH_BTC'.freeze
|
35
|
+
|
36
|
+
class Private
|
37
|
+
class << self
|
38
|
+
def get_info
|
39
|
+
StocksExchangeApiClient.make_api_request(:post,
|
40
|
+
{},
|
41
|
+
METHOD_NAME[:get_info])
|
42
|
+
end
|
43
|
+
|
44
|
+
def active_order(params = {})
|
45
|
+
params[:pair] = params[:pair].nil? ? ALL : params[:pair]
|
46
|
+
params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
|
47
|
+
params[:order] = params[:order].nil? ? ASC : params[:order]
|
48
|
+
params[:type] = params[:type].nil? ? ALL : params[:type]
|
49
|
+
params[:owner] = params[:owner].nil? ? ALL : params[:owner]
|
50
|
+
|
51
|
+
params[:order] = ASC unless params[:since].nil? || params[:end].nil?
|
52
|
+
|
53
|
+
StocksExchangeApiClient.make_api_request(:post,
|
54
|
+
params,
|
55
|
+
METHOD_NAME[:active_orders])
|
56
|
+
end
|
57
|
+
|
58
|
+
def trade(type = nil, pair = nil, amount = nil, rate = nil)
|
59
|
+
params = {
|
60
|
+
type: type,
|
61
|
+
pair: pair,
|
62
|
+
amount: amount,
|
63
|
+
rate: rate
|
64
|
+
}
|
65
|
+
StocksExchangeApiClient.make_api_request(:post,
|
66
|
+
params,
|
67
|
+
METHOD_NAME[:trade])
|
68
|
+
end
|
69
|
+
|
70
|
+
def cancel_order(order_id)
|
71
|
+
params = { order_id: order_id }
|
72
|
+
StocksExchangeApiClient.make_api_request(:post,
|
73
|
+
params,
|
74
|
+
METHOD_NAME[:cancel_order])
|
75
|
+
end
|
76
|
+
|
77
|
+
def trade_history(params = {})
|
78
|
+
params[:pair] = params[:pair].nil? ? ALL : params[:pair]
|
79
|
+
params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
|
80
|
+
params[:order] = params[:order].nil? ? ASC : params[:order]
|
81
|
+
params[:owner] = params[:owner].nil? ? OWNER[:own] : params[:owner]
|
82
|
+
params[:status] = params[:status].nil? ? STATUS_ORDER[:finished] : params[:status]
|
83
|
+
params[:order] = ASC unless params[:since].nil? || params[:end].nil?
|
84
|
+
|
85
|
+
StocksExchangeApiClient.make_api_request(:post,
|
86
|
+
params,
|
87
|
+
METHOD_NAME[:trade_history])
|
88
|
+
end
|
89
|
+
|
90
|
+
def trade_register_history(params = {})
|
91
|
+
params[:currency] = params[:currency].nil? ? ALL : params[:currency]
|
92
|
+
|
93
|
+
StocksExchangeApiClient.make_api_request(:post,
|
94
|
+
params,
|
95
|
+
METHOD_NAME[:trade_register_history])
|
96
|
+
end
|
97
|
+
|
98
|
+
def user_history(params = {})
|
99
|
+
StocksExchangeApiClient.make_api_request(:post,
|
100
|
+
params,
|
101
|
+
METHOD_NAME[:user_history])
|
102
|
+
end
|
103
|
+
|
104
|
+
def trans_history(params = {})
|
105
|
+
params[:currency] = params[:currency].nil? ? ALL : params[:currency]
|
106
|
+
params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
|
107
|
+
params[:order] = params[:order].nil? ? 'DESC' : params[:order]
|
108
|
+
params[:operation] = params[:operation].nil? ? ALL : params[:operation]
|
109
|
+
params[:status] = params[:status].nil? ? STATUS_ORDER_HUMAN_NAME[STATUS_ORDER[:finished]] : params[:status]
|
110
|
+
params[:order] = ASC unless params[:since].nil? || params[:end].nil?
|
111
|
+
|
112
|
+
params[:status] = STATUS_ORDER_HUMAN_NAME[STATUS_ORDER[:finished]] unless params[:operation].nil? && params[:operation] == ALL
|
113
|
+
|
114
|
+
StocksExchangeApiClient.make_api_request(:post,
|
115
|
+
params,
|
116
|
+
METHOD_NAME[:trans_history])
|
117
|
+
end
|
118
|
+
|
119
|
+
def grafic(params = {})
|
120
|
+
params[:pair] = params[:pair].nil? ? DEFAULT_PAIRS : params[:pair]
|
121
|
+
params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
|
122
|
+
params[:order] = params[:order].nil? ? ASC : params[:order]
|
123
|
+
params[:interval] = params[:interval].nil? ? INTERVAL[:day] : params[:interval]
|
124
|
+
params[:page] = params[:page].nil? ? 1 : params[:page]
|
125
|
+
params[:order] = ASC unless params[:since].nil? || params[:end].nil?
|
126
|
+
|
127
|
+
StocksExchangeApiClient.make_api_request(:post,
|
128
|
+
params,
|
129
|
+
METHOD_NAME[:grafic])
|
130
|
+
end
|
131
|
+
|
132
|
+
def generate_wallets(currency)
|
133
|
+
StocksExchangeApiClient.make_api_request(:post,
|
134
|
+
{ currency: currency },
|
135
|
+
METHOD_NAME[:generate_wallets])
|
136
|
+
end
|
137
|
+
|
138
|
+
def deposit(currency)
|
139
|
+
StocksExchangeApiClient.make_api_request(:post,
|
140
|
+
{ currency: currency },
|
141
|
+
METHOD_NAME[:deposit])
|
142
|
+
end
|
143
|
+
|
144
|
+
def withdraw(currency, address, amount)
|
145
|
+
params = {
|
146
|
+
currency: currency,
|
147
|
+
address: address,
|
148
|
+
amount: amount
|
149
|
+
}
|
150
|
+
|
151
|
+
StocksExchangeApiClient.make_api_request(:post,
|
152
|
+
params,
|
153
|
+
METHOD_NAME[:withdraw])
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module StocksExchangeApiClient
|
2
|
+
class Public
|
3
|
+
class << self
|
4
|
+
def currencies
|
5
|
+
StocksExchangeApiClient.make_api_request(:get,
|
6
|
+
nil,
|
7
|
+
'currencies')
|
8
|
+
end
|
9
|
+
|
10
|
+
def markets
|
11
|
+
StocksExchangeApiClient.make_api_request(:get,
|
12
|
+
nil,
|
13
|
+
'markets')
|
14
|
+
end
|
15
|
+
|
16
|
+
def markets_summary(currency1 = 'ETH', currency2 = 'BTC')
|
17
|
+
url = "market_summary/#{currency1}/#{currency2}"
|
18
|
+
StocksExchangeApiClient.make_api_request(:get,
|
19
|
+
nil,
|
20
|
+
url)
|
21
|
+
end
|
22
|
+
|
23
|
+
def ticker
|
24
|
+
StocksExchangeApiClient.make_api_request(:get,
|
25
|
+
nil,
|
26
|
+
'ticker')
|
27
|
+
end
|
28
|
+
|
29
|
+
def prices
|
30
|
+
StocksExchangeApiClient.make_api_request(:get,
|
31
|
+
nil,
|
32
|
+
'prices')
|
33
|
+
end
|
34
|
+
|
35
|
+
def trade_history(pair = DEFAULT_PAIRS)
|
36
|
+
url = "trades?pair=#{pair}"
|
37
|
+
StocksExchangeApiClient.make_api_request(:get,
|
38
|
+
nil,
|
39
|
+
url)
|
40
|
+
end
|
41
|
+
|
42
|
+
def order_book(pair = DEFAULT_PAIRS)
|
43
|
+
url = "orderbook?pair=#{pair}"
|
44
|
+
StocksExchangeApiClient.make_api_request(:get,
|
45
|
+
nil,
|
46
|
+
url)
|
47
|
+
end
|
48
|
+
|
49
|
+
def grafic(params = {})
|
50
|
+
params[:pair] = params[:pair].nil? ? DEFAULT_PAIRS : params[:pair]
|
51
|
+
params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
|
52
|
+
params[:order] = params[:order].nil? ? ASC : params[:order]
|
53
|
+
params[:interval] = params[:interval].nil? ? INTERVAL[:day] : params[:interval]
|
54
|
+
params[:page] = params[:page].nil? ? 1 : params[:page]
|
55
|
+
params[:order] = ASC unless params[:since].nil? || params[:end].nil?
|
56
|
+
encode_www_form = URI.encode_www_form(params)
|
57
|
+
|
58
|
+
url = "grafic_public?#{encode_www_form}"
|
59
|
+
StocksExchangeApiClient.make_api_request(:get,
|
60
|
+
nil,
|
61
|
+
url)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stocks_exchange_api_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'stocks_exchange_api_client'
|
8
|
+
spec.version = StocksExchangeApiClient::VERSION
|
9
|
+
spec.authors = ['Stocks Exchange']
|
10
|
+
|
11
|
+
spec.summary = 'Stocks Exchange API client for ruby.'
|
12
|
+
spec.description = 'Stocks Exchange provides all the core exchange functionality, and additional merchant tools available via the HTTP API where all returned messages are in JSON. Its much easier to work with the API by using one of the clients provided by Stocks.Exchange, so while this page describes the API in case you want or need to build your own client, the examples use the Ruby client.'
|
13
|
+
spec.homepage = 'https://github.com/StocksExchange/ruby-client#readme'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.extra_rdoc_files = ['README.md']
|
17
|
+
|
18
|
+
spec.required_ruby_version = '~> 2.2'
|
19
|
+
|
20
|
+
spec.add_dependency 'openssl', '~> 2.1', '>= 2.1.1'
|
21
|
+
spec.add_dependency 'httparty', '~> 0.16.2'
|
22
|
+
spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stocks_exchange_api_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stocks Exchange
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: openssl
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.1.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.1.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: httparty
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.16.2
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.16.2
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: json
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.1'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.1.0
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.1'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.1.0
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: bundler
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.16'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.16'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rake
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '10.0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '10.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.0'
|
109
|
+
description: Stocks Exchange provides all the core exchange functionality, and additional
|
110
|
+
merchant tools available via the HTTP API where all returned messages are in JSON.
|
111
|
+
Its much easier to work with the API by using one of the clients provided by Stocks.Exchange,
|
112
|
+
so while this page describes the API in case you want or need to build your own
|
113
|
+
client, the examples use the Ruby client.
|
114
|
+
email:
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files:
|
118
|
+
- README.md
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/stocks_exchange_api_client.rb
|
128
|
+
- lib/stocks_exchange_api_client/configuration.rb
|
129
|
+
- lib/stocks_exchange_api_client/errors/configuration_error.rb
|
130
|
+
- lib/stocks_exchange_api_client/private.rb
|
131
|
+
- lib/stocks_exchange_api_client/public.rb
|
132
|
+
- lib/stocks_exchange_api_client/version.rb
|
133
|
+
- stocks_exchange_api_client.gemspec
|
134
|
+
homepage: https://github.com/StocksExchange/ruby-client#readme
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2.2'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.7.6
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Stocks Exchange API client for ruby.
|
158
|
+
test_files: []
|