UNPKG

@jmparsons/ccxt

Version:

A JavaScript / Python / PHP cryptocurrency trading library with support for 100+ exchanges

1 lines 1.45 MB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ccxt",[],t):"object"==typeof exports?exports.ccxt=t():e.ccxt=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=37)}([function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=!0,d=!1,h=void 0;try{for(var l,p=Object.entries(t)[Symbol.iterator]();!(c=(l=p.next()).done);c=!0)!function(){var t=u(l.value,2),c=t[0],d=t[1],h=Object.assign(r,n({},c,function(e){function t(e){i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.constructor=h,r.__proto__=h.prototype,r.message=e,r}return a(t,e),t}(e)))[c];s(h,d,r)}()}catch(e){d=!0,h=e}finally{try{!c&&p.return&&p.return()}finally{if(d)throw h}}return r}var u=function(){function e(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.exports=s(Error,{BaseError:{ExchangeError:{NotSupported:{},AuthenticationError:{PermissionDenied:{}},InsufficientFunds:{},InvalidAddress:{},InvalidOrder:{OrderNotFound:{},OrderNotCached:{},CancelPending:{}}},NetworkError:{DDoSProtection:{},RequestTimeout:{},ExchangeNotAvailable:{},InvalidNonce:{}}}})},function(e,t,r){"use strict";(function(t){function n(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,r){function n(i,o){try{var a=t[i](o),s=a.value}catch(e){return void r(e)}if(!a.done)return Promise.resolve(s).then(function(e){n("next",e)},function(e){n("throw",e)});e(s)}return n("next")})}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(22),c=r(69),d=u.isNode,h=(u.keys,u.values,u.deepExtend),l=u.extend,p=u.flatten,f=u.unique,v=u.indexBy,m=u.sortBy,y=u.groupBy,g=u.aggregate,b=(u.uuid,u.unCamelCase),k=(u.precisionFromString,u.throttle),w=u.capitalize,x=u.now,O=(u.sleep,u.timeout),T=u.TimedOut,_=u.buildOHLCVC,C=r(0),R=C.ExchangeError,P=C.InvalidAddress,B=C.NotSupported,S=C.AuthenticationError,E=C.DDoSProtection,F=C.RequestTimeout,j=C.ExchangeNotAvailable,A=u.precisionConstants.DECIMAL_PLACES,I=d?r(70)().fetch:fetch,M=void 0;e.exports=function(){function e(){var r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),Object.assign(this,u,{encode:function(e){return e},decode:function(e){return e}}),d&&(this.nodeVersion=t.version.match(/\d+\.\d+.\d+/)[0]),this.options={},this.userAgents={chrome:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",chrome39:"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"},this.headers={},this.proxy="",this.origin="*",this.iso8601=function(e){return void 0===e?e:new Date(e).toISOString()},this.parse8601=function(e){return Date.parse(e.indexOf("+")>=0||"Z"===e.slice(-1)?e:(e+"Z").replace(/\s(\d\d):/,"T$1:"))},this.parseDate=function(e){return void 0===e?e:e.indexOf("GMT")>=0?Date.parse(e):r.parse8601(e)},this.microseconds=function(){return 1e3*x()},this.seconds=function(){return Math.floor(x()/1e3)},this.minFundingAddressLength=1,this.substituteCommonCurrencyCodes=!0,this.fetchImplementation=I,this.timeout=1e4,this.verbose=!1,this.debug=!1,this.journal="debug.json",this.userAgent=void 0,this.twofa=!1,this.apiKey=void 0,this.secret=void 0,this.uid=void 0,this.login=void 0,this.password=void 0,this.balance={},this.orderbooks={},this.tickers={},this.orders={},this.trades={},this.last_http_response=void 0,this.last_json_response=void 0,this.last_response_headers=void 0,this.arrayConcat=function(e,t){return e.concat(t)};!function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r;if(null!==t){var n=!0,i=!1,o=void 0;try{for(var a,s=Object.getOwnPropertyNames(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;r[b(u)]=r[u]}}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}e(Object.getPrototypeOf(t))}}();var o=h(this.describe(),n),s=!0,c=!1,l=void 0;try{for(var p,f=Object.entries(o)[Symbol.iterator]();!(s=(p=f.next()).done);s=!0){var v=a(p.value,2),m=v[0],y=v[1];this[m]=h(this[m],y)}}catch(e){c=!0,l=e}finally{try{!s&&f.return&&f.return()}finally{if(c)throw l}}for(var g in this.has)this["has"+w(g)]=!!this.has[g];this.api&&this.defineRestApi(this.api,"request"),this.initRestRateLimiter(),this.markets&&this.setMarkets(this.markets),this.debug&&M&&M(function(){return r.journal},this,Object.keys(this.has))}return s(e,[{key:"getMarket",value:function(e){this.marketClasses||(this.marketClasses={});var t=this.marketClasses[e];return t||(t=new c(this,e),this.marketClasses[e]=t,t)}},{key:"describe",value:function(){return{id:void 0,name:void 0,countries:void 0,enableRateLimit:!1,rateLimit:2e3,has:{CORS:!1,publicAPI:!0,privateAPI:!0,cancelOrder:!0,cancelOrders:!1,createDepositAddress:!1,createOrder:!0,createMarketOrder:!0,createLimitOrder:!0,deposit:!1,editOrder:"emulated",fetchBalance:!0,fetchBidsAsks:!1,fetchClosedOrders:!1,fetchCurrencies:!1,fetchDepositAddress:!1,fetchFundingFees:!1,fetchL2OrderBook:!0,fetchMarkets:!0,fetchMyTrades:!1,fetchOHLCV:"emulated",fetchOpenOrders:!1,fetchOrder:!1,fetchOrderBook:!0,fetchOrderBooks:!1,fetchOrders:!1,fetchTicker:!0,fetchTickers:!1,fetchTrades:!0,fetchTradingFees:!1,withdraw:!1},urls:{logo:void 0,api:void 0,www:void 0,doc:void 0,fees:void 0},api:void 0,requiredCredentials:{apiKey:!0,secret:!0,uid:!1,login:!1,password:!1,twofa:!1},markets:void 0,currencies:{},timeframes:void 0,fees:{trading:{tierBased:void 0,percentage:void 0,taker:void 0,maker:void 0},funding:{tierBased:void 0,percentage:void 0,withdraw:{},deposit:{}}},parseJsonResponse:!0,skipJsonOnStatusCodes:[],exceptions:void 0,dontGetUsedBalanceFromStaleCache:!1,commonCurrencies:{XBT:"BTC",BCC:"BCH",DRK:"DASH"},precisionMode:A}}}]),s(e,[{key:"defaults",value:function(){return{}}},{key:"nonce",value:function(){return this.seconds()}},{key:"milliseconds",value:function(){return x()}},{key:"encodeURIComponent",value:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(){return encodeURIComponent.apply(void 0,arguments)})},{key:"checkRequiredCredentials",value:function(){var e=this;Object.keys(this.requiredCredentials).forEach(function(t){if(e.requiredCredentials[t]&&!e[t])throw new S(e.id+" requires `"+t+"`")})}},{key:"checkAddress",value:function(e){if(void 0===e)throw new P(this.id+" address is undefined");if(1===f(e).length||e.length<this.minFundingAddressLength||e.includes(" "))throw new P(this.id+" address is invalid or has less than "+this.minFundingAddressLength.toString()+' characters: "'+e.toString()+'"');return e}},{key:"initRestRateLimiter",value:function(){var e=this.fetchImplementation;if(void 0===this.rateLimit)throw new Error(this.id+".rateLimit property is not configured");this.tokenBucket=this.extend({refillRate:1/this.rateLimit,delay:1,capacity:1,defaultCost:1,maxCapacity:1e3},this.tokenBucket),this.throttle=k(this.tokenBucket),this.executeRestRequest=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,a=e(t,{method:r,headers:i,body:o,agent:this.agent||null,timeout:this.timeout}).catch(function(e){if(d)throw new j([n.id,r,t,e.type,e.message].join(" "));throw e}).then(function(e){return n.handleRestResponse(e,t,r,i,o)});return O(this.timeout,a).catch(function(e){if(e instanceof T)throw new F(n.id+" "+r+" "+t+" request timed out ("+n.timeout+" ms)");throw e})}}},{key:"defineRestApi",value:function(e,t){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=!0,a=!1,s=void 0;try{for(var u,c=Object.keys(e)[Symbol.iterator]();!(o=(u=c.next()).done);o=!0)!function(){var o=u.value,a=!0,s=!1,c=void 0;try{for(var d,h=Object.keys(e[o])[Symbol.iterator]();!(a=(d=h.next()).done);a=!0)for(var l=d.value,p=e[o][l],f=0;f<p.length;f++)!function(e){var a=p[e].trim(),s=a.split(/[^a-zA-Z0-9]/),u=l.toUpperCase(),c=l.toLowerCase(),d=r.capitalize(c),h=s.map(r.capitalize).join(""),f=s.map(function(e){return e.trim().toLowerCase()}).filter(function(e){return e.length>0}).join("_"),v=o+d+r.capitalize(h),m=o+"_"+c+"_"+f;"suffixes"in i&&("camelcase"in i.suffixes&&(v+=i.suffixes.camelcase),"underscore"in i.suffixes&&(m+=i.suffixes.underscore)),"underscore_suffix"in i&&(m+=i.underscoreSuffix),"camelcase_suffix"in i&&(v+=i.camelcaseSuffix);var y=function(){var e=n(regeneratorRuntime.mark(function e(n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r[t](a,o,u,n||{}));case 1:case"end":return e.stop()}},e,r)}));return function(t){return e.apply(this,arguments)}}();r[v]=y,r[m]=y}(f)}catch(e){s=!0,c=e}finally{try{!a&&h.return&&h.return()}finally{if(s)throw c}}}()}catch(e){a=!0,s=e}finally{try{!o&&c.return&&c.return()}finally{if(a)throw s}}}},{key:"fetch",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;return d&&this.userAgent&&("string"==typeof this.userAgent?r=l({"User-Agent":this.userAgent},r):"object"===o(this.userAgent)&&"User-Agent"in this.userAgent&&(r=l(this.userAgent,r))),"function"==typeof this.proxy?(e=this.proxy(e),d&&(r=l({Origin:this.origin},r))):"string"==typeof this.proxy&&(this.proxy.length&&d&&(r=l({Origin:this.origin},r)),e=this.proxy+e),r=l(this.headers,r),this.verbose&&console.log("fetch:\n",this.id,t,e,"\nRequest:\n",r,"\n",n,"\n"),this.executeRestRequest(e,t,r,n)}},{key:"fetch2",value:function(){function e(e){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"public",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:void 0;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.enableRateLimit){e.next=3;break}return e.next=3,this.throttle();case 3:return r=this.sign(t,n,i,o,a,s),e.abrupt("return",this.fetch(r.url,r.method,r.headers,r.body));case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"request",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"public",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:void 0;return this.fetch2(e,t,r,n,i,o)}},{key:"parseJson",value:function(e,t,r,n){try{return t.length>0?JSON.parse(t):{}}catch(d){this.verbose&&console.log("parseJson:\n",this.id,n,r,e.status,"error",d,"response body:\n'"+t+"'\n");var i=void 0,o=t.match(/<title>([^<]+)/i);o&&(i=o[1].trim());var a=t.match(/offline|busy|retry|wait|unavailable|maintain|maintenance|maintenancing/i),s=t.match(/cloudflare|incapsula|overload|ddos/i);if(d instanceof SyntaxError){var u=j,c="not accessible from this location at the moment";throw a&&(c="offline, on maintenance or unreachable from this location at the moment"),s&&(u=E),new u([this.id,n,r,e.status,i,c].join(" "))}throw d}}},{key:"handleErrors",value:function(e,t,r,n,i,o,a){}},{key:"defaultErrorHandler",value:function(e,t,r,n){var i=e.status,o=e.statusText;if(!(i>=200&&i<=299)){var a=void 0,s=t,u=t.match(/<title>([^<]+)/i);if(u&&(s=u[1].trim()),[418,429].includes(i))a=E;else if([404,409,500,501,502,520,521,522,525].includes(i))a=j;else if([400,403,405,503,530].includes(i)){var c=t.match(/cloudflare|incapsula/i);c?a=E:(a=j,s+=" (possible reasons: "+["invalid API keys","bad or old nonce","exchange is down or offline","on maintenance","DDoS protection","rate-limiting"].join(", ")+")")}else a=[408,504].includes(i)?F:[401,511].includes(i)?S:R;throw new a([this.id,n,r,i,o,s].join(" "))}}},{key:"handleRestResponse",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",n=this;arguments.length>3&&void 0!==arguments[3]&&arguments[3],arguments.length>4&&void 0!==arguments[4]&&arguments[4];return e.text().then(function(i){var o=n.parseJsonResponse&&!n.skipJsonOnStatusCodes.includes(e.status),a=o?n.parseJson(e,i,t,r):void 0,s={};e.headers.forEach(function(e,t){t=t.split("-").map(function(e){return w(e)}).join("-"),s[t]=e}),n.last_response_headers=s,n.last_http_response=i,n.last_json_response=a,n.verbose&&console.log("handleRestResponse:\n",n.id,r,t,e.status,e.statusText,"\nResponse:\n",s,"\n",i,"\n");var u=[e.status,e.statusText,t,r,s,i,a];return n.handleErrors.apply(n,u),n.defaultErrorHandler(e,i,t,r),o?a:i})}},{key:"setMarkets",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=Object.values(e).map(function(e){return h({limits:t.limits,precision:t.precision},t.fees.trading,e)});if(this.markets=h(this.markets,v(n,"symbol")),this.marketsById=v(e,"id"),this.markets_by_id=this.marketsById,this.symbols=Object.keys(this.markets).sort(),this.ids=Object.keys(this.markets_by_id).sort(),r)this.currencies=h(r,this.currencies);else{var i=n.filter(function(e){return"base"in e}).map(function(e){return{id:e.baseId||e.base,numericId:void 0!==e.baseNumericId?e.baseNumericId:void 0,code:e.base,precision:e.precision?e.precision.base||e.precision.amount:8}}),o=n.filter(function(e){return"quote"in e}).map(function(e){return{id:e.quoteId||e.quote,numericId:void 0!==e.quoteNumericId?e.quoteNumericId:void 0,code:e.quote,precision:e.precision?e.precision.quote||e.precision.price:8}}),a=i.concat(o),s=y(a,"code"),u=Object.keys(s).map(function(e){return s[e].reduce(function(e,t){return e.precision>t.precision?e:t},s[e][0])}),c=m(p(u),"code");this.currencies=h(v(c,"code"),this.currencies)}return this.currencies_by_id=v(this.currencies,"id"),this.markets}},{key:"loadMarkets",value:function(){function e(){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(){var t,r,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n||!this.markets){e.next=4;break}if(this.markets_by_id){e.next=3;break}return e.abrupt("return",this.setMarkets(this.markets));case 3:return e.abrupt("return",this.markets);case 4:return e.next=6,this.fetchMarkets();case 6:if(t=e.sent,r=void 0,!this.has.fetchCurrencies){e.next=12;break}return e.next=11,this.fetchCurrencies();case 11:r=e.sent;case 12:return e.abrupt("return",this.setMarkets(t,r));case 13:case"end":return e.stop()}},e,this)}));return e}()},{key:"fetchBidsAsks",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]&&arguments[1];throw new B(this.id+" fetchBidsAsks not supported yet")}},{key:"fetchOHLCVC",value:function(){function e(e){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t){var r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"1m",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.has.fetchTrades){e.next=2;break}throw new B(this.id+" fetchOHLCV() not supported yet");case 2:return e.next=4,this.loadMarkets();case 4:return e.next=6,this.fetchTrades(t,o,a,s);case 6:return r=e.sent,n=_(r,i,o,a),e.abrupt("return",n);case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"fetchOHLCV",value:function(){function e(e){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t){var r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"1m",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.has.fetchTrades){e.next=2;break}throw new B(this.id+" fetchOHLCV() not supported yet");case 2:return e.next=4,this.loadMarkets();case 4:return e.next=6,this.fetchTrades(t,o,a,s);case 6:return r=e.sent,n=_(r,i,o,a),e.abrupt("return",n.map(function(e){return e.slice(0,-1)}));case 9:case"end":return e.stop()}},e,this)}));return e}()},{key:"convertTradingViewToOHLCV",value:function(e){for(var t=[],r=0;r<e.t.length;r++)t.push([1e3*e.t[r],e.o[r],e.h[r],e.l[r],e.c[r],e.v[r]]);return t}},{key:"convertOHLCVToTradingView",value:function(e){for(var t={t:[],o:[],h:[],l:[],c:[],v:[]},r=0;r<e.length;r++)t.t.push(parseInt(e[r][0]/1e3)),t.o.push(e[r][1]),t.h.push(e[r][2]),t.l.push(e[r][3]),t.c.push(e[r][4]),t.v.push(e[r][5]);return t}},{key:"fetchTickers",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]&&arguments[1];throw new B(this.id+" fetchTickers not supported yet")}},{key:"purgeCachedOrders",value:function(e){var t=Object.values(this.orders).filter(function(t){return"open"===t.status||t.timestamp>=e});return this.orders=v(t,"id"),this.orders}},{key:"fetchOrder",value:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2];throw new B(this.id+" fetchOrder not supported yet")}},{key:"fetchOrders",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3];throw new B(this.id+" fetchOrders not supported yet")}},{key:"fetchOpenOrders",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3];throw new B(this.id+" fetchOpenOrders not supported yet")}},{key:"fetchClosedOrders",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3];throw new B(this.id+" fetchClosedOrders not supported yet")}},{key:"fetchMyTrades",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3];throw new B(this.id+" fetchMyTrades not supported yet")}},{key:"fetchCurrencies",value:function(){throw new B(this.id+" fetchCurrencies not supported yet")}},{key:"fetchMarkets",value:function(){var e=this;return new Promise(function(t,r){return t(Object.values(e.markets))})}},{key:"fetchOrderStatus",value:function(){function e(e){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.fetchOrder(t,n);case 2:return r=e.sent,e.abrupt("return",r.status);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"account",value:function(){return{free:0,used:0,total:0}}},{key:"commonCurrencyCode",value:function(e){return this.substituteCommonCurrencyCodes?this.safeString(this.commonCurrencies,e,e):e}},{key:"currencyId",value:function(e){for(var t={},r=Object.keys(this.commonCurrencies),n=0;n<r.length;n++){var i=r[n];t[this.commonCurrencies[i]]=i}return this.safeString(t,e,e)}},{key:"currency",value:function(e){if(void 0===this.currencies)throw new R(this.id+" currencies not loaded");if("string"==typeof e&&e in this.currencies)return this.currencies[e];throw new R(this.id+" does not have currency code "+e)}},{key:"findMarket",value:function(e){if(void 0===this.markets)throw new R(this.id+" markets not loaded");if("string"==typeof e){if(e in this.markets_by_id)return this.markets_by_id[e];if(e in this.markets)return this.markets[e]}return e}},{key:"findSymbol",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return void 0===t&&(t=this.findMarket(e)),"object"===(void 0===t?"undefined":o(t))?t.symbol:e}},{key:"market",value:function(e){if(void 0===this.markets)throw new R(this.id+" markets not loaded");if("string"==typeof e&&e in this.markets)return this.markets[e];throw new R(this.id+" does not have market symbol "+e)}},{key:"marketId",value:function(e){var t=this.market(e);return void 0!==t?t.id:e}},{key:"marketIds",value:function(e){var t=this;return e.map(function(e){return t.marketId(e)})}},{key:"symbol",value:function(e){return this.market(e).symbol||e}},{key:"extractParams",value:function(e){for(var t=/{([\w-]+)}/g,r=[],n=t.exec(e);n;)r.push(n[1]),n=t.exec(e);return r}},{key:"implodeParams",value:function(e,t){for(var r in t)e=e.replace("{"+r+"}",t[r]);return e}},{key:"url",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.implodeParams(e,t),n=this.omit(t,this.extractParams(e));return Object.keys(n).length&&(r+="?"+this.urlencode(n)),r}},{key:"parseBidAsk",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return[parseFloat(e[t]),parseFloat(e[r])]}},{key:"parseBidsAsks",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Object.values(e||[]).map(function(e){return t.parseBidAsk(e,r,n)})}},{key:"fetchL2OrderBook",value:function(){function e(e){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.fetchOrderBook(t,n,i);case 2:return r=e.sent,e.abrupt("return",l(r,{bids:m(g(r.bids),0,!0),asks:m(g(r.asks),0)}));case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"parseOrderBook",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"bids",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"asks",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1;return{bids:m(r in e?this.parseBidsAsks(e[r],i,o):[],0,!0),asks:m(n in e?this.parseBidsAsks(e[n],i,o):[],0),timestamp:t,datetime:void 0!==t?this.iso8601(t):void 0,nonce:void 0}}},{key:"getCurrencyUsedOnOpenOrders",value:function(e){var t=this;return Object.values(this.orders).filter(function(e){return"open"===e.status}).reduce(function(r,n){var i=n.symbol,o=t.markets[i],a=n.remaining;return e===o.base&&"sell"===n.side?r+a:e===o.quote&&"buy"===n.side?r+n.price*a:r},0)}},{key:"parseBalance",value:function(e){var t=this;return Object.keys(this.omit(e,"info")).forEach(function(r){if(void 0===e[r].used)if(t.dontGetUsedBalanceFromStaleCache&&"open_orders"in e.info){var n=e.info.open_orders,i=Object.values(t.orders).filter(function(e){return"open"===e.status}).length;i===n&&(e[r].used=t.getCurrencyUsedOnOpenOrders(r),e[r].total=e[r].used+e[r].free)}else e[r].used=t.getCurrencyUsedOnOpenOrders(r),e[r].total=e[r].used+e[r].free;["free","used","total"].forEach(function(t){e[t]=e[t]||{},e[t][r]=e[r][t]})}),e}},{key:"fetchPartialBalance",value:function(){function e(e){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.fetchBalance(n);case 2:return r=e.sent,e.abrupt("return",r[t]);case 4:case"end":return e.stop()}},e,this)}));return e}()},{key:"fetchFreeBalance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.fetchPartialBalance("free",e)}},{key:"fetchUsedBalance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.fetchPartialBalance("used",e)}},{key:"fetchTotalBalance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.fetchPartialBalance("total",e)}},{key:"filterBySinceLimit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return void 0!==t&&(e=e.filter(function(e){return e.timestamp>=t})),void 0!==r&&(e=e.slice(0,r)),e}},{key:"filterBySymbolSinceLimit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=void 0!==t,o=void 0!==r;return(i||o)&&(e=Object.values(e).filter(function(e){return(!i||e.symbol===t)&&(!o||e.timestamp>=r)})),void 0!==n&&(e=Object.values(e).slice(0,n)),e}},{key:"filterByArray",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e=Object.values(e),void 0===r)return n?v(e,t):e;for(var i=[],o=0;o<e.length;o++)r.includes(e[o][t])&&i.push(e[o]);return n?v(i,t):i}},{key:"parseTrades",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,o=Object.values(e||[]).map(function(e){return r.parseTrade(e,t)});o=m(o,"timestamp");var a=void 0!==t?t.symbol:void 0;return this.filterBySymbolSinceLimit(o,a,n,i)}},{key:"parseOrders",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,o=Object.values(e).map(function(e){return r.parseOrder(e,t)});o=m(o,"timestamp");var a=void 0!==t?t.symbol:void 0;return this.filterBySymbolSinceLimit(o,a,n,i)}},{key:"filterBySymbol",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return void 0!==t?e.filter(function(e){return e.symbol===t}):e}},{key:"parseOHLCV",value:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3],arguments.length>4&&void 0!==arguments[4]&&arguments[4];return Array.isArray(e)?e.slice(0,6):e}},{key:"parseOHLCVs",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"1m",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;e=Object.values(e);for(var o=[],a=0;a<e.length&&!(i&&o.length>=i);a++){var s=this.parseOHLCV(e[a],t,r,n,i);n&&s[0]<n||o.push(s)}return o}},{key:"editLimitBuyOrder",value:function(e,t){for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return this.editLimitOrder.apply(this,[e,t,"buy"].concat(n))}},{key:"editLimitSellOrder",value:function(e,t){for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return this.editLimitOrder.apply(this,[e,t,"sell"].concat(n))}},{key:"editLimitOrder",value:function(e,t){for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return this.editOrder.apply(this,[e,t,"limit"].concat(n))}},{key:"editOrder",value:function(){function e(e,r){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t,r){for(var n=arguments.length,i=Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.enableRateLimit){e.next=2;break}throw new R(this.id+" editOrder() requires enableRateLimit = true");case 2:return e.next=4,this.cancelOrder(t,r);case 4:return e.abrupt("return",this.createOrder.apply(this,[r].concat(i)));case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"createLimitOrder",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return this.createOrder.apply(this,[e,"limit"].concat(r))}},{key:"createMarketOrder",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return this.createOrder.apply(this,[e,"market"].concat(r))}},{key:"createLimitBuyOrder",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return this.createOrder.apply(this,[e,"limit","buy"].concat(r))}},{key:"createLimitSellOrder",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return this.createOrder.apply(this,[e,"limit","sell"].concat(r))}},{key:"createMarketBuyOrder",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.createOrder(e,"market","buy",t,void 0,r)}},{key:"createMarketSellOrder",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.createOrder(e,"market","sell",t,void 0,r)}},{key:"costToPrecision",value:function(e,t){return parseFloat(t).toFixed(this.markets[e].precision.price)}},{key:"priceToPrecision",value:function(e,t){return parseFloat(t).toFixed(this.markets[e].precision.price)}},{key:"amountToPrecision",value:function(e,t){return this.truncate(t,this.markets[e].precision.amount)}},{key:"amountToString",value:function(e,t){return this.truncate_to_string(t,this.markets[e].precision.amount)}},{key:"amountToLots",value:function(e,t){var r=this.markets[e].lot;return this.amountToPrecision(e,Math.floor(t/r)*r)}},{key:"feeToPrecision",value:function(e,t){return parseFloat(t).toFixed(this.markets[e].precision.price)}},{key:"calculateFee",value:function(e,t,r,n,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"taker",a=(arguments.length>6&&void 0!==arguments[6]&&arguments[6],this.markets[e]),s=a[o],u=parseFloat(this.costToPrecision(e,n*i));return{type:o,currency:a.quote,rate:s,cost:parseFloat(this.feeToPrecision(e,s*u))}}},{key:"ymd",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]&&arguments[1],new Date(e)),r=t.getUTCFullYear(),n=t.getUTCMonth()+1,i=t.getUTCDate();return n=n<10?"0"+n:n,i=i<10?"0"+i:i,r+"-"+n+"-"+i}},{key:"ymdhms",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" ",r=new Date(e),n=r.getUTCFullYear(),i=r.getUTCMonth()+1,o=r.getUTCDate(),a=r.getUTCHours(),s=r.getUTCMinutes(),u=r.getUTCSeconds();return i=i<10?"0"+i:i,o=o<10?"0"+o:o,a=a<10?"0"+a:a,s=s<10?"0"+s:s,u=u<10?"0"+u:u,n+"-"+i+"-"+o+t+a+":"+s+":"+u}}]),e}()}).call(t,r(21))},function(e,t,r){!function(r,n){e.exports=t=n()}(0,function(){var e=e||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},i=n.lib={},o=i.Base=function(){return{extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],i=0;i<t;i+=4){var o=function(t){var t=t,r=987654321,n=4294967295;return function(){r=36969*(65535&r)+(r>>16)&n,t=18e3*(65535&t)+(t>>16)&n;var i=(r<<16)+t&n;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}}(4294967296*(r||e.random()));r=987654071*o(),n.push(4294967296*o()|0)}return new a.init(n,t)}}),s=n.enc={},u=s.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new a.init(r,t/2)}},c=s.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new a.init(r,t)}},d=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,s=4*o,u=i/s;u=t?e.ceil(u):e.max((0|u)-this._minBufferSize,0);var c=u*o,d=e.min(4*c,i);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(n,h);var l=n.splice(0,c);r.sigBytes-=d}return new a.init(l,d)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),l=(i.Hasher=h.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new l.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math);return e})},function(e,t,r){!function(n,i,o){e.exports=t=i(r(2),r(4))}(0,function(e){e.lib.Cipher||function(t){var r=e,n=r.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=r.enc,u=(s.Utf8,s.Base64),c=r.algo,d=c.EvpKDF,h=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?O:k}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()}),l=(n.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),p=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=l.CBC=function(){function e(e,r,n){var i=this._iv;if(i){var o=i;this._iv=t}else var o=this._prevBlock;for(var a=0;a<n;a++)e[r+a]^=o[a]}var r=p.extend();return r.Encryptor=r.extend({processBlock:function(t,r){var n=this._cipher,i=n.blockSize;e.call(this,t,r,i),n.encryptBlock(t,r),this._prevBlock=t.slice(r,r+i)}}),r.Decryptor=r.extend({processBlock:function(t,r){var n=this._cipher,i=n.blockSize,o=t.slice(r,r+i);n.decryptBlock(t,r),e.call(this,t,r,i),this._prevBlock=o}}),r}(),v=r.pad={},m=v.Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var u=o.create(a,n);e.concat(u)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},y=(n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:f,padding:m}),reset:function(){h.reset.call(this);var e=this.cfg,t=e.iv,r=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{var n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,t&&t.words):(this._mode=n.call(r,this,t&&t.words),this._mode.__creator=n)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{var t=this._process(!0);e.unpad(t)}return t},blockSize:4}),n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),g=r.format={},b=g.OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(t);else var n=t;return n.toString(u)},parse:function(e){var t=u.parse(e),r=t.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),t.sigBytes-=16}return y.create({ciphertext:t,salt:n})}},k=n.SerializableCipher=i.extend({cfg:i.extend({format:b}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return y.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),w=r.kdf={},x=w.OpenSSL={execute:function(e,t,r,n){n||(n=o.random(8));var i=d.create({keySize:t+r}).compute(e,n),a=o.create(i.words.slice(t),4*r);return i.sigBytes=4*t,y.create({key:i,iv:a,salt:n})}},O=n.PasswordBasedCipher=k.extend({cfg:k.cfg.extend({kdf:x}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=n.kdf.execute(r,e.keySize,e.ivSize);n.iv=i.iv;var o=k.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt);return n.iv=i.iv,k.decrypt.call(this,e,t,i.key,n)}})}()})},function(e,t,r){!function(n,i,o){e.exports=t=i(r(2),r(15),r(16))}(0,function(e){return function(){var t=e,r=t.lib,n=r.Base,i=r.WordArray,o=t.algo,a=o.MD5,s=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:a,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),a=o.words,s=r.keySize,u=r.iterations;a.length<s;){c&&n.update(c);var c=n.update(e).finalize(t);n.reset();for(var d=1;d<u;d++)c=n.finalize(c),n.reset();o.concat(c)}return o.sigBytes=4*s,o}});t.EvpKDF=function(e,t,r){return s.create(r).compute(e,t)}}(),e.EvpKDF})},function(e,t,r){!function(n,i){e.exports=t=i(r(2))}(0,function(e){return function(){function t(e,t,r){for(var n=[],o=0,a=0;a<t;a++)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2,u=r[e.charCodeAt(a)]>>>6-a%4*2;n[o>>>2]|=(s|u)<<24-o%4*8,o++}return i.create(n,o)}var r=e,n=r.lib,i=n.WordArray,o=r.enc;o.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=t[o>>>2]>>>24-o%4*8&255,s=t[o+1>>>2]>>>24-(o+1)%4*8&255,u=t[o+2>>>2]>>>24-(o+2)%4*8&255,c=a<<16|s<<8|u,d=0;d<4&&o+.75*d<r;d++)i.push(n.charAt(c>>>6*(3-d)&63));var h=n.charAt(64);if(h)for(;i.length%4;)i.push(h);return i.join("")},parse:function(e){var r=e.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<n.length;o++)i[n.charCodeAt(o)]=o}var a=n.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(r=s)}return t(e,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64})},function(e,t,r){!function(n,i){e.exports=t=i(r(2))}(0,function(e){return function(t){function r(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function n(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function i(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function o(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}var a=e,s=a.lib,u=s.WordArray,c=s.Hasher,d=a.algo,h=[];!function(){for(var e=0;e<64;e++)h[e]=4294967296*t.abs(t.sin(e+1))|0}();var l=d.MD5=c.extend({_doReset:function(){this._hash=new u.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var a=0;a<16;a++){var s=t+a,u=e[s];e[s]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}var c=this._hash.words,d=e[t+0],l=e[t+1],p=e[t+2],f=e[t+3],v=e[t+4],m=e[t+5],y=e[t+6],g=e[t+7],b=e[t+8],k=e[t+9],w=e[t+10],x=e[t+11],O=e[t+12],T=e[t+13],_=e[t+14],C=e[t+15],R=c[0],P=c[1],B=c[2],S=c[3];R=r(R,P,B,S,d,7,h[0]),S=r(S,R,P,B,l,12,h[1]),B=r(B,S,R,P,p,17,h[2]),P=r(P,B,S,R,f,22,h[3]),R=r(R,P,B,S,v,7,h[4]),S=r(S,R,P,B,m,12,h[5]),B=r(B,S,R,P,y,17,h[6]),P=r(P,B,S,R,g,22,h[7]),R=r(R,P,B,S,b,7,h[8]),S=r(S,R,P,B,k,12,h[9]),B=r(B,S,R,P,w,17,h[10]),P=r(P,B,S,R,x,22,h[11]),R=r(R,P,B,S,O,7,h[12]),S=r(S,R,P,B,T,12,h[13]),B=r(B,S,R,P,_,17,h[14]),P=r(P,B,S,R,C,22,h[15]),R=n(R,P,B,S,l,5,h[16]),S=n(S,R,P,B,y,9,h[17]),B=n(B,S,R,P,x,14,h[18]),P=n(P,B,S,R,d,20,h[19]),R=n(R,P,B,S,m,5,h[20]),S=n(S,R,P,B,w,9,h[21]),B=n(B,S,R,P,C,14,h[22]),P=n(P,B,S,R,v,20,h[23]),R=n(R,P,B,S,k,5,h[24]),S=n(S,R,P,B,_,9,h[25]),B=n(B,S,R,P,f,14,h[26]),P=n(P,B,S,R,b,20,h[27]),R=n(R,P,B,S,T,5,h[28]),S=n(S,R,P,B,p,9,h[29]),B=n(B,S,R,P,g,14,h[30]),P=n(P,B,S,R,O,20,h[31]),R=i(R,P,B,S,m,4,h[32]),S=i(S,R,P,B,b,11,h[33]),B=i(B,S,R,P,x,16,h[34]),P=i(P,B,S,R,_,23,h[35]),R=i(R,P,B,S,l,4,h[36]),S=i(S,R,P,B,v,11,h[37]),B=i(B,S,R,P,g,16,h[38]),P=i(P,B,S,R,w,23,h[39]),R=i(R,P,B,S,T,4,h[40]),S=i(S,R,P,B,d,11,h[41]),B=i(B,S,R,P,f,16,h[42]),P=i(P,B,S,R,y,23,h[43]),R=i(R,P,B,S,k,4,h[44]),S=i(S,R,P,B,O,11,h[45]),B=i(B,S,R,P,C,16,h[46]),P=i(P,B,S,R,p,23,h[47]),R=o(R,P,B,S,d,6,h[48]),S=o(S,R,P,B,g,10,h[49]),B=o(B,S,R,P,_,15,h[50]),P=o(P,B,S,R,m,21,h[51]),R=o(R,P,B,S,O,6,h[52]),S=o(S,R,P,B,f,10,h[53]),B=o(B,S,R,P,w,15,h[54]),P=o(P,B,S,R,l,21,h[55]),R=o(R,P,B,S,b,6,h[56]),S=o(S,R,P,B,C,10,h[57]),B=o(B,S,R,P,y,15,h[58]),P=o(P,B,S,R,T,21,h[59]),R=o(R,P,B,S,v,6,h[60]),S=o(S,R,P,B,x,10,h[61]),B=o(B,S,R,P,p,15,h[62]),P=o(P,B,S,R,k,21,h[63]),c[0]=c[0]+R|0,c[1]=c[1]+P|0,c[2]=c[2]+B|0,c[3]=c[3]+S|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,u=s.words,c=0;c<4;c++){var d=u[c];u[c]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=c.clone.call(this);return e._hash=this._hash.clone(),e}});a.MD5=c._createHelper(l),a.HmacMD5=c._createHmacHelper(l)}(Math),e.MD5})},function(e,t,r){"use strict";function n(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,r){function n(i,o){try{var a=t[i](o),s=a.value}catch(e){return void r(e)}if(!a.done)return Promise.resolve(s).then(function(e){n("next",e)},function(e){n("throw",e)});e(s)}return n("next")})}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in i)return i.value;var a=i.get;if(void 0!==a)return a.call(n)},c=r(1),d=r(0),h=d.ExchangeError;e.exports=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),s(t,[{key:"describe",value:function(){return this.deepExtend(u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"describe",this).call(this),{id:"foxbit",name:"FoxBit",countries:"BR",has:{CORS:!1,createMarketOrder:!1},rateLimit:1e3,version:"v1",urls:{logo:"https://user-images.githubusercontent.com/1294454/27991413-11b40d42-647f-11e7-91ee-78ced874dd09.jpg",api:{public:"https://api.blinktrade.com/api",private:"https://api.blinktrade.com/tapi"},www:"https://foxbit.exchange",doc:"https://blinktrade.com/docs"},comment:"Blinktrade API",api:{public:{get:["{currency}/ticker","{currency}/orderbook","{currency}/trades"]},private:{post:["D","F","U2","U4","U6","U18","U24","U26","U30","U34","U70"]}},markets:{"BTC/VEF":{id:"BTCVEF",symbol:"BTC/VEF",base:"BTC",quote:"VEF",brokerId:1,broker:"SurBitcoin"},"BTC/VND":{id:"BTCVND",symbol:"BTC/VND",base:"BTC",quote:"VND",brokerId:3,broker:"VBTC"},"BTC/BRL":{id:"BTCBRL",symbol:"BTC/BRL",base:"BTC",quote:"BRL",brokerId:4,broker:"FoxBit"},"BTC/PKR":{id:"BTCPKR",symbol:"BTC/PKR",base:"BTC",quote:"PKR",brokerId:8,broker:"UrduBit"},"BTC/CLP":{id:"BTCCLP",symbol:"BTC/CLP",base:"BTC",quote:"CLP",brokerId:9,broker:"ChileBit"}},options:{brokerId:"4"}})}},{key:"fetchBalance",value:function(){function e(){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(){var t,r,n,i,o,a,s,u,c;arguments.length>0&&void 0!==arguments[0]&&arguments[0];return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.privatePostU2({BalanceReqID:this.nonce()});case 2:if(t=e.sent,r=this.safeValue(t.Responses,this.options.brokerId),n={info:t},void 0!==r)for(i=Object.keys(this.currencies_by_id),o=0;o<i.length;o++)a=i[o],s=this.currencies_by_id[a],u=s.code,a in r&&(c=this.account(),c.used=1e-8*parseFloat(r[a+"_locked"]),c.total=1e-8*parseFloat(r[a]),c.free=c.total-c.used,n[u]=c);return e.abrupt("return",this.parseBalance(n));case 7:case"end":return e.stop()}},e,this)}));return e}()},{key:"fetchOrderBook",value:function(){function e(e){return t.apply(this,arguments)}var t=n(regeneratorRuntime.mark(function e(t){var r,n,i=(arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:{});return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.market(t),e.next=3,this.publicGetCurrencyOrderbook(this.extend({currency:r.quote,crypto_currency:r.base},i));case 3:return n=e.sent,e.abrupt("return",this.parseOrderBook(n));case 5:case"end":return e.stop()}},e,this)}));return e}()},{key:"