Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tmlee committed May 2, 2019
2 parents e42d77a + 624f043 commit 60714ee
Show file tree
Hide file tree
Showing 34 changed files with 1,317 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Or install it yourself as:
| Bisq | Y | | Y | | Y | | bisq | |
| Bit2C | Y | Y | Y | | User-Defined| Y | bit2c | |
| Bit-Z | Y | | | | Y | | bit_z | |
| Bitalong | Y | Y | Y | | Y | Y | bitalong | |
| Bitbank | Y | Y | Y | | User-Defined| Y | bitbank | |
| Bitbay | Y | | | | User-Defined| | bitbay | |
| Bitbegin | Y | N | N | | Y | Y | bitbegin | |
Expand Down Expand Up @@ -99,6 +100,7 @@ Or install it yourself as:
| Bitso | Y | | | | Y | | bitso | |
| Bitstamp | Y | Y [x] | Y | | User-Defined| | bitstamp | |
| Bitsten | Y | Y | N | | Y | Y | bitsten | |
| Bitstorage | Y | Y | Y | | Y | Y | bitstorage | |
| Bittrex | Y | Y [x] | | | Y | Y | bittrex | |
| Bkex | Y | N | N | | Y | Y | bkex | |
| Bleutrade | Y | | | | Y | | bleutrade | |
Expand Down
12 changes: 12 additions & 0 deletions lib/cryptoexchange/exchanges/bitalong/market.rb
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
51 changes: 51 additions & 0 deletions lib/cryptoexchange/exchanges/bitalong/services/market.rb
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 lib/cryptoexchange/exchanges/bitalong/services/order_book.rb
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
23 changes: 23 additions & 0 deletions lib/cryptoexchange/exchanges/bitalong/services/pairs.rb
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
32 changes: 32 additions & 0 deletions lib/cryptoexchange/exchanges/bitalong/services/trades.rb
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
12 changes: 12 additions & 0 deletions lib/cryptoexchange/exchanges/bitstorage/market.rb
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 lib/cryptoexchange/exchanges/bitstorage/services/market.rb
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 lib/cryptoexchange/exchanges/bitstorage/services/order_book.rb
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}&currency=#{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
23 changes: 23 additions & 0 deletions lib/cryptoexchange/exchanges/bitstorage/services/pairs.rb
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 lib/cryptoexchange/exchanges/bitstorage/services/trades.rb
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}&currency=#{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
4 changes: 4 additions & 0 deletions lib/cryptoexchange/exchanges/kuna/kuna.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@
:target: ARUB
- :base: BTC
:target: USDT
- :base: BTC
:target: RUB
- :base: USDT
:target: RUB
2 changes: 1 addition & 1 deletion lib/cryptoexchange/exchanges/kyber_network/market.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Market < Cryptoexchange::Models::Market
API_URL = 'https://tracker.kyber.network/api'

def self.trade_page_url(args={})
"https://kyber.network/swap/#{args[:target]}_#{args[:base]}"
"https://kyber.network/swap/#{args[:target].downcase}-#{args[:base].downcase}"
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/cryptoexchange/exchanges/omgfin/market.rb
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
Loading

0 comments on commit 60714ee

Please sign in to comment.