diff --git a/README.md b/README.md index 183ee280e..f7f5ad0e8 100644 --- a/README.md +++ b/README.md @@ -250,6 +250,7 @@ Or install it yourself as: | Dobitrade | Y | Y [x] | N | | Y | Y | dobitrade | | | Dove Wallet | Y | Y [x] | Y | | Y | Y | dove_wallet | | | Dragonex | Y | Y [x] | N | | Y | Y | dragonex | | +| Drgx | Y | Y | Y | | Y | Y | drgx | | | Dsx | Y | Y | Y | | Y | | dsx | | | Dydx | Y | Y [x] | N | | Y | N | dydx | | | Eosex | Y | N | N | | Y | Y | eosex | | diff --git a/lib/cryptoexchange/exchanges/drgx/market.rb b/lib/cryptoexchange/exchanges/drgx/market.rb new file mode 100755 index 000000000..2fd2d071d --- /dev/null +++ b/lib/cryptoexchange/exchanges/drgx/market.rb @@ -0,0 +1,12 @@ +module Cryptoexchange::Exchanges + module Drgx + class Market < Cryptoexchange::Models::Market + NAME = 'drgx' + API_URL = 'https://exchange.drgx.io/cmc/public' + + def self.trade_page_url(args={}) + "https://exchange.drgx.io/en/exchange/#{args[:base].upcase}-#{args[:target].upcase}" + end + end + end +end diff --git a/lib/cryptoexchange/exchanges/drgx/services/market.rb b/lib/cryptoexchange/exchanges/drgx/services/market.rb new file mode 100755 index 000000000..f3392b92a --- /dev/null +++ b/lib/cryptoexchange/exchanges/drgx/services/market.rb @@ -0,0 +1,51 @@ +module Cryptoexchange::Exchanges + module Drgx + module Services + class Market < Cryptoexchange::Services::Market + class << self + def supports_individual_ticker_query? + false + end + end + + def fetch + output = super(self.ticker_url) + adapt_all(output) + end + + def ticker_url + "https://feeds-api.drgx.io/drgx/tickers.json" + end + + def adapt_all(output) + output.map do |pair, ticker| + base, target = pair.split('_') + market_pair = Cryptoexchange::Models::MarketPair.new( + base: base, + target: target, + market: Drgx::Market::NAME + ) + + adapt(ticker, 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 = Drgx::Market::NAME + ticker.last = NumericHelper.to_d(output['last']) + ticker.bid = NumericHelper.to_d(output['highestBid']) + ticker.ask = NumericHelper.to_d(output['lowestAsk']) + ticker.high = NumericHelper.to_d(output['high24hr']) + ticker.low = NumericHelper.to_d(output['low24hr']) + ticker.volume = NumericHelper.to_d(output['baseVolume']) + ticker.timestamp = nil + ticker.payload = output + ticker + end + end + end + end +end diff --git a/lib/cryptoexchange/exchanges/drgx/services/order_book.rb b/lib/cryptoexchange/exchanges/drgx/services/order_book.rb new file mode 100644 index 000000000..205b9b04d --- /dev/null +++ b/lib/cryptoexchange/exchanges/drgx/services/order_book.rb @@ -0,0 +1,42 @@ +module Cryptoexchange::Exchanges + module Drgx + module Services + class OrderBook < Cryptoexchange::Services::Market + class << self + def supports_individual_ticker_query? + true + end + end + + def fetch(market_pair) + output = super(order_book_url(market_pair)) + adapt(output, market_pair) + end + + def order_book_url(market_pair) + "#{Cryptoexchange::Exchanges::Drgx::Market::API_URL}/orderbookCm?pair=#{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 = Drgx::Market::NAME + order_book.asks = adapt_orders(output['asks']) + order_book.bids = adapt_orders(output['bids']) + order_book.payload = output + order_book + end + + def adapt_orders(orders) + orders.collect do |order_entry| + Cryptoexchange::Models::Order.new(price: NumericHelper.to_d(order_entry[0]), + amount: NumericHelper.to_d(order_entry[1]), + timestamp: nil) + end + end + end + end + end +end diff --git a/lib/cryptoexchange/exchanges/drgx/services/pairs.rb b/lib/cryptoexchange/exchanges/drgx/services/pairs.rb new file mode 100755 index 000000000..21533e29f --- /dev/null +++ b/lib/cryptoexchange/exchanges/drgx/services/pairs.rb @@ -0,0 +1,27 @@ +module Cryptoexchange::Exchanges + module Drgx + module Services + class Pairs < Cryptoexchange::Services::Pairs + PAIRS_URL = "https://feeds-api.drgx.io/drgx/tickers.json" + + def fetch + output = super + adapt(output) + end + + def adapt(output) + market_pairs = [] + output.each do |pair, ticker| + market_pair = Cryptoexchange::Models::MarketPair.new + base, target = pair.split('_') + market_pair.base = base + market_pair.target = target + market_pair.market = Drgx::Market::NAME + market_pairs << market_pair + end + market_pairs + end + end + end + end +end diff --git a/lib/cryptoexchange/exchanges/drgx/services/trades.rb b/lib/cryptoexchange/exchanges/drgx/services/trades.rb new file mode 100644 index 000000000..b801b550d --- /dev/null +++ b/lib/cryptoexchange/exchanges/drgx/services/trades.rb @@ -0,0 +1,33 @@ +module Cryptoexchange::Exchanges + module Drgx + module Services + class Trades < Cryptoexchange::Services::Market + + def fetch(market_pair) + output = super(trades_url(market_pair)) + adapt(output, market_pair) + end + + def trades_url(market_pair) + "#{Cryptoexchange::Exchanges::Drgx::Market::API_URL}/TradesCm?pair=#{market_pair.base.downcase}_#{market_pair.target.downcase}" + end + + def adapt(output, market_pair) + output.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 = Drgx::Market::NAME + tr.type = trade['type'] + tr.price = trade['price'] + tr.amount = trade['base_volume'] + tr.timestamp = trade['trade_timestamp'] + tr.payload = trade + tr + end + end + end + end + end +end diff --git a/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_order_book.yml b/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_order_book.yml new file mode 100644 index 000000000..faad8e129 --- /dev/null +++ b/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_order_book.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: get + uri: https://exchange.drgx.io/cmc/public/orderbookCm?pair=drg_eth + body: + encoding: UTF-8 + string: '' + headers: + Connection: + - close + Host: + - exchange.drgx.io + User-Agent: + - http.rb/5.0.0.pre + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 Mar 2020 17:56:21 GMT + Content-Type: + - application/json;charset=UTF-8 + Content-Length: + - '792' + Connection: + - close + Set-Cookie: + - AWSELB=41076F071A4D5467FA79DEFB52FB48C8E92113E856F426869115B0173729FED900DEBF88A8893DB8C39ED0E1B43213196258E3B1CBFFC4C823092716457FB0E33FA0914D9C;PATH=/;MAX-AGE=1800 + - AWSELBCORS=41076F071A4D5467FA79DEFB52FB48C8E92113E856F426869115B0173729FED900DEBF88A8893DB8C39ED0E1B43213196258E3B1CBFFC4C823092716457FB0E33FA0914D9C;PATH=/;MAX-AGE=1800;SECURE;SAMESITE=None + - __cfduid=dbe947ff1d9a0bce7ef8e76f360a54b2a1585072580; expires=Thu, 23-Apr-20 + 17:56:20 GMT; path=/; domain=.drgx.io; HttpOnly; SameSite=Lax; Secure + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Headers: + - content-type, api-key, api-sign, auth-token + Access-Control-Allow-Origin: + - "*" + Cache-Control: + - no-cache, private, max-age=0 + - no-cache="set-cookie" + Expires: + - Tue, 24 Mar 2020 17:56:21 GMT + Strict-Transport-Security: + - max-age=15768000 + X-Frame-Options: + - SAMEORIGIN + Cf-Cache-Status: + - DYNAMIC + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 579244ae7bf3d5a7-BOM + body: + encoding: UTF-8 + string: '{"timestamp":1585031274,"asks":[["0.000295","1000"],["0.0003","1000"],["0.000305","1000"],["0.00031","1000"],["0.00033","1000"],["0.00034","1000"],["0.00045","50"],["0.000592","20000"],["0.000593","1982.24246503"],["0.0006","7414.78083637"],["0.00061","15200"],["0.00073","100"],["0.001","10000"],["0.00136","20000"],["0.0038","88"],["0.003995","4000.46209638"],["0.003996","50000"],["0.0051","20000"],["0.0054","50100"],["0.005499","100000"],["0.0055","150600"],["0.006","5700"],["0.013","25000"],["0.035","88"],["0.05","88"],["0.1","250000"],["0.999999","88"],["1","8321"]],"bids":[["0.000138","3758.55072464"],["0.000137","4000"],["0.000124","14427.05201613"],["0.000123","11382"],["0.00011","2161.66451314"],["0.000106","1345"],["0.000104","5000"],["0.000103","287"],["0.000101","5000"]]}' + http_version: + recorded_at: Tue, 24 Mar 2020 17:56:04 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_pairs.yml b/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_pairs.yml new file mode 100644 index 000000000..63f3f9423 --- /dev/null +++ b/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_pairs.yml @@ -0,0 +1,55 @@ +--- +http_interactions: +- request: + method: get + uri: https://feeds-api.drgx.io/drgx/tickers.json + body: + encoding: UTF-8 + string: '' + headers: + Connection: + - close + Host: + - feeds-api.drgx.io + User-Agent: + - http.rb/5.0.0.pre + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 Mar 2020 17:56:20 GMT + Content-Type: + - application/json + Content-Length: + - '2245' + Connection: + - close + Set-Cookie: + - __cfduid=d42a399920bfd0fe031d4d36692ebea2d1585072579; expires=Thu, 23-Apr-20 + 17:56:19 GMT; path=/; domain=.drgx.io; HttpOnly; SameSite=Lax; Secure + X-Amz-Id-2: + - JApfL9MC76Xd39sbT4zVHK5D5OVIwErTDR8/0Ux2TDls/ftzIqqxjdDxkcxBzO5sKe10+lebkFg= + X-Amz-Request-Id: + - FA53D0C0432FB529 + Cache-Control: + - max-age=60, public + Last-Modified: + - Tue, 24 Mar 2020 16:33:57 GMT + Etag: + - '"4ed313c194f4bf8a6a86dadccee0e21e"' + Cf-Cache-Status: + - DYNAMIC + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 579244a818244dad-BOM + body: + encoding: ASCII-8BIT + string: '{"ETH_BTC":{"last":0.02130982,"lowestAsk":0,"highestBid":0,"percentChange":-9.38342035,"baseVolume":3.38404738,"high24hr":0.02130982,"low24hr":0.02067957,"quoteVolume24hr":0.07302086,"id":"ETH-BTC","quoteVolume":0},"DRG_ETH":{"last":0.000279,"lowestAsk":0.000295,"highestBid":0.000138,"percentChange":0,"baseVolume":46303.61083442,"high24hr":0.000329,"low24hr":0.000273,"quoteVolume24hr":16.70031796,"id":"DRG-ETH","quoteVolume":0},"DRG_BTC":{"last":0.00000699,"lowestAsk":0.00000949,"highestBid":0.00000425,"percentChange":6.97223835,"baseVolume":45181.86737346,"high24hr":0.00000711,"low24hr":0.00000668,"quoteVolume24hr":0.46762152,"id":"DRG-BTC","quoteVolume":0},"DRG_LTC":{"last":0,"lowestAsk":0.0017,"highestBid":0.0005,"percentChange":0,"baseVolume":0,"high24hr":0,"low24hr":0,"quoteVolume24hr":0,"id":"DRG-LTC","quoteVolume":0},"DRG_EUR":{"last":0.05,"lowestAsk":0.14,"highestBid":0,"percentChange":-33.33333333,"baseVolume":21911.66666667,"high24hr":0.06,"low24hr":0.04,"quoteVolume24hr":929.16,"id":"DRG-EUR","quoteVolume":0},"BTC_USDC":{"last":6905,"lowestAsk":0,"highestBid":0,"percentChange":-13.12930965,"baseVolume":0.09431368,"high24hr":6905,"low24hr":6247,"quoteVolume24hr":826.14684437,"id":"BTC-USDC","quoteVolume":0},"ETH_USDC":{"last":155,"lowestAsk":0,"highestBid":0,"percentChange":-18.9278311,"baseVolume":3.48617576,"high24hr":162,"low24hr":134,"quoteVolume24hr":523.63314139,"id":"ETH-USDC","quoteVolume":0},"DRG_XRP":{"last":0.3,"lowestAsk":0.6789,"highestBid":0.1556677,"percentChange":-31.25611916,"baseVolume":7108.43892494,"high24hr":0.301,"low24hr":0.23,"quoteVolume24hr":1843.00000271,"id":"DRG-XRP","quoteVolume":0},"XRP_BTC":{"last":0.00002603,"lowestAsk":0,"highestBid":0,"percentChange":-4.25264186,"baseVolume":1772.14533032,"high24hr":0.00002639,"low24hr":0.0000242,"quoteVolume24hr":0.04316708,"id":"XRP-BTC","quoteVolume":0},"DRG_USDC":{"last":0.054,"lowestAsk":0.299,"highestBid":0,"percentChange":-37.85341617,"baseVolume":13605.69575016,"high24hr":0.062,"low24hr":0.043,"quoteVolume24hr":860.00002019,"id":"DRG-USDC","quoteVolume":0},"DRG_USDT20":{"last":0,"lowestAsk":0.2,"highestBid":0,"percentChange":0,"baseVolume":0,"high24hr":0,"low24hr":0,"quoteVolume24hr":0,"id":"DRG-USDT20","quoteVolume":0}}' + http_version: + recorded_at: Tue, 24 Mar 2020 17:56:03 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_trades.yml b/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_trades.yml new file mode 100644 index 000000000..83340805a --- /dev/null +++ b/spec/cassettes/vcr_cassettes/Drgx/integration_specs_fetch_trades.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: get + uri: https://exchange.drgx.io/cmc/public/TradesCm?pair=drg_eth + body: + encoding: UTF-8 + string: '' + headers: + Connection: + - close + Host: + - exchange.drgx.io + User-Agent: + - http.rb/5.0.0.pre + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 Mar 2020 17:56:21 GMT + Content-Type: + - application/json;charset=UTF-8 + Content-Length: + - '7180' + Connection: + - close + Set-Cookie: + - AWSELB=41076F071A4D5467FA79DEFB52FB48C8E92113E856F426869115B0173729FED900DEBF88A8893DB8C39ED0E1B43213196258E3B1CBFFC4C823092716457FB0E33FA0914D9C;PATH=/;MAX-AGE=1800 + - AWSELBCORS=41076F071A4D5467FA79DEFB52FB48C8E92113E856F426869115B0173729FED900DEBF88A8893DB8C39ED0E1B43213196258E3B1CBFFC4C823092716457FB0E33FA0914D9C;PATH=/;MAX-AGE=1800;SECURE;SAMESITE=None + - __cfduid=d5b545d543fecb4d1f4807d2e0e1fc3121585072581; expires=Thu, 23-Apr-20 + 17:56:21 GMT; path=/; domain=.drgx.io; HttpOnly; SameSite=Lax; Secure + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Headers: + - content-type, api-key, api-sign, auth-token + Access-Control-Allow-Origin: + - "*" + Cache-Control: + - no-cache, private, max-age=0 + - no-cache="set-cookie" + Expires: + - Tue, 24 Mar 2020 17:56:21 GMT + Strict-Transport-Security: + - max-age=15768000 + X-Frame-Options: + - SAMEORIGIN + Cf-Cache-Status: + - DYNAMIC + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 579244b2eb7dd5e4-BOM + body: + encoding: UTF-8 + string: '[{"tradeID":58545,"price":"0.000294","base_volume":"890","quote_volume":0.26166,"trade_timestamp":1585070561,"type":"buy"},{"tradeID":58542,"price":"0.000292","base_volume":"1056","quote_volume":0.308352,"trade_timestamp":1585069311,"type":"buy"},{"tradeID":58540,"price":"0.00029","base_volume":"1137.93103448","quote_volume":0.32999999999920004,"trade_timestamp":1585068858,"type":"buy"},{"tradeID":58533,"price":"0.000275","base_volume":"1200","quote_volume":0.33,"trade_timestamp":1585068493,"type":"buy"},{"tradeID":58530,"price":"0.000279","base_volume":"1182.79569892","quote_volume":0.32999999999868,"trade_timestamp":1585067298,"type":"buy"},{"tradeID":58529,"price":"0.000274","base_volume":"1094.89051095","quote_volume":0.30000000000029997,"trade_timestamp":1585066954,"type":"buy"},{"tradeID":58526,"price":"0.000278","base_volume":"1079.13669065","quote_volume":0.3000000000007,"trade_timestamp":1585066740,"type":"buy"},{"tradeID":58515,"price":"0.000273","base_volume":"989.01098901","quote_volume":0.26999999999973,"trade_timestamp":1585063433,"type":"buy"},{"tradeID":58508,"price":"0.000277","base_volume":"1119.13357401","quote_volume":0.31000000000077005,"trade_timestamp":1585062989,"type":"buy"},{"tradeID":58507,"price":"0.000282","base_volume":"992.90780142","quote_volume":0.28000000000044006,"trade_timestamp":1585061128,"type":"buy"},{"tradeID":58504,"price":"0.000285","base_volume":"1052.63157895","quote_volume":0.30000000000075,"trade_timestamp":1585059995,"type":"buy"},{"tradeID":58495,"price":"0.00028","base_volume":"1178.57142857","quote_volume":0.3299999999996,"trade_timestamp":1585058590,"type":"buy"},{"tradeID":58493,"price":"0.000288","base_volume":"1145.83333333","quote_volume":0.32999999999904,"trade_timestamp":1585058119,"type":"buy"},{"tradeID":58492,"price":"0.000293","base_volume":"1023.89078498","quote_volume":0.29999999999914,"trade_timestamp":1585056172,"type":"buy"},{"tradeID":58490,"price":"0.000281","base_volume":"818.50533808","quote_volume":0.23000000000048,"trade_timestamp":1585055058,"type":"buy"},{"tradeID":58488,"price":"0.000284","base_volume":"915.49295775","quote_volume":0.260000000001,"trade_timestamp":1585054445,"type":"buy"},{"tradeID":58481,"price":"0.000287","base_volume":"905.92334495","quote_volume":0.26000000000065,"trade_timestamp":1585054010,"type":"buy"},{"tradeID":58476,"price":"0.000282","base_volume":"1063.82978723","quote_volume":0.29999999999886,"trade_timestamp":1585052115,"type":"buy"},{"tradeID":58475,"price":"0.000288","base_volume":"1145.83333333","quote_volume":0.32999999999904,"trade_timestamp":1585052006,"type":"buy"},{"tradeID":58473,"price":"0.000285","base_volume":"1157.89473684","quote_volume":0.3299999999994,"trade_timestamp":1585051057,"type":"buy"},{"tradeID":58466,"price":"0.000282","base_volume":"1170.21276596","quote_volume":0.33000000000072005,"trade_timestamp":1585049843,"type":"buy"},{"tradeID":58462,"price":"0.000294","base_volume":"578.23129252","quote_volume":0.17000000000088,"trade_timestamp":1585049236,"type":"buy"},{"tradeID":58459,"price":"0.000292","base_volume":"993.15068493","quote_volume":0.28999999999956,"trade_timestamp":1585048366,"type":"buy"},{"tradeID":58458,"price":"0.000289","base_volume":"1107.26643599","quote_volume":0.32000000000110995,"trade_timestamp":1585047652,"type":"buy"},{"tradeID":58451,"price":"0.000282","base_volume":"1099.29078014","quote_volume":0.30999999999948,"trade_timestamp":1585046665,"type":"buy"},{"tradeID":58447,"price":"0.00028","base_volume":"964.28571429","quote_volume":0.27000000000119995,"trade_timestamp":1585045694,"type":"buy"},{"tradeID":58446,"price":"0.000291","base_volume":"962.19931271","quote_volume":0.27999999999861,"trade_timestamp":1585045595,"type":"buy"},{"tradeID":58443,"price":"0.000289","base_volume":"622.83737024","quote_volume":0.17999999999936,"trade_timestamp":1585044549,"type":"buy"},{"tradeID":58442,"price":"0.00029","base_volume":"517.24137931","quote_volume":0.1499999999999,"trade_timestamp":1585043525,"type":"buy"},{"tradeID":58435,"price":"0.000288","base_volume":"1041.66666667","quote_volume":0.30000000000096,"trade_timestamp":1585042605,"type":"buy"},{"tradeID":58429,"price":"0.000283","base_volume":"706.71378092","quote_volume":0.20000000000036,"trade_timestamp":1585041478,"type":"buy"},{"tradeID":58428,"price":"0.000286","base_volume":"874.12587413","quote_volume":0.25000000000118,"trade_timestamp":1585040262,"type":"buy"},{"tradeID":58421,"price":"0.000281","base_volume":"782.91814947","quote_volume":0.22000000000107,"trade_timestamp":1585039014,"type":"buy"},{"tradeID":58417,"price":"0.00029","base_volume":"500","quote_volume":0.145,"trade_timestamp":1585037796,"type":"buy"},{"tradeID":58415,"price":"0.000284","base_volume":"704.22535211","quote_volume":0.19999999999924,"trade_timestamp":1585036967,"type":"buy"},{"tradeID":58413,"price":"0.000282","base_volume":"714","quote_volume":0.20134800000000003,"trade_timestamp":1585036239,"type":"buy"},{"tradeID":58404,"price":"0.000287","base_volume":"666","quote_volume":0.19114199999999998,"trade_timestamp":1585035393,"type":"buy"},{"tradeID":58402,"price":"0.000289","base_volume":"484.42906574","quote_volume":0.13999999999885998,"trade_timestamp":1585034685,"type":"buy"},{"tradeID":58400,"price":"0.000285","base_volume":"500","quote_volume":0.1425,"trade_timestamp":1585034117,"type":"buy"},{"tradeID":58391,"price":"0.00028","base_volume":"100","quote_volume":0.027999999999999997,"trade_timestamp":1585033028,"type":"buy"},{"tradeID":58389,"price":"0.00029","base_volume":"250","quote_volume":0.0725,"trade_timestamp":1585032443,"type":"buy"},{"tradeID":58386,"price":"0.000315","base_volume":"952.38095238","quote_volume":0.2999999999997,"trade_timestamp":1585030554,"type":"buy"},{"tradeID":58385,"price":"0.000311","base_volume":"964.63022508","quote_volume":0.29999999999988003,"trade_timestamp":1585029808,"type":"buy"},{"tradeID":58375,"price":"0.000327","base_volume":"917.43119266","quote_volume":0.29999999999981997,"trade_timestamp":1585028902,"type":"buy"},{"tradeID":58374,"price":"0.000325","base_volume":"923.07692308","quote_volume":0.300000000001,"trade_timestamp":1585028071,"type":"buy"},{"tradeID":58371,"price":"0.000323","base_volume":"928.79256966","quote_volume":0.30000000000018,"trade_timestamp":1585027460,"type":"buy"},{"tradeID":58370,"price":"0.000321","base_volume":"934.57943925","quote_volume":0.29999999999925,"trade_timestamp":1585026735,"type":"buy"},{"tradeID":58368,"price":"0.000328","base_volume":"914.63414634","quote_volume":0.29999999999952004,"trade_timestamp":1585025347,"type":"buy"},{"tradeID":58358,"price":"0.000326","base_volume":"920.24539877","quote_volume":0.29999999999902,"trade_timestamp":1585024482,"type":"buy"},{"tradeID":58357,"price":"0.000324","base_volume":"925.92592593","quote_volume":0.30000000000132,"trade_timestamp":1585023641,"type":"buy"},{"tradeID":58355,"price":"0.000322","base_volume":"931.67701863","quote_volume":0.29999999999886,"trade_timestamp":1585023319,"type":"buy"},{"tradeID":58348,"price":"0.00032","base_volume":"937.5","quote_volume":0.30000000000000004,"trade_timestamp":1585022314,"type":"buy"}]' + http_version: + recorded_at: Tue, 24 Mar 2020 17:56:05 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/exchanges/drgx/integration/market_spec.rb b/spec/exchanges/drgx/integration/market_spec.rb new file mode 100755 index 000000000..b3623d438 --- /dev/null +++ b/spec/exchanges/drgx/integration/market_spec.rb @@ -0,0 +1,80 @@ +require 'spec_helper' + +RSpec.describe 'Drgx integration specs' do + let(:client) { Cryptoexchange::Client.new } + let(:market) { 'drgx' } + let(:drg_eth_pair) { Cryptoexchange::Models::MarketPair.new(base: 'DRG', target: 'ETH', market: 'drgx') } + + it 'fetch pairs' do + pairs = client.pairs('drgx') + expect(pairs).not_to be_empty + + pair = pairs.first + expect(pair.base).to_not be nil + expect(pair.target).to_not be nil + expect(pair.market).to eq market + end + + it 'give trade url' do + trade_page_url = client.trade_page_url 'drgx', base: drg_eth_pair.base, target: drg_eth_pair.target + expect(trade_page_url).to eq "https://exchange.drgx.io/en/exchange/DRG-ETH" + end + + it 'fetch pairs' do + pairs = client.pairs('drgx') + expect(pairs).not_to be_empty + + pair = pairs.first + expect(pair.base).to_not be nil + expect(pair.target).to_not be nil + expect(pair.market).to eq 'drgx' + end + + it 'fetch ticker' do + ticker = client.ticker(drg_eth_pair) + + expect(ticker.base).to eq 'DRG' + expect(ticker.target).to eq 'ETH' + expect(ticker.market).to eq market + expect(ticker.last).to be_a Numeric + expect(ticker.bid).to be_a Numeric + expect(ticker.ask).to be_a Numeric + expect(ticker.high).to be_a Numeric + expect(ticker.volume).to be_a Numeric + expect(ticker.timestamp).to be nil + expect(ticker.payload).to_not be nil + end + + it 'fetch order book' do + order_book = client.order_book(drg_eth_pair) + + expect(order_book.base).to eq drg_eth_pair.base + expect(order_book.target).to eq drg_eth_pair.target + expect(order_book.market).to eq market + + expect(order_book.asks).to_not be_empty + expect(order_book.bids).to_not be_empty + expect(order_book.asks.first.price).to_not be_nil + expect(order_book.bids.first.amount).to_not be_nil + expect(order_book.bids.first.timestamp).to be_nil + expect(order_book.asks.count).to be > 5 + expect(order_book.bids.count).to be > 5 + expect(order_book.timestamp).to be_nil + expect(order_book.payload).to_not be nil + end + + it 'fetch trades' do + trades = client.trades(drg_eth_pair) + trade = trades.first + + expect(trade.base).to eq drg_eth_pair.base + expect(trade.target).to eq drg_eth_pair.target + expect(trade.market).to eq market + + expect(trade.amount).to_not be_nil + expect(trade.price).to_not be_nil + expect(2000..Date.today.year).to include(Time.at(trade.timestamp).year) + expect(trade.trade_id).to_not be_nil + expect(trade.type).to eq("buy").or eq("sell") + end +end diff --git a/spec/exchanges/drgx/market_spec.rb b/spec/exchanges/drgx/market_spec.rb new file mode 100755 index 000000000..92edf0506 --- /dev/null +++ b/spec/exchanges/drgx/market_spec.rb @@ -0,0 +1,6 @@ +require 'spec_helper' + +RSpec.describe Cryptoexchange::Exchanges::Drgx::Market do + it { expect(described_class::NAME).to eq 'drgx' } + it { expect(described_class::API_URL).to eq 'https://exchange.drgx.io/cmc/public' } +end