forked from coingecko/cryptoexchange
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/coingecko/cryptoexchange
- Loading branch information
Showing
34 changed files
with
1,317 additions
and
2 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 Bitalong | ||
class Market < Cryptoexchange::Models::Market | ||
NAME = 'bitalong' | ||
API_URL = 'https://www.bitalong.com/api' | ||
|
||
def self.trade_page_url(args={}) | ||
"https://www.bitalong.com/trade/index/market/#{args[:base].downcase}_#{args[:target].downcase}" | ||
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,51 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitalong | ||
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::Bitalong::Market::API_URL}/index/tickers" | ||
end | ||
|
||
def adapt_all(output) | ||
output.map do |pair| | ||
base, target = pair[0].split('_') | ||
market_pair = Cryptoexchange::Models::MarketPair.new( | ||
base: base.upcase, | ||
target: target.upcase, | ||
market: Bitalong::Market::NAME | ||
) | ||
adapt(market_pair, pair[1]) | ||
end | ||
end | ||
|
||
def adapt(market_pair, output) | ||
ticker = Cryptoexchange::Models::Ticker.new | ||
ticker.base = market_pair.base | ||
ticker.target = market_pair.target | ||
ticker.market = Bitalong::Market::NAME | ||
ticker.last = NumericHelper.to_d(output['last']) | ||
ticker.high = NumericHelper.to_d(output['high24hr']) | ||
ticker.low = NumericHelper.to_d(output['low24hr']) | ||
ticker.bid = NumericHelper.to_d(output['highestBid']) | ||
ticker.ask = NumericHelper.to_d(output['lowestAsk']) | ||
ticker.volume = NumericHelper.to_d(output['baseVolume']) | ||
ticker.change = NumericHelper.to_d(output['percentChange']) | ||
ticker.timestamp = nil | ||
ticker.payload = output | ||
ticker | ||
end | ||
end | ||
end | ||
end | ||
end |
42 changes: 42 additions & 0 deletions
42
lib/cryptoexchange/exchanges/bitalong/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,42 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitalong | ||
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) | ||
"#{Cryptoexchange::Exchanges::Bitalong::Market::API_URL}/index/orderBook/#{market_pair.base.downcase}_#{market_pair.target.downcase}" | ||
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 = Bitalong::Market::NAME | ||
order_book.asks = adapt_orders(output['asks']) | ||
order_book.bids = adapt_orders(output['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[0], | ||
amount: order_entry[1]) | ||
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,23 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitalong | ||
module Services | ||
class Pairs < Cryptoexchange::Services::Pairs | ||
PAIRS_URL = "#{Cryptoexchange::Exchanges::Bitalong::Market::API_URL}/index/pairs" | ||
|
||
def fetch | ||
output = super | ||
market_pairs = [] | ||
output.each do |pair| | ||
base, target = pair.split('_') | ||
market_pairs << Cryptoexchange::Models::MarketPair.new( | ||
base: base.upcase, | ||
target: target.upcase, | ||
market: Bitalong::Market::NAME | ||
) | ||
end | ||
market_pairs | ||
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,32 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitalong | ||
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) | ||
"#{Cryptoexchange::Exchanges::Bitalong::Market::API_URL}/index/tradeHistory/#{market_pair.base.downcase}_#{market_pair.target.downcase}" | ||
end | ||
|
||
def adapt(output, market_pair) | ||
output['data'].collect do |trade| | ||
tr = Cryptoexchange::Models::Trade.new | ||
tr.trade_id = trade['tradeID'] | ||
tr.base = market_pair.base | ||
tr.target = market_pair.target | ||
tr.market = Bitalong::Market::NAME | ||
tr.type = trade['type'] | ||
tr.price = trade['rate'] | ||
tr.amount = trade['amount'] | ||
tr.timestamp = DateTime.parse(trade['date']).to_time.to_i | ||
tr.payload = trade | ||
tr | ||
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,12 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitstorage | ||
class Market < Cryptoexchange::Models::Market | ||
NAME = 'bitstorage' | ||
API_URL = 'https://bitstorage.finance/api' | ||
|
||
def self.trade_page_url(args={}) | ||
"https://bitstorage.finance/market/#{args[:base]}-#{args[:target]}" | ||
end | ||
end | ||
end | ||
end |
51 changes: 51 additions & 0 deletions
51
lib/cryptoexchange/exchanges/bitstorage/services/market.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,51 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitstorage | ||
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::Bitstorage::Market::API_URL}/ticker" | ||
end | ||
|
||
def adapt_all(output) | ||
output.map do |pair| | ||
base, target = pair['pairs'].split('_') | ||
market_pair = Cryptoexchange::Models::MarketPair.new( | ||
base: base, | ||
target: target, | ||
market: Bitstorage::Market::NAME | ||
) | ||
adapt(market_pair, pair) | ||
end | ||
end | ||
|
||
def adapt(market_pair, output) | ||
ticker = Cryptoexchange::Models::Ticker.new | ||
ticker.base = market_pair.base | ||
ticker.target = market_pair.target | ||
ticker.market = Bitstorage::Market::NAME | ||
ticker.last = NumericHelper.to_d(output['last_price']) | ||
ticker.high = NumericHelper.to_d(output['high']) | ||
ticker.low = NumericHelper.to_d(output['low']) | ||
ticker.bid = NumericHelper.to_d(output['bid']) | ||
ticker.ask = NumericHelper.to_d(output['ask']) | ||
ticker.volume = NumericHelper.divide(output['24H_volume'], ticker.last) if ticker.last > 0 | ||
ticker.change = NumericHelper.to_d(output['change']) | ||
ticker.timestamp = nil | ||
ticker.payload = output | ||
ticker | ||
end | ||
end | ||
end | ||
end | ||
end |
43 changes: 43 additions & 0 deletions
43
lib/cryptoexchange/exchanges/bitstorage/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,43 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitstorage | ||
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) | ||
"#{Cryptoexchange::Exchanges::Bitstorage::Market::API_URL}/order-book?market=#{market_pair.base}¤cy=#{market_pair.target}" | ||
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 = Bitstorage::Market::NAME | ||
order_book.asks = output['order-book']['ask'].empty? ? ['Nil'] : adapt_orders(output['order-book']['ask']) | ||
order_book.bids = output['order-book']['bid'].empty? ? ['Nil'] : adapt_orders(output['order-book']['bid']) | ||
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['order_amount'], | ||
timestamp: order_entry['timestamp']) | ||
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,23 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitstorage | ||
module Services | ||
class Pairs < Cryptoexchange::Services::Pairs | ||
PAIRS_URL = "#{Cryptoexchange::Exchanges::Bitstorage::Market::API_URL}/ticker" | ||
|
||
def fetch | ||
output = super | ||
market_pairs = [] | ||
output.each do |pair| | ||
base, target = pair['pairs'].split('_') | ||
market_pairs << Cryptoexchange::Models::MarketPair.new( | ||
base: base, | ||
target: target, | ||
market: Bitstorage::Market::NAME | ||
) | ||
end | ||
market_pairs | ||
end | ||
end | ||
end | ||
end | ||
end |
32 changes: 32 additions & 0 deletions
32
lib/cryptoexchange/exchanges/bitstorage/services/trades.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,32 @@ | ||
module Cryptoexchange::Exchanges | ||
module Bitstorage | ||
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) | ||
"#{Cryptoexchange::Exchanges::Bitstorage::Market::API_URL}/transactions?market=#{market_pair.base}¤cy=#{market_pair.target}" | ||
end | ||
|
||
def adapt(output, market_pair) | ||
output['transactions']['data'].collect do |trade| | ||
tr = Cryptoexchange::Models::Trade.new | ||
tr.trade_id = trade['id'] | ||
tr.base = market_pair.base | ||
tr.target = market_pair.target | ||
tr.market = Bitstorage::Market::NAME | ||
tr.type = trade['maker_type'] | ||
tr.price = trade['price'] | ||
tr.amount = trade['amount'] | ||
tr.timestamp = trade['timestamp'] | ||
tr.payload = trade | ||
tr | ||
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 |
---|---|---|
|
@@ -67,3 +67,7 @@ | |
:target: ARUB | ||
- :base: BTC | ||
:target: USDT | ||
- :base: BTC | ||
:target: RUB | ||
- :base: USDT | ||
:target: RUB |
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 Omgfin | ||
class Market < Cryptoexchange::Models::Market | ||
NAME = 'omgfin' | ||
API_URL = 'https://omgfin.com/api/v1/ticker/24hr' | ||
|
||
def self.trade_page_url(args={}) | ||
"https://omgfin.com/exchange/trade/market/#{args[:base]}#{args[:target]}" | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.