diff --git a/README.md b/README.md index dab6cc27f..259aebb6b 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,7 @@ Or install it yourself as: | Negociecoins | Y | Y [x] | Y | | User-Defined| | negociecoins | | | Neraex | Y | Y | Y | | Y | Y | neraex | | | Newdex | Y | N | N | | Y | Y | newdex | | +| New Capital | Y | Y [x] | Y | | Y | Y | new_capital | | | Nexybit | Y | Y | N | | Y | N | nexybit | | | Ninecoin (Halted) | Y | | | | Y | | ninecoin | | | NLexch | Y | | | | Y | Y | nlexch | | diff --git a/lib/cryptoexchange/exchanges/new_capital/market.rb b/lib/cryptoexchange/exchanges/new_capital/market.rb index 84f6fcf10..16d987a34 100644 --- a/lib/cryptoexchange/exchanges/new_capital/market.rb +++ b/lib/cryptoexchange/exchanges/new_capital/market.rb @@ -4,9 +4,10 @@ class Market < Cryptoexchange::Models::Market NAME = 'new_capital' API_URL = 'https://api.new.capital/v1' - def self.trade_page_url(args={}) - "https://new.capital/exchange/trade/#{args[:target].downcase}_#{args[:base].downcase}" + def self.trade_page_url(args = {}) + "https://new.capital/exchange/trade/#{args[:base].upcase}_#{args[:target].upcase}" end + end end end diff --git a/lib/cryptoexchange/exchanges/new_capital/services/order_book.rb b/lib/cryptoexchange/exchanges/new_capital/services/order_book.rb new file mode 100644 index 000000000..a4cbab25c --- /dev/null +++ b/lib/cryptoexchange/exchanges/new_capital/services/order_book.rb @@ -0,0 +1,40 @@ +module Cryptoexchange::Exchanges + module NewCapital + 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::NewCapital::Market::API_URL}/depth?symbol=#{market_pair.base}_#{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 = NewCapital::Market::NAME + order_book.asks = adapt_orders(output['asks']) + order_book.bids = adapt_orders(output['bids']) + order_book.timestamp = Time.now.to_i + 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], timestamp: nil) + end + end + end + end + end +end diff --git a/lib/cryptoexchange/exchanges/new_capital/services/trades.rb b/lib/cryptoexchange/exchanges/new_capital/services/trades.rb new file mode 100644 index 000000000..127929506 --- /dev/null +++ b/lib/cryptoexchange/exchanges/new_capital/services/trades.rb @@ -0,0 +1,34 @@ +module Cryptoexchange::Exchanges + module NewCapital + 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.upcase + target = market_pair.target.upcase + "#{Cryptoexchange::Exchanges::NewCapital::Market::API_URL}/trades?symbol=#{base}_#{target}" + end + + def adapt(output, market_pair) + output.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 = NewCapital::Market::NAME + tr.price = trade['price'] + tr.amount = trade['qty'] + tr.timestamp = trade['time'] + tr.payload = trade + tr + end + end + end + end + end +end diff --git a/spec/cassettes/vcr_cassettes/NewCapital/integration_specs_fetch_order_book.yml b/spec/cassettes/vcr_cassettes/NewCapital/integration_specs_fetch_order_book.yml new file mode 100644 index 000000000..2d38dd347 --- /dev/null +++ b/spec/cassettes/vcr_cassettes/NewCapital/integration_specs_fetch_order_book.yml @@ -0,0 +1,45 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.new.capital/v1/depth?symbol=BTC_TWINS + body: + encoding: UTF-8 + string: '' + headers: + Connection: + - close + Host: + - api.new.capital + User-Agent: + - http.rb/5.0.0.pre + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 03 Jul 2019 13:04:10 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - close + Set-Cookie: + - __cfduid=d769d0dc272c7fffe92611cc60bb24c051562159050; expires=Thu, 02-Jul-20 + 13:04:10 GMT; path=/; domain=.new.capital; HttpOnly; Secure + X-Frame-Options: + - SAMEORIGIN + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 4f091050df5b639b-FRA + body: + encoding: UTF-8 + string: '{"bids":[["18000000","0.00815296"],["17590000","0.03513694"],["17583000","0.00176454"],["17580000","0.00853242"],["17575000","0.01263157"],["17550000","0.00928774"],["17500321","0.01080300"],["17500000","0.00357908"],["17111258","0.01164888"],["17000000","0.00288234"],["16500000","0.03832262"],["16000300","0.01110150"],["16000000","0.00750000"],["15000999","0.01105925"],["15000000","0.05772036"],["14000000","0.00130784"],["13600000","0.00036764"],["13000000","0.00187792"],["12000002","0.00271255"],["11000002","0.00090909"],["11000000","0.00450954"],["10500000","0.00551122"],["10250000","0.01544344"],["10000000","0.11100000"],["9500000","0.02948958"],["9000000","0.04210808"],["8500000","0.03046439"],["8200000","0.03048780"],["8000000","0.03391667"],["7800000","0.03205128"],["7000000","0.01745238"],["6500000","0.02419355"],["6400000","0.02419355"],["6300000","0.02419355"],["6200000","0.02419355"],["6000000","0.00016667"],["5500000","0.04237537"],["5400000","0.02777778"],["5300000","0.05607967"],["5200000","0.02830189"],["5100000","0.04040636"],["5000000","0.23278520"],["4900000","0.03061224"],["4800000","0.03061224"],["4700000","0.03061224"],["4500000","0.02222222"],["4000000","0.03457108"],["3000000","0.00333333"],["2400000","0.00125000"],["2000299","0.08607164"],["2000000","0.01500000"],["1000000","0.03742645"],["500000","0.02742645"],["400000","0.03250000"],["100000","0.01000000"],["10000","0.10000000"],["100","10.00000000"],["1","1000.00000000"]],"asks":[["22500000","0.00566674"],["23000000","0.01008064"],["24000000","0.00382641"],["25000000","0.07539454"],["26500000","0.00202202"],["27000000","0.03683608"],["30000000","0.05531506"],["32000000","0.03150295"],["32399999","0.02160000"],["32400000","0.01650613"],["32589500","0.02580612"],["33000000","0.01142174"],["33203813","0.00618567"],["34600000","0.02016129"],["34999999","0.05266906"],["35000000","0.00158889"],["39889996","0.00793855"],["39889997","0.01058473"],["39889998","0.02116946"],["39889999","0.02116946"],["39999999","0.00500000"],["41000000","0.01219512"],["42000000","0.01219512"],["43000000","0.01219512"],["44000000","0.01219512"],["45000000","0.01219512"],["46000000","0.01219512"],["47000000","0.01219512"],["48000000","0.01219512"],["49000000","0.02016129"],["49000001","0.02016129"],["49000002","0.02016129"],["49900000","0.00242380"],["90000000","0.00010000"]]}' + http_version: + recorded_at: Wed, 03 Jul 2019 13:04:10 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/cassettes/vcr_cassettes/NewCapital/integration_specs_fetch_trade.yml b/spec/cassettes/vcr_cassettes/NewCapital/integration_specs_fetch_trade.yml new file mode 100644 index 000000000..3cb69e0ac --- /dev/null +++ b/spec/cassettes/vcr_cassettes/NewCapital/integration_specs_fetch_trade.yml @@ -0,0 +1,45 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.new.capital/v1/trades?symbol=BTC_TWINS + body: + encoding: UTF-8 + string: '' + headers: + Connection: + - close + Host: + - api.new.capital + User-Agent: + - http.rb/5.0.0.pre + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 03 Jul 2019 13:04:10 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - close + Set-Cookie: + - __cfduid=df0b4f36817cb0eb647540fca886976b51562159050; expires=Thu, 02-Jul-20 + 13:04:10 GMT; path=/; domain=.new.capital; HttpOnly; Secure + X-Frame-Options: + - SAMEORIGIN + Expect-Ct: + - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" + Server: + - cloudflare + Cf-Ray: + - 4f091052c8da97ea-FRA + body: + encoding: UTF-8 + string: '[{"id":278,"price":"22500000","qty":"0.00441390","quoteQty":"99312.75000000","time":1562158908},{"id":277,"price":"22000000","qty":"0.00137740","quoteQty":"30302.79999998","time":1562158908},{"id":276,"price":"17590000","qty":"0.00005685","quoteQty":"999.99149998","time":1562138583},{"id":275,"price":"22000000","qty":"0.00504033","quoteQty":"110887.25999998","time":1562136461},{"id":274,"price":"21500000","qty":"0.00109341","quoteQty":"23508.31499999","time":1562136461},{"id":273,"price":"21500000","qty":"0.00898724","quoteQty":"193225.65999998","time":1562136445},{"id":272,"price":"21000000","qty":"0.00323080","quoteQty":"67846.80000000","time":1562136445},{"id":271,"price":"20000000","qty":"0.00601693","quoteQty":"120338.60000000","time":1562136445},{"id":270,"price":"19500000","qty":"0.00565838","quoteQty":"110338.41000000","time":1562136445},{"id":269,"price":"19000000","qty":"0.00528097","quoteQty":"100338.42999999","time":1562136445},{"id":268,"price":"18500000","qty":"0.00773094","quoteQty":"143022.39000000","time":1562136445},{"id":267,"price":"18500000","qty":"0.00448234","quoteQty":"82923.28999998","time":1562136445},{"id":266,"price":"18100000","qty":"0.00075360","quoteQty":"13640.15999999","time":1562136444},{"id":265,"price":"18100000","qty":"0.00114842","quoteQty":"20786.40199999","time":1562136444},{"id":264,"price":"18000000","qty":"0.00018864","quoteQty":"3395.51999999","time":1562136444},{"id":263,"price":"17882000","qty":"0.00513058","quoteQty":"91745.03155999","time":1562128216},{"id":262,"price":"17882001","qty":"0.00719572","quoteQty":"128673.87223572","time":1562115180},{"id":261,"price":"17882000","qty":"0.00216933","quoteQty":"38791.95906000","time":1562114707},{"id":260,"price":"18000000","qty":"0.00094176","quoteQty":"16951.67999998","time":1562113884},{"id":259,"price":"18000000","qty":"0.00238176","quoteQty":"42871.68000000","time":1562113884},{"id":258,"price":"17700000","qty":"0.00178631","quoteQty":"31617.68699999","time":1562113884},{"id":257,"price":"17600000","qty":"0.00016794","quoteQty":"2955.74400000","time":1562113884},{"id":256,"price":"17600000","qty":"0.00756299","quoteQty":"133108.62399998","time":1562113413},{"id":255,"price":"17600000","qty":"0.00095973","quoteQty":"16891.24799999","time":1562113413},{"id":254,"price":"17500000","qty":"0.00113040","quoteQty":"19782.00000000","time":1562113198},{"id":253,"price":"17600000","qty":"0.00003210","quoteQty":"564.96000000","time":1562112838},{"id":252,"price":"17600000","qty":"0.00006818","quoteQty":"1199.96800000","time":1562112789},{"id":251,"price":"17600000","qty":"0.00017045","quoteQty":"2999.92000000","time":1562112737},{"id":250,"price":"17600000","qty":"0.00010928","quoteQty":"1923.32799999","time":1562112649},{"id":249,"price":"17500000","qty":"0.00100480","quoteQty":"17584.00000000","time":1562112357},{"id":248,"price":"18000000","qty":"0.00555555","quoteQty":"99999.89999999","time":1562112216},{"id":247,"price":"18000000","qty":"0.00055555","quoteQty":"9999.89999999","time":1562112216},{"id":246,"price":"18100000","qty":"0.00343298","quoteQty":"62136.93799998","time":1562112193},{"id":245,"price":"18100000","qty":"0.00675403","quoteQty":"122247.94299999","time":1562112145},{"id":244,"price":"18200000","qty":"0.00675403","quoteQty":"122923.34600000","time":1562112116},{"id":243,"price":"18300000","qty":"0.00341854","quoteQty":"62559.28199999","time":1562112091},{"id":242,"price":"18300000","qty":"0.00548298","quoteQty":"100338.53399999","time":1562112066},{"id":241,"price":"18300000","qty":"0.00005464","quoteQty":"999.91199999","time":1562110439},{"id":240,"price":"21000000","qty":"0.00180952","quoteQty":"37999.91999999","time":1562109811},{"id":239,"price":"18300000","qty":"0.00895616","quoteQty":"163897.72800000","time":1562108886},{"id":238,"price":"25000000","qty":"0.00002000","quoteQty":"500.00000000","time":1562108810},{"id":237,"price":"18400000","qty":"0.01187665","quoteQty":"218530.35999999","time":1562107359},{"id":236,"price":"18500000","qty":"0.00399549","quoteQty":"73916.56500000","time":1562107351},{"id":235,"price":"19000000","qty":"0.00052631","quoteQty":"9999.88999999","time":1562107247},{"id":234,"price":"19000001","qty":"0.01815794","quoteQty":"345000.87815792","time":1562107204},{"id":233,"price":"19608043","qty":"0.00560000","quoteQty":"109805.04079999","time":1562107187},{"id":232,"price":"19608043","qty":"0.00510000","quoteQty":"100001.01929999","time":1562107187},{"id":231,"price":"20000000","qty":"0.00050000","quoteQty":"10000.00000000","time":1562107187},{"id":230,"price":"21000000","qty":"0.02899238","quoteQty":"608839.97999998","time":1562107122},{"id":229,"price":"21000000","qty":"0.00022998","quoteQty":"4829.57999999","time":1562107122},{"id":228,"price":"21000100","qty":"0.00057980","quoteQty":"12175.85798000","time":1562107122},{"id":227,"price":"25252525","qty":"0.00028209","quoteQty":"7123.48477723","time":1562106131},{"id":226,"price":"26774466","qty":"0.00027798","quoteQty":"7442.76605867","time":1562105218},{"id":225,"price":"27777777","qty":"0.00020095","quoteQty":"5581.94428814","time":1562104628},{"id":224,"price":"26252527","qty":"0.00490135","quoteQty":"128672.82321144","time":1562099705},{"id":223,"price":"26512000","qty":"0.00029521","quoteQty":"7826.60751999","time":1562099234},{"id":222,"price":"27000000","qty":"0.00025925","quoteQty":"6999.75000000","time":1562098757},{"id":221,"price":"25252526","qty":"0.00355374","quoteQty":"89740.91174722","time":1562096189},{"id":220,"price":"25252526","qty":"0.00751461","quoteQty":"189762.88440486","time":1562096101},{"id":219,"price":"21000113","qty":"0.00709400","quoteQty":"148974.80162198","time":1562093140},{"id":218,"price":"24000113","qty":"0.00907887","quoteQty":"217893.90591229","time":1562092937},{"id":217,"price":"24000113","qty":"0.00537330","quoteQty":"128959.80718288","time":1562092725},{"id":216,"price":"24000111","qty":"0.00479164","quoteQty":"114999.89187202","time":1562092620},{"id":215,"price":"21000112","qty":"0.00476187","quoteQty":"99999.80332942","time":1562092526},{"id":214,"price":"29000000","qty":"0.00013241","quoteQty":"3839.88999998","time":1562090370},{"id":213,"price":"29000000","qty":"0.00001140","quoteQty":"330.60000000","time":1562090340},{"id":212,"price":"29000000","qty":"0.00013241","quoteQty":"3839.88999998","time":1562090339},{"id":211,"price":"21000000","qty":"0.00009930","quoteQty":"2085.30000000","time":1562087877},{"id":210,"price":"21000000","qty":"0.00009930","quoteQty":"2085.30000000","time":1562087863},{"id":209,"price":"21000000","qty":"0.00004761","quoteQty":"999.80999999","time":1562087147},{"id":208,"price":"29980000","qty":"0.05536267","quoteQty":"1659772.84660000","time":1562086982},{"id":207,"price":"21000003","qty":"0.04761904","quoteQty":"999999.98285710","time":1562086634},{"id":206,"price":"21000021","qty":"0.00003620","quoteQty":"760.20076018","time":1562086281},{"id":205,"price":"21000022","qty":"0.03156598","quoteQty":"662886.27445154","time":1562086281},{"id":204,"price":"22000000","qty":"0.00045454","quoteQty":"9999.87999999","time":1562086175},{"id":203,"price":"22000022","qty":"0.00113636","quoteQty":"24999.94499992","time":1562086175},{"id":202,"price":"23000000","qty":"0.00400000","quoteQty":"92000.00000000","time":1562086175},{"id":201,"price":"23000023","qty":"0.02212693","quoteQty":"508919.89891937","time":1562086119},{"id":200,"price":"23000023","qty":"0.00117245","quoteQty":"26966.37696634","time":1562086119},{"id":199,"price":"29990000","qty":"0.00117245","quoteQty":"35161.77550000","time":1562085986},{"id":198,"price":"29990000","qty":"0.00117245","quoteQty":"35161.77550000","time":1562085966},{"id":197,"price":"29999999","qty":"0.00179776","quoteQty":"53932.79820224","time":1562073590},{"id":196,"price":"29999800","qty":"0.00020224","quoteQty":"6067.15955200","time":1562073590},{"id":195,"price":"29999800","qty":"0.00121768","quoteQty":"36530.15646399","time":1562064468},{"id":194,"price":"20100010","qty":"0.00181741","quoteQty":"36529.95917408","time":1562042409},{"id":193,"price":"32590000","qty":"0.00001904","quoteQty":"620.51359999","time":1562020282},{"id":192,"price":"31000000","qty":"0.00115807","quoteQty":"35900.16999999","time":1562020282},{"id":191,"price":"31000000","qty":"0.00206774","quoteQty":"64099.94000000","time":1561992291},{"id":190,"price":"33000000","qty":"0.00069983","quoteQty":"23094.38999998","time":1561988098},{"id":189,"price":"33000000","qty":"0.00117870","quoteQty":"38897.09999999","time":1561986813},{"id":188,"price":"33333330","qty":"0.00193566","quoteQty":"64521.99354779","time":1561985153},{"id":187,"price":"33333300","qty":"0.00067385","quoteQty":"22461.64420500","time":1561985153},{"id":186,"price":"33333300","qty":"0.00357616","quoteQty":"119205.21412800","time":1561985119},{"id":185,"price":"18000000","qty":"0.00005556","quoteQty":"1000.08000000","time":1561963363},{"id":184,"price":"18000000","qty":"0.00005556","quoteQty":"1000.08000000","time":1561963355},{"id":183,"price":"18000000","qty":"0.00138889","quoteQty":"25000.02000000","time":1561961515},{"id":182,"price":"18000000","qty":"0.00002849","quoteQty":"512.82000000","time":1561950927},{"id":181,"price":"33780000","qty":"0.00208358","quoteQty":"70383.33239999","time":1561949681},{"id":180,"price":"33770000","qty":"0.00564773","quoteQty":"190723.84210000","time":1561949662},{"id":179,"price":"25000000","qty":"0.00000011","quoteQty":"2.75000000","time":1561949424},{"id":178,"price":"25000000","qty":"0.00014561","quoteQty":"3640.24999999","time":1561941404},{"id":177,"price":"23000000","qty":"0.00000011","quoteQty":"2.52999999","time":1561941404},{"id":176,"price":"23000000","qty":"0.00013319","quoteQty":"3063.36999998","time":1561941391},{"id":175,"price":"22000010","qty":"0.00000007","quoteQty":"1.54000070","time":1561941391},{"id":174,"price":"22000010","qty":"0.00042207","quoteQty":"9285.54422069","time":1561941371},{"id":173,"price":"21000002","qty":"0.00000007","quoteQty":"1.47000014","time":1561941371},{"id":172,"price":"21000002","qty":"0.00024823","quoteQty":"5212.83049645","time":1561941357},{"id":171,"price":"21000000","qty":"0.00000006","quoteQty":"1.26000000","time":1561941357},{"id":170,"price":"21000000","qty":"0.00038259","quoteQty":"8034.38999999","time":1561941328},{"id":169,"price":"20002255","qty":"0.00000003","quoteQty":"0.60006765","time":1561941328},{"id":168,"price":"20002255","qty":"0.00045835","quoteQty":"9168.03357924","time":1561941307},{"id":167,"price":"20002200","qty":"0.00039931","quoteQty":"7987.07848199","time":1561941294},{"id":166,"price":"20002100","qty":"0.00039736","quoteQty":"7948.03445599","time":1561941282},{"id":165,"price":"17000000","qty":"0.00006118","quoteQty":"1040.05999999","time":1561941265},{"id":164,"price":"15000999","qty":"0.00033324","quoteQty":"4998.93290676","time":1561936608},{"id":163,"price":"15001000","qty":"0.00000007","quoteQty":"1.05006998","time":1561936608},{"id":162,"price":"15001000","qty":"0.03458789","quoteQty":"518852.93789000","time":1561936589},{"id":161,"price":"15000999","qty":"0.00033331","quoteQty":"4999.98297669","time":1561936139},{"id":160,"price":"17000000","qty":"0.00288000","quoteQty":"48960.00000000","time":1561935969},{"id":159,"price":"20002100","qty":"0.00860164","quoteQty":"172050.86344399","time":1561935896},{"id":158,"price":"20002200","qty":"0.00859969","quoteQty":"172012.71931799","time":1561935881},{"id":157,"price":"20002255","qty":"0.00604089","quoteQty":"120831.42220693","time":1561935848},{"id":156,"price":"20002255","qty":"0.00256390","quoteQty":"51283.78159449","time":1561935184},{"id":155,"price":"21000000","qty":"0.00011395","quoteQty":"2392.94999999","time":1561935163},{"id":154,"price":"21000000","qty":"0.00426530","quoteQty":"89571.29999999","time":1561935163},{"id":153,"price":"21000002","qty":"0.00213265","quoteQty":"44785.65426529","time":1561935148},{"id":152,"price":"22000010","qty":"0.01003240","quoteQty":"220712.90032399","time":1561935123},{"id":151,"price":"22000010","qty":"0.00639523","quoteQty":"140695.12395229","time":1561934874},{"id":150,"price":"23000000","qty":"0.00204061","quoteQty":"46934.02999999","time":1561934860},{"id":149,"price":"23000000","qty":"0.00056799","quoteQty":"13063.76999998","time":1561934845},{"id":148,"price":"23500000","qty":"0.00012766","quoteQty":"3000.01000000","time":1561934845},{"id":147,"price":"24000000","qty":"0.00800000","quoteQty":"192000.00000000","time":1561934845},{"id":146,"price":"25000000","qty":"0.00012000","quoteQty":"3000.00000000","time":1561934706},{"id":145,"price":"26000000","qty":"0.00011538","quoteQty":"2999.88000000","time":1561934706},{"id":144,"price":"26500000","qty":"0.00001887","quoteQty":"500.05500000","time":1561934706},{"id":143,"price":"27000000","qty":"0.00000003","quoteQty":"0.80999999","time":1561934706},{"id":142,"price":"27000000","qty":"0.00011108","quoteQty":"2999.15999998","time":1561934684},{"id":141,"price":"27500000","qty":"0.00000003","quoteQty":"0.82499999","time":1561934684},{"id":140,"price":"27500000","qty":"0.00001815","quoteQty":"499.12500000","time":1561934666},{"id":139,"price":"28000000","qty":"0.00010714","quoteQty":"2999.91999999","time":1561932761},{"id":138,"price":"28500000","qty":"0.00001754","quoteQty":"499.88999999","time":1561932761},{"id":137,"price":"29000000","qty":"0.00010345","quoteQty":"3000.04999998","time":1561932761},{"id":136,"price":"30000000","qty":"0.00010000","quoteQty":"3000.00000000","time":1561932760},{"id":135,"price":"31000000","qty":"0.00003226","quoteQty":"1000.05999999","time":1561932760},{"id":134,"price":"32000000","qty":"0.00003125","quoteQty":"1000.00000000","time":1561932760},{"id":133,"price":"33000000","qty":"0.00003125","quoteQty":"1031.25000000","time":1561932760},{"id":132,"price":"33500000","qty":"0.00002985","quoteQty":"999.97500000","time":1561932760},{"id":131,"price":"34300000","qty":"0.00001367","quoteQty":"468.88099999","time":1561932760},{"id":130,"price":"24000000","qty":"0.00500000","quoteQty":"120000.00000000","time":1561922345},{"id":129,"price":"23000000","qty":"0.00013044","quoteQty":"3000.11999998","time":1561920236},{"id":128,"price":"23000000","qty":"0.00211765","quoteQty":"48705.94999998","time":1561920236},{"id":127,"price":"27000000","qty":"0.00300000","quoteQty":"81000.00000000","time":1561919960},{"id":126,"price":"30000000","qty":"0.00600000","quoteQty":"180000.00000000","time":1561917936},{"id":125,"price":"34800000","qty":"0.00174112","quoteQty":"60590.97600000","time":1561917203},{"id":124,"price":"34800000","qty":"0.00295263","quoteQty":"102751.52399998","time":1561917108},{"id":123,"price":"34800000","qty":"0.00001000","quoteQty":"348.00000000","time":1561900191},{"id":122,"price":"21121700","qty":"0.00810298","quoteQty":"171148.71266600","time":1561893768},{"id":121,"price":"21121700","qty":"0.00889702","quoteQty":"187920.18733399","time":1561893736},{"id":120,"price":"34800000","qty":"0.00001149","quoteQty":"399.85199999","time":1561893626},{"id":119,"price":"34800000","qty":"0.00003959","quoteQty":"1377.73199999","time":1561893582},{"id":118,"price":"34800000","qty":"0.00013657","quoteQty":"4752.63600000","time":1561893539},{"id":117,"price":"21121600","qty":"0.00236724","quoteQty":"49999.89638399","time":1561893490},{"id":116,"price":"34800000","qty":"0.00071787","quoteQty":"24981.87600000","time":1561892735},{"id":115,"price":"34800000","qty":"0.00047122","quoteQty":"16398.45599999","time":1561892551},{"id":114,"price":"34800000","qty":"0.00075629","quoteQty":"26318.89199998","time":1561892533},{"id":113,"price":"34800000","qty":"0.00103459","quoteQty":"36003.73200000","time":1561892210},{"id":112,"price":"34800000","qty":"0.00244505","quoteQty":"85087.73999998","time":1561892210},{"id":111,"price":"34800000","qty":"0.00001000","quoteQty":"348.00000000","time":1561853846},{"id":110,"price":"34800000","qty":"0.00001000","quoteQty":"348.00000000","time":1561843043},{"id":109,"price":"21005021","qty":"0.00003089","quoteQty":"648.84509867","time":1561837056},{"id":108,"price":"34800000","qty":"0.00003089","quoteQty":"1074.97199999","time":1561836982},{"id":107,"price":"21005021","qty":"0.00004761","quoteQty":"1000.04904981","time":1561828083},{"id":106,"price":"34800000","qty":"0.00000406","quoteQty":"141.28800000","time":1561813986},{"id":105,"price":"22000000","qty":"0.00000594","quoteQty":"130.67999998","time":1561813986},{"id":104,"price":"21000021","qty":"0.00066900","quoteQty":"14049.01404899","time":1561812209},{"id":103,"price":"22000000","qty":"0.00013636","quoteQty":"2999.92000000","time":1561812189},{"id":102,"price":"23000000","qty":"0.00013043","quoteQty":"2999.88999999","time":1561812189},{"id":101,"price":"24000000","qty":"0.00013042","quoteQty":"3130.07999999","time":1561812153},{"id":100,"price":"25000000","qty":"0.00013043","quoteQty":"3260.75000000","time":1561801617},{"id":99,"price":"26000000","qty":"0.00013043","quoteQty":"3391.17999999","time":1561801617},{"id":98,"price":"27000000","qty":"0.00013043","quoteQty":"3521.61000000","time":1561801617},{"id":97,"price":"28000000","qty":"0.00013043","quoteQty":"3652.03999999","time":1561800581},{"id":96,"price":"29000000","qty":"0.00013043","quoteQty":"3782.46999999","time":1561800581},{"id":95,"price":"30000000","qty":"0.00013043","quoteQty":"3912.90000000","time":1561800461},{"id":94,"price":"31000000","qty":"0.00008716","quoteQty":"2701.96000000","time":1561800410},{"id":93,"price":"20005500","qty":"0.00004999","quoteQty":"1000.07494499","time":1561792729},{"id":92,"price":"20005500","qty":"0.00009108","quoteQty":"1822.10094000","time":1561792694},{"id":91,"price":"21005500","qty":"0.00182264","quoteQty":"38285.46452000","time":1561792694},{"id":90,"price":"20000000","qty":"0.00250000","quoteQty":"50000.00000000","time":1561750175},{"id":89,"price":"35000000","qty":"0.00738375","quoteQty":"258431.25000000","time":1561747401},{"id":88,"price":"35000000","qty":"0.00255274","quoteQty":"89345.89999999","time":1561747401},{"id":87,"price":"32400000","qty":"0.01006351","quoteQty":"326057.72399998","time":1561747401},{"id":86,"price":"18000000","qty":"0.02796126","quoteQty":"503302.67999999","time":1561716767},{"id":85,"price":"20000001","qty":"0.01006351","quoteQty":"201270.21006350","time":1561716767},{"id":84,"price":"35000000","qty":"0.00030440","quoteQty":"10654.00000000","time":1561715285},{"id":83,"price":"40000000","qty":"0.04471852","quoteQty":"1788740.79999999","time":1561711113},{"id":82,"price":"32000000","qty":"0.00161290","quoteQty":"51612.80000000","time":1561711113},{"id":81,"price":"31000000","qty":"0.00161290","quoteQty":"49999.90000000","time":1561711113},{"id":80,"price":"30000000","qty":"0.00975305","quoteQty":"292591.50000000","time":1561711113},{"id":79,"price":"30000000","qty":"0.03333333","quoteQty":"999999.90000000","time":1561711002},{"id":78,"price":"30000000","qty":"0.01603333","quoteQty":"480999.89999999","time":1561709819},{"id":77,"price":"30000000","qty":"0.00788029","quoteQty":"236408.69999998","time":1561709280},{"id":76,"price":"29000000","qty":"0.00344828","quoteQty":"100000.11999999","time":1561709255},{"id":75,"price":"28000000","qty":"0.00357143","quoteQty":"100000.03999998","time":1561709231},{"id":74,"price":"28000000","qty":"0.00183690","quoteQty":"51433.19999999","time":1561709231},{"id":73,"price":"27999000","qty":"0.00509450","quoteQty":"142640.90549999","time":1561709177},{"id":72,"price":"27999000","qty":"0.00173686","quoteQty":"48630.34313999","time":1561708239},{"id":71,"price":"18000000","qty":"0.00002362","quoteQty":"425.16000000","time":1561702662},{"id":70,"price":"17000001","qty":"0.00029412","quoteQty":"5000.04029411","time":1561698189},{"id":69,"price":"17000000","qty":"0.00005556","quoteQty":"944.51999999","time":1561656981},{"id":68,"price":"18000000","qty":"0.00003194","quoteQty":"574.91999998","time":1561656974},{"id":67,"price":"27999000","qty":"0.00035712","quoteQty":"9999.00288000","time":1561655997},{"id":66,"price":"18000000","qty":"0.00027778","quoteQty":"5000.03999999","time":1561654623},{"id":65,"price":"28000000","qty":"0.00316310","quoteQty":"88566.80000000","time":1561651979},{"id":64,"price":"27000000","qty":"0.00384615","quoteQty":"103846.05000000","time":1561651970},{"id":63,"price":"26000000","qty":"0.00384615","quoteQty":"99999.89999998","time":1561651962},{"id":62,"price":"25000000","qty":"0.00001037","quoteQty":"259.24999998","time":1561651962},{"id":61,"price":"25000000","qty":"0.00398963","quoteQty":"99740.75000000","time":1561651956},{"id":60,"price":"24000000","qty":"0.00001037","quoteQty":"248.87999998","time":1561651956},{"id":59,"price":"24000000","qty":"0.00112500","quoteQty":"26999.99999998","time":1561651913},{"id":58,"price":"24000000","qty":"0.00303130","quoteQty":"72751.19999999","time":1561651895},{"id":57,"price":"23000000","qty":"0.00434783","quoteQty":"100000.08999998","time":1561651895},{"id":56,"price":"22000000","qty":"0.00454545","quoteQty":"99999.89999999","time":1561651895},{"id":55,"price":"21000000","qty":"0.00474209","quoteQty":"99583.88999999","time":1561651895},{"id":54,"price":"21000000","qty":"0.00001981","quoteQty":"416.00999998","time":1561645923},{"id":53,"price":"20000000","qty":"0.00013748","quoteQty":"2749.59999999","time":1561645867},{"id":52,"price":"20000000","qty":"0.00017143","quoteQty":"3428.59999999","time":1561645766},{"id":51,"price":"20000000","qty":"0.00469109","quoteQty":"93821.79999999","time":1561633362},{"id":50,"price":"19000000","qty":"0.00526316","quoteQty":"100000.03999999","time":1561633362},{"id":49,"price":"18200000","qty":"0.00034575","quoteQty":"6292.64999998","time":1561633362},{"id":48,"price":"16000000","qty":"0.00100000","quoteQty":"16000.00000000","time":1561626912},{"id":47,"price":"18200000","qty":"0.00126715","quoteQty":"23062.13000000","time":1561625397},{"id":46,"price":"18100000","qty":"0.00161290","quoteQty":"29193.49000000","time":1561625354},{"id":45,"price":"18000000","qty":"0.00183223","quoteQty":"32980.13999999","time":1561622654},{"id":44,"price":"15000010","qty":"0.00600000","quoteQty":"90000.05999999","time":1561619261},{"id":43,"price":"18000000","qty":"0.00076111","quoteQty":"13699.97999999","time":1561618033},{"id":42,"price":"18000000","qty":"0.00083333","quoteQty":"14999.93999998","time":1561613869},{"id":41,"price":"18000000","qty":"0.00001778","quoteQty":"320.03999999","time":1561612322},{"id":40,"price":"18000000","qty":"0.00211111","quoteQty":"37999.97999998","time":1561612293},{"id":39,"price":"17999000","qty":"0.00154259","quoteQty":"27765.07740999","time":1561612249},{"id":38,"price":"17999000","qty":"0.00007031","quoteQty":"1265.50969000","time":1561611777},{"id":37,"price":"17800000","qty":"0.00042969","quoteQty":"7648.48199999","time":1561611777},{"id":36,"price":"20000000","qty":"0.00109358","quoteQty":"21871.59999999","time":1561593833},{"id":35,"price":"19500000","qty":"0.00133066","quoteQty":"25947.86999999","time":1561593833},{"id":34,"price":"19500000","qty":"0.00050000","quoteQty":"9750.00000000","time":1561592720},{"id":33,"price":"19500000","qty":"0.00047708","quoteQty":"9303.05999999","time":1561579078},{"id":32,"price":"19500000","qty":"0.00002564","quoteQty":"499.98000000","time":1561579078},{"id":31,"price":"19400000","qty":"0.00001010","quoteQty":"195.93999998","time":1561579078},{"id":30,"price":"19500000","qty":"0.00023077","quoteQty":"4500.01499999","time":1561550670},{"id":29,"price":"11000000","qty":"0.00043599","quoteQty":"4795.88999999","time":1561527087},{"id":28,"price":"20000000","qty":"0.00001000","quoteQty":"200.00000000","time":1561458638},{"id":27,"price":"20000000","qty":"0.00001000","quoteQty":"200.00000000","time":1561458519},{"id":26,"price":"20000000","qty":"0.00060000","quoteQty":"11999.99999998","time":1561406706},{"id":25,"price":"20000000","qty":"0.00050000","quoteQty":"10000.00000000","time":1561386516},{"id":24,"price":"20000000","qty":"0.00005000","quoteQty":"1000.00000000","time":1561355156},{"id":23,"price":"10000000","qty":"0.00118848","quoteQty":"11884.79999999","time":1561325391},{"id":22,"price":"13300000","qty":"0.00026308","quoteQty":"3498.96399999","time":1561325391},{"id":21,"price":"13500000","qty":"0.00014815","quoteQty":"2000.02499998","time":1561239780},{"id":20,"price":"16000000","qty":"0.00120000","quoteQty":"19200.00000000","time":1561239746},{"id":19,"price":"20000000","qty":"0.00000404","quoteQty":"80.79999999","time":1561222040},{"id":18,"price":"20000000","qty":"0.00016263","quoteQty":"3252.59999999","time":1561222040},{"id":17,"price":"20000000","qty":"0.00016667","quoteQty":"3333.40000000","time":1561221909},{"id":16,"price":"20000000","qty":"0.00067070","quoteQty":"13414.00000000","time":1561221723},{"id":15,"price":"15000000","qty":"0.00068990","quoteQty":"10348.50000000","time":1561106097},{"id":14,"price":"15000000","qty":"0.00030000","quoteQty":"4500.00000000","time":1561105406},{"id":13,"price":"13000000","qty":"0.00155002","quoteQty":"20150.25999999","time":1561071973},{"id":12,"price":"7000000","qty":"0.00068451","quoteQty":"4791.56999998","time":1560996026},{"id":11,"price":"7000000","qty":"0.00010000","quoteQty":"700.00000000","time":1560980360},{"id":10,"price":"7000000","qty":"0.00173929","quoteQty":"12175.03000000","time":1560979325},{"id":9,"price":"12000000","qty":"0.00033334","quoteQty":"4000.07999999","time":1560979325},{"id":8,"price":"12000000","qty":"0.00008333","quoteQty":"999.96000000","time":1560978930},{"id":7,"price":"15000000","qty":"0.00001010","quoteQty":"151.50000000","time":1560978878},{"id":6,"price":"10000000","qty":"0.00001010","quoteQty":"101.00000000","time":1560978674},{"id":5,"price":"10000000","qty":"0.00001010","quoteQty":"101.00000000","time":1560978674},{"id":4,"price":"10000000","qty":"0.00100000","quoteQty":"10000.00000000","time":1560975007},{"id":3,"price":"10000000","qty":"0.00055002","quoteQty":"5500.19999998","time":1560974871},{"id":2,"price":"10000000","qty":"0.00100000","quoteQty":"10000.00000000","time":1560973372},{"id":1,"price":"10000000","qty":"0.00155002","quoteQty":"15500.20000000","time":1560967997}]' + http_version: + recorded_at: Wed, 03 Jul 2019 13:04:10 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/exchanges/new_capital/integration/market_spec.rb b/spec/exchanges/new_capital/integration/market_spec.rb index cbdd46e1b..531096609 100644 --- a/spec/exchanges/new_capital/integration/market_spec.rb +++ b/spec/exchanges/new_capital/integration/market_spec.rb @@ -2,7 +2,7 @@ RSpec.describe 'NewCapital integration specs' do let(:client) {Cryptoexchange::Client.new} - let(:twins_btc_pair) {Cryptoexchange::Models::MarketPair.new(base: 'BTC', target: 'TWINS', market: 'new_capital')} + let(:btc_twins_pair) {Cryptoexchange::Models::MarketPair.new(base: 'BTC', target: 'TWINS', market: 'new_capital')} it 'fetch pairs' do pairs = client.pairs('new_capital') @@ -14,7 +14,7 @@ end it 'fetch ticker' do - ticker = client.ticker(twins_btc_pair) + ticker = client.ticker(btc_twins_pair) expect(ticker.base).to eq 'BTC' expect(ticker.target).to eq 'TWINS' expect(ticker.market).to eq 'new_capital' @@ -28,4 +28,35 @@ expect(ticker.payload).to_not be nil end + it 'fetch order book' do + order_book = client.order_book(btc_twins_pair) + + expect(order_book.base).to eq 'BTC' + expect(order_book.target).to eq 'TWINS' + expect(order_book.market).to eq 'new_capital' + 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 > 0 + expect(order_book.bids.count).to be > 0 + expect(order_book.payload).to_not be nil + end + + it 'fetch trade' do + trades = client.trades(btc_twins_pair) + trade = trades.sample + + expect(trades).to_not be_empty + expect(trade.base).to eq 'BTC' + expect(trade.target).to eq 'TWINS' + expect(trade.market).to eq 'new_capital' + expect(trade.trade_id).to_not be_nil + expect(trade.price).to_not be_nil + expect(trade.amount).to_not be_nil + expect(trade.timestamp).to be_a Numeric + expect(trade.payload).to_not be nil + end + end \ No newline at end of file