Skip to content
This repository was archived by the owner on Jun 22, 2020. It is now read-only.

Commit 9e2eb43

Browse files
committed
Add ionomy exchange
1 parent b1cca72 commit 9e2eb43

File tree

12 files changed

+500
-0
lines changed

12 files changed

+500
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ Or install it yourself as:
322322
| IndependentReserve| Y | Y [x] | N | | Y | Y |independent_reserve| |
323323
| InfinityCoin | Y | | | | Y | Y | infinity_coin | |
324324
| InstantBitex | Y | Y [x] | Y | | Y | | instantbitex | |
325+
| ionomy | Y | Y | Y | | Y | Y | ionomy | |
325326
| Iqfinex | Y | Y | Y | | Y | Y | iqfinex | |
326327
| Ironex | Y | | | | Y | | ironex | |
327328
| Itbit | Y | Y [x] | Y | | User-Defined| | itbit | |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Cryptoexchange::Exchanges
2+
module Ionomy
3+
class Market < Cryptoexchange::Models::Market
4+
NAME = 'ionomy'
5+
API_URL = 'https://ionomy.com/api/v1'
6+
7+
def self.trade_page_url(args={})
8+
"https://ionomy.com/en/markets/#{args[:target]}-#{args[:base]}"
9+
end
10+
end
11+
end
12+
end
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module Cryptoexchange::Exchanges
2+
module Ionomy
3+
module Services
4+
class Market < Cryptoexchange::Services::Market
5+
class << self
6+
def supports_individual_ticker_query?
7+
false
8+
end
9+
end
10+
11+
def fetch
12+
output = super ticker_url
13+
adapt_all(output)
14+
end
15+
16+
def ticker_url
17+
"#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/markets-summaries"
18+
end
19+
20+
def adapt_all(output)
21+
output['data'].map do |output|
22+
target, base = output['market'].split('-')
23+
market_pair = Cryptoexchange::Models::MarketPair.new(
24+
base: base,
25+
target: target,
26+
market: Ionomy::Market::NAME
27+
)
28+
29+
adapt(output, market_pair)
30+
end
31+
end
32+
33+
def adapt(output, market_pair)
34+
ticker = Cryptoexchange::Models::Ticker.new
35+
ticker.base = market_pair.base
36+
ticker.target = market_pair.target
37+
ticker.market = Ionomy::Market::NAME
38+
ticker.bid = NumericHelper.to_d(output['highestBid'])
39+
ticker.ask = NumericHelper.to_d(output['lowestAsk'])
40+
ticker.last = NumericHelper.to_d(output['price'])
41+
ticker.volume = NumericHelper.to_d(output['volume'])
42+
ticker.high = NumericHelper.to_d(output['high'])
43+
ticker.low = NumericHelper.to_d(output['low'])
44+
ticker.change = NumericHelper.to_d(output['change'])
45+
ticker.timestamp = nil
46+
ticker.payload = output
47+
ticker
48+
end
49+
end
50+
end
51+
end
52+
end
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module Cryptoexchange::Exchanges
2+
module Ionomy
3+
module Services
4+
class OrderBook < Cryptoexchange::Services::Market
5+
class << self
6+
def supports_individual_ticker_query?
7+
true
8+
end
9+
end
10+
11+
def fetch(market_pair)
12+
output = super(ticker_url(market_pair))
13+
adapt(output, market_pair)
14+
end
15+
16+
def ticker_url(market_pair)
17+
base = market_pair.base
18+
target = market_pair.target
19+
"#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/orderbook?market=#{target}-#{base}&type=both"
20+
end
21+
22+
def adapt(output, market_pair)
23+
order_book = Cryptoexchange::Models::OrderBook.new
24+
25+
order_book.base = market_pair.base
26+
order_book.target = market_pair.target
27+
order_book.market = Ionomy::Market::NAME
28+
order_book.asks = adapt_orders output['data']['asks']
29+
order_book.bids = adapt_orders output['data']['bids']
30+
order_book.timestamp = nil
31+
order_book.payload = output
32+
order_book
33+
end
34+
35+
def adapt_orders(orders)
36+
orders.collect do |order_entry|
37+
Cryptoexchange::Models::Order.new(price: order_entry['price'],
38+
amount: order_entry['size']
39+
)
40+
end
41+
end
42+
end
43+
end
44+
end
45+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Cryptoexchange::Exchanges
2+
module Ionomy
3+
module Services
4+
class Pairs < Cryptoexchange::Services::Pairs
5+
PAIRS_URL = "#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/markets"
6+
7+
def fetch
8+
output = super
9+
adapt(output)
10+
end
11+
12+
def adapt(output)
13+
output['data'].map do |output|
14+
target, base = output['market'].split('-')
15+
Cryptoexchange::Models::MarketPair.new(
16+
base: base,
17+
target: target,
18+
market: Ionomy::Market::NAME
19+
)
20+
end
21+
end
22+
end
23+
end
24+
end
25+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module Cryptoexchange::Exchanges
2+
module Ionomy
3+
module Services
4+
class Trades < Cryptoexchange::Services::Market
5+
def fetch(market_pair)
6+
output = super(ticker_url(market_pair))
7+
adapt(output, market_pair)
8+
end
9+
10+
def ticker_url(market_pair)
11+
base = market_pair.base
12+
target = market_pair.target
13+
"#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/market-history?market=#{target}-#{base}"
14+
end
15+
16+
def adapt(output, market_pair)
17+
output['data'].collect do |trade|
18+
tr = Cryptoexchange::Models::Trade.new
19+
tr.trade_id = nil
20+
tr.base = market_pair.base
21+
tr.target = market_pair.target
22+
tr.market = Ionomy::Market::NAME
23+
tr.type = (trade['type'].include? "_BUY") ? "buy" : "sell"
24+
tr.price = trade['price']
25+
tr.amount = trade['amount']
26+
tr.timestamp = DateTime.parse(trade['createdAt']).to_time.to_i
27+
tr.payload = trade
28+
tr
29+
end
30+
end
31+
end
32+
end
33+
end
34+
end

spec/cassettes/vcr_cassettes/Ionomy/integration_specs_fetch_order_book.yml

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)