This repository has been archived by the owner on Jun 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1cca72
commit 04595ee
Showing
12 changed files
with
500 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Cryptoexchange::Exchanges | ||
module Ionomy | ||
class Market < Cryptoexchange::Models::Market | ||
NAME = 'ionomy' | ||
API_URL = 'https://ionomy.com/api/v1' | ||
|
||
def self.trade_page_url(args={}) | ||
"https://ionomy.com/en/markets/#{args[:target]}-#{args[:base]}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Cryptoexchange::Exchanges | ||
module Ionomy | ||
module Services | ||
class Market < Cryptoexchange::Services::Market | ||
class << self | ||
def supports_individual_ticker_query? | ||
false | ||
end | ||
end | ||
|
||
def fetch | ||
output = super ticker_url | ||
adapt_all(output) | ||
end | ||
|
||
def ticker_url | ||
"#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/markets-summaries" | ||
end | ||
|
||
def adapt_all(output) | ||
output['data'].map do |output| | ||
target, base = output['market'].split('-') | ||
market_pair = Cryptoexchange::Models::MarketPair.new( | ||
base: base, | ||
target: target, | ||
market: Ionomy::Market::NAME | ||
) | ||
|
||
adapt(output, market_pair) | ||
end | ||
end | ||
|
||
def adapt(output, market_pair) | ||
ticker = Cryptoexchange::Models::Ticker.new | ||
ticker.base = market_pair.base | ||
ticker.target = market_pair.target | ||
ticker.market = Ionomy::Market::NAME | ||
ticker.bid = NumericHelper.to_d(output['bidsLastPrice']) | ||
ticker.ask = NumericHelper.to_d(output['asksLastPrice']) | ||
ticker.last = NumericHelper.to_d(output['price']) | ||
ticker.volume = NumericHelper.to_d(output['volume']) | ||
ticker.high = NumericHelper.to_d(output['high']) | ||
ticker.low = NumericHelper.to_d(output['low']) | ||
ticker.change = NumericHelper.to_d(output['change']) | ||
ticker.timestamp = nil | ||
ticker.payload = output | ||
ticker | ||
end | ||
end | ||
end | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
lib/cryptoexchange/exchanges/ionomy/services/order_book.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Cryptoexchange::Exchanges | ||
module Ionomy | ||
module Services | ||
class OrderBook < Cryptoexchange::Services::Market | ||
class << self | ||
def supports_individual_ticker_query? | ||
true | ||
end | ||
end | ||
|
||
def fetch(market_pair) | ||
output = super(ticker_url(market_pair)) | ||
adapt(output, market_pair) | ||
end | ||
|
||
def ticker_url(market_pair) | ||
base = market_pair.base | ||
target = market_pair.target | ||
"#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/orderbook?market=#{target}-#{base}&type=both" | ||
end | ||
|
||
def adapt(output, market_pair) | ||
order_book = Cryptoexchange::Models::OrderBook.new | ||
|
||
order_book.base = market_pair.base | ||
order_book.target = market_pair.target | ||
order_book.market = Ionomy::Market::NAME | ||
order_book.asks = adapt_orders output['data']['asks'] | ||
order_book.bids = adapt_orders output['data']['bids'] | ||
order_book.timestamp = nil | ||
order_book.payload = output | ||
order_book | ||
end | ||
|
||
def adapt_orders(orders) | ||
orders.collect do |order_entry| | ||
Cryptoexchange::Models::Order.new(price: order_entry['price'], | ||
amount: order_entry['size'] | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Cryptoexchange::Exchanges | ||
module Ionomy | ||
module Services | ||
class Pairs < Cryptoexchange::Services::Pairs | ||
PAIRS_URL = "#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/markets" | ||
|
||
def fetch | ||
output = super | ||
adapt(output) | ||
end | ||
|
||
def adapt(output) | ||
output['data'].map do |output| | ||
target, base = output['market'].split('-') | ||
Cryptoexchange::Models::MarketPair.new( | ||
base: base, | ||
target: target, | ||
market: Ionomy::Market::NAME | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Cryptoexchange::Exchanges | ||
module Ionomy | ||
module Services | ||
class Trades < Cryptoexchange::Services::Market | ||
def fetch(market_pair) | ||
output = super(ticker_url(market_pair)) | ||
adapt(output, market_pair) | ||
end | ||
|
||
def ticker_url(market_pair) | ||
base = market_pair.base | ||
target = market_pair.target | ||
"#{Cryptoexchange::Exchanges::Ionomy::Market::API_URL}/public/market-history?market=#{target}-#{base}" | ||
end | ||
|
||
def adapt(output, market_pair) | ||
output['data'].collect do |trade| | ||
tr = Cryptoexchange::Models::Trade.new | ||
tr.trade_id = nil | ||
tr.base = market_pair.base | ||
tr.target = market_pair.target | ||
tr.market = Ionomy::Market::NAME | ||
tr.type = (trade['type'].include? "_BUY") ? "buy" : "sell" | ||
tr.price = trade['price'] | ||
tr.amount = trade['amount'] | ||
tr.timestamp = DateTime.parse(trade['createdAt']).to_time.to_i | ||
tr.payload = trade | ||
tr | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
63 changes: 63 additions & 0 deletions
63
spec/cassettes/vcr_cassettes/Ionomy/integration_specs_fetch_order_book.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.