@umerx/alpaca
Version:
A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
1 lines • 481 kB
JavaScript
import require$$0$3 from"util";import Stream from"stream";import http from"http";import Url from"url";import https from"https";import zlib from"zlib";import EventEmitter from"events";import net from"net";import tls from"tls";import require$$0$4 from"crypto";import fs from"fs";import path from"path";import os from"os";function __awaiter(e,a,p,t){return new(p||(p=Promise))((function(d,i){function r(e){try{s(t.next(e))}catch(e){i(e)}}function n(e){try{s(t.throw(e))}catch(e){i(e)}}function s(e){var a;e.done?d(e.value):(a=e.value,a instanceof p?a:new p((function(e){e(a)}))).then(r,n)}s((t=t.apply(e,a||[])).next())}))}var shams=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},a=Symbol("test"),p=Object(a);if("string"==typeof a)return!1;if("[object Symbol]"!==Object.prototype.toString.call(a))return!1;if("[object Symbol]"!==Object.prototype.toString.call(p))return!1;for(a in e[a]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var t=Object.getOwnPropertySymbols(e);if(1!==t.length||t[0]!==a)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,a))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var d=Object.getOwnPropertyDescriptor(e,a);if(42!==d.value||!0!==d.enumerable)return!1}return!0},origSymbol="undefined"!=typeof Symbol&&Symbol,hasSymbols$1=function(){return"function"==typeof origSymbol&&("function"==typeof Symbol&&("symbol"==typeof origSymbol("foo")&&("symbol"==typeof Symbol("bar")&&shams())))},ERROR_MESSAGE="Function.prototype.bind called on incompatible ",slice=Array.prototype.slice,toStr$1=Object.prototype.toString,funcType="[object Function]",implementation$1=function(e){var a=this;if("function"!=typeof a||toStr$1.call(a)!==funcType)throw new TypeError(ERROR_MESSAGE+a);for(var p,t=slice.call(arguments,1),d=function(){if(this instanceof p){var d=a.apply(this,t.concat(slice.call(arguments)));return Object(d)===d?d:this}return a.apply(e,t.concat(slice.call(arguments)))},i=Math.max(0,a.length-t.length),r=[],n=0;n<i;n++)r.push("$"+n);if(p=Function("binder","return function ("+r.join(",")+"){ return binder.apply(this,arguments); }")(d),a.prototype){var s=function(){};s.prototype=a.prototype,p.prototype=new s,s.prototype=null}return p},functionBind=Function.prototype.bind||implementation$1,src=functionBind.call(Function.call,Object.prototype.hasOwnProperty),undefined$1,$SyntaxError=SyntaxError,$Function=Function,$TypeError$1=TypeError,getEvalledConstructor=function(e){try{return $Function('"use strict"; return ('+e+").constructor;")()}catch(e){}},$gOPD=Object.getOwnPropertyDescriptor;if($gOPD)try{$gOPD({},"")}catch(e){$gOPD=null}var throwTypeError=function(){throw new $TypeError$1},ThrowTypeError=$gOPD?function(){try{return throwTypeError}catch(e){try{return $gOPD(arguments,"callee").get}catch(e){return throwTypeError}}}():throwTypeError,hasSymbols=hasSymbols$1(),getProto=Object.getPrototypeOf||function(e){return e.__proto__},needsEval={},TypedArray="undefined"==typeof Uint8Array?undefined$1:getProto(Uint8Array),INTRINSICS={"%AggregateError%":"undefined"==typeof AggregateError?undefined$1:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined$1:ArrayBuffer,"%ArrayIteratorPrototype%":hasSymbols?getProto([][Symbol.iterator]()):undefined$1,"%AsyncFromSyncIteratorPrototype%":undefined$1,"%AsyncFunction%":needsEval,"%AsyncGenerator%":needsEval,"%AsyncGeneratorFunction%":needsEval,"%AsyncIteratorPrototype%":needsEval,"%Atomics%":"undefined"==typeof Atomics?undefined$1:Atomics,"%BigInt%":"undefined"==typeof BigInt?undefined$1:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?undefined$1:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?undefined$1:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?undefined$1:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?undefined$1:FinalizationRegistry,"%Function%":$Function,"%GeneratorFunction%":needsEval,"%Int8Array%":"undefined"==typeof Int8Array?undefined$1:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined$1:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined$1:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":hasSymbols?getProto(getProto([][Symbol.iterator]())):undefined$1,"%JSON%":"object"==typeof JSON?JSON:undefined$1,"%Map%":"undefined"==typeof Map?undefined$1:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&hasSymbols?getProto((new Map)[Symbol.iterator]()):undefined$1,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?undefined$1:Promise,"%Proxy%":"undefined"==typeof Proxy?undefined$1:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?undefined$1:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?undefined$1:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&hasSymbols?getProto((new Set)[Symbol.iterator]()):undefined$1,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined$1:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":hasSymbols?getProto(""[Symbol.iterator]()):undefined$1,"%Symbol%":hasSymbols?Symbol:undefined$1,"%SyntaxError%":$SyntaxError,"%ThrowTypeError%":ThrowTypeError,"%TypedArray%":TypedArray,"%TypeError%":$TypeError$1,"%Uint8Array%":"undefined"==typeof Uint8Array?undefined$1:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?undefined$1:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?undefined$1:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?undefined$1:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?undefined$1:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?undefined$1:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?undefined$1:WeakSet},doEval=function e(a){var p;if("%AsyncFunction%"===a)p=getEvalledConstructor("async function () {}");else if("%GeneratorFunction%"===a)p=getEvalledConstructor("function* () {}");else if("%AsyncGeneratorFunction%"===a)p=getEvalledConstructor("async function* () {}");else if("%AsyncGenerator%"===a){var t=e("%AsyncGeneratorFunction%");t&&(p=t.prototype)}else if("%AsyncIteratorPrototype%"===a){var d=e("%AsyncGenerator%");d&&(p=getProto(d.prototype))}return INTRINSICS[a]=p,p},LEGACY_ALIASES={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},$concat=functionBind.call(Function.call,Array.prototype.concat),$spliceApply=functionBind.call(Function.apply,Array.prototype.splice),$replace=functionBind.call(Function.call,String.prototype.replace),$strSlice=functionBind.call(Function.call,String.prototype.slice),rePropName=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,reEscapeChar=/\\(\\)?/g,stringToPath=function(e){var a=$strSlice(e,0,1),p=$strSlice(e,-1);if("%"===a&&"%"!==p)throw new $SyntaxError("invalid intrinsic syntax, expected closing `%`");if("%"===p&&"%"!==a)throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");var t=[];return $replace(e,rePropName,(function(e,a,p,d){t[t.length]=p?$replace(d,reEscapeChar,"$1"):a||e})),t},getBaseIntrinsic=function(e,a){var p,t=e;if(src(LEGACY_ALIASES,t)&&(t="%"+(p=LEGACY_ALIASES[t])[0]+"%"),src(INTRINSICS,t)){var d=INTRINSICS[t];if(d===needsEval&&(d=doEval(t)),void 0===d&&!a)throw new $TypeError$1("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:p,name:t,value:d}}throw new $SyntaxError("intrinsic "+e+" does not exist!")},getIntrinsic=function(e,a){if("string"!=typeof e||0===e.length)throw new $TypeError$1("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof a)throw new $TypeError$1('"allowMissing" argument must be a boolean');var p=stringToPath(e),t=p.length>0?p[0]:"",d=getBaseIntrinsic("%"+t+"%",a),i=d.name,r=d.value,n=!1,s=d.alias;s&&(t=s[0],$spliceApply(p,$concat([0,1],s)));for(var o=1,l=!0;o<p.length;o+=1){var m=p[o],u=$strSlice(m,0,1),c=$strSlice(m,-1);if(('"'===u||"'"===u||"`"===u||'"'===c||"'"===c||"`"===c)&&u!==c)throw new $SyntaxError("property names with quotes must have matching quotes");if("constructor"!==m&&l||(n=!0),src(INTRINSICS,i="%"+(t+="."+m)+"%"))r=INTRINSICS[i];else if(null!=r){if(!(m in r)){if(!a)throw new $TypeError$1("base intrinsic for "+e+" exists, but the property is not available.");return}if($gOPD&&o+1>=p.length){var h=$gOPD(r,m);r=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:r[m]}else l=src(r,m),r=r[m];l&&!n&&(INTRINSICS[i]=r)}}return r},commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getAugmentedNamespace(e){if(e.__esModule)return e;var a=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(p){var t=Object.getOwnPropertyDescriptor(e,p);Object.defineProperty(a,p,t.get?t:{enumerable:!0,get:function(){return e[p]}})})),a}function createCommonjsModule(e){var a={exports:{}};return e(a,a.exports),a.exports}function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.')}var callBind=createCommonjsModule((function(e){var a=getIntrinsic("%Function.prototype.apply%"),p=getIntrinsic("%Function.prototype.call%"),t=getIntrinsic("%Reflect.apply%",!0)||functionBind.call(p,a),d=getIntrinsic("%Object.getOwnPropertyDescriptor%",!0),i=getIntrinsic("%Object.defineProperty%",!0),r=getIntrinsic("%Math.max%");if(i)try{i({},"a",{value:1})}catch(e){i=null}e.exports=function(e){var a=t(functionBind,p,arguments);if(d&&i){var n=d(a,"length");n.configurable&&i(a,"length",{value:1+r(0,e.length-(arguments.length-1))})}return a};var n=function(){return t(functionBind,a,arguments)};i?i(e.exports,"apply",{value:n}):e.exports.apply=n})),$indexOf=callBind(getIntrinsic("String.prototype.indexOf")),callBound=function(e,a){var p=getIntrinsic(e,!!a);return"function"==typeof p&&$indexOf(e,".prototype.")>-1?callBind(p):p},util_inspect=require$$0$3.inspect,hasMap="function"==typeof Map&&Map.prototype,mapSizeDescriptor=Object.getOwnPropertyDescriptor&&hasMap?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,mapSize=hasMap&&mapSizeDescriptor&&"function"==typeof mapSizeDescriptor.get?mapSizeDescriptor.get:null,mapForEach=hasMap&&Map.prototype.forEach,hasSet="function"==typeof Set&&Set.prototype,setSizeDescriptor=Object.getOwnPropertyDescriptor&&hasSet?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,setSize=hasSet&&setSizeDescriptor&&"function"==typeof setSizeDescriptor.get?setSizeDescriptor.get:null,setForEach=hasSet&&Set.prototype.forEach,hasWeakMap="function"==typeof WeakMap&&WeakMap.prototype,weakMapHas=hasWeakMap?WeakMap.prototype.has:null,hasWeakSet="function"==typeof WeakSet&&WeakSet.prototype,weakSetHas=hasWeakSet?WeakSet.prototype.has:null,hasWeakRef="function"==typeof WeakRef&&WeakRef.prototype,weakRefDeref=hasWeakRef?WeakRef.prototype.deref:null,booleanValueOf=Boolean.prototype.valueOf,objectToString=Object.prototype.toString,functionToString=Function.prototype.toString,match=String.prototype.match,bigIntValueOf="function"==typeof BigInt?BigInt.prototype.valueOf:null,gOPS=Object.getOwnPropertySymbols,symToString="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,hasShammedSymbols="function"==typeof Symbol&&"object"==typeof Symbol.iterator,isEnumerable=Object.prototype.propertyIsEnumerable,gPO=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),inspectCustom=util_inspect.custom,inspectSymbol=inspectCustom&&isSymbol(inspectCustom)?inspectCustom:null,toStringTag="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null,objectInspect=function e(a,p,t,d){var i=p||{};if(has$3(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(has$3(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var r=!has$3(i,"customInspect")||i.customInspect;if("boolean"!=typeof r&&"symbol"!==r)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(has$3(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');if(void 0===a)return"undefined";if(null===a)return"null";if("boolean"==typeof a)return a?"true":"false";if("string"==typeof a)return inspectString(a,i);if("number"==typeof a)return 0===a?1/0/a>0?"0":"-0":String(a);if("bigint"==typeof a)return String(a)+"n";var n=void 0===i.depth?5:i.depth;if(void 0===t&&(t=0),t>=n&&n>0&&"object"==typeof a)return isArray$3(a)?"[Array]":"[Object]";var s=getIndent(i,t);if(void 0===d)d=[];else if(indexOf(d,a)>=0)return"[Circular]";function o(a,p,r){if(p&&(d=d.slice()).push(p),r){var n={depth:i.depth};return has$3(i,"quoteStyle")&&(n.quoteStyle=i.quoteStyle),e(a,n,t+1,d)}return e(a,i,t+1,d)}if("function"==typeof a){var l=nameOf(a),m=arrObjKeys(a,o);return"[Function"+(l?": "+l:" (anonymous)")+"]"+(m.length>0?" { "+m.join(", ")+" }":"")}if(isSymbol(a)){var u=hasShammedSymbols?String(a).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):symToString.call(a);return"object"!=typeof a||hasShammedSymbols?u:markBoxed(u)}if(isElement(a)){for(var c="<"+String(a.nodeName).toLowerCase(),h=a.attributes||[],v=0;v<h.length;v++)c+=" "+h[v].name+"="+wrapQuotes(quote(h[v].value),"double",i);return c+=">",a.childNodes&&a.childNodes.length&&(c+="..."),c+="</"+String(a.nodeName).toLowerCase()+">"}if(isArray$3(a)){if(0===a.length)return"[]";var f=arrObjKeys(a,o);return s&&!singleLineValues(f)?"["+indentedJoin(f,s)+"]":"[ "+f.join(", ")+" ]"}if(isError(a)){var _=arrObjKeys(a,o);return 0===_.length?"["+String(a)+"]":"{ ["+String(a)+"] "+_.join(", ")+" }"}if("object"==typeof a&&r){if(inspectSymbol&&"function"==typeof a[inspectSymbol])return a[inspectSymbol]();if("symbol"!==r&&"function"==typeof a.inspect)return a.inspect()}if(isMap(a)){var y=[];return mapForEach.call(a,(function(e,p){y.push(o(p,a,!0)+" => "+o(e,a))})),collectionOf("Map",mapSize.call(a),y,s)}if(isSet(a)){var w=[];return setForEach.call(a,(function(e){w.push(o(e,a))})),collectionOf("Set",setSize.call(a),w,s)}if(isWeakMap(a))return weakCollectionOf("WeakMap");if(isWeakSet(a))return weakCollectionOf("WeakSet");if(isWeakRef(a))return weakCollectionOf("WeakRef");if(isNumber(a))return markBoxed(o(Number(a)));if(isBigInt(a))return markBoxed(o(bigIntValueOf.call(a)));if(isBoolean(a))return markBoxed(booleanValueOf.call(a));if(isString(a))return markBoxed(o(String(a)));if(!isDate(a)&&!isRegExp$1(a)){var g=arrObjKeys(a,o),b=gPO?gPO(a)===Object.prototype:a instanceof Object||a.constructor===Object,S=a instanceof Object?"":"null prototype",N=!b&&toStringTag&&Object(a)===a&&toStringTag in a?toStr(a).slice(8,-1):S?"Object":"",T=(b||"function"!=typeof a.constructor?"":a.constructor.name?a.constructor.name+" ":"")+(N||S?"["+[].concat(N||[],S||[]).join(": ")+"] ":"");return 0===g.length?T+"{}":s?T+"{"+indentedJoin(g,s)+"}":T+"{ "+g.join(", ")+" }"}return String(a)};function wrapQuotes(e,a,p){var t="double"===(p.quoteStyle||a)?'"':"'";return t+e+t}function quote(e){return String(e).replace(/"/g,""")}function isArray$3(e){return!("[object Array]"!==toStr(e)||toStringTag&&"object"==typeof e&&toStringTag in e)}function isDate(e){return!("[object Date]"!==toStr(e)||toStringTag&&"object"==typeof e&&toStringTag in e)}function isRegExp$1(e){return!("[object RegExp]"!==toStr(e)||toStringTag&&"object"==typeof e&&toStringTag in e)}function isError(e){return!("[object Error]"!==toStr(e)||toStringTag&&"object"==typeof e&&toStringTag in e)}function isString(e){return!("[object String]"!==toStr(e)||toStringTag&&"object"==typeof e&&toStringTag in e)}function isNumber(e){return!("[object Number]"!==toStr(e)||toStringTag&&"object"==typeof e&&toStringTag in e)}function isBoolean(e){return!("[object Boolean]"!==toStr(e)||toStringTag&&"object"==typeof e&&toStringTag in e)}function isSymbol(e){if(hasShammedSymbols)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!symToString)return!1;try{return symToString.call(e),!0}catch(e){}return!1}function isBigInt(e){if(!e||"object"!=typeof e||!bigIntValueOf)return!1;try{return bigIntValueOf.call(e),!0}catch(e){}return!1}var hasOwn=Object.prototype.hasOwnProperty||function(e){return e in this};function has$3(e,a){return hasOwn.call(e,a)}function toStr(e){return objectToString.call(e)}function nameOf(e){if(e.name)return e.name;var a=match.call(functionToString.call(e),/^function\s*([\w$]+)/);return a?a[1]:null}function indexOf(e,a){if(e.indexOf)return e.indexOf(a);for(var p=0,t=e.length;p<t;p++)if(e[p]===a)return p;return-1}function isMap(e){if(!mapSize||!e||"object"!=typeof e)return!1;try{mapSize.call(e);try{setSize.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}function isWeakMap(e){if(!weakMapHas||!e||"object"!=typeof e)return!1;try{weakMapHas.call(e,weakMapHas);try{weakSetHas.call(e,weakSetHas)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}function isWeakRef(e){if(!weakRefDeref||!e||"object"!=typeof e)return!1;try{return weakRefDeref.call(e),!0}catch(e){}return!1}function isSet(e){if(!setSize||!e||"object"!=typeof e)return!1;try{setSize.call(e);try{mapSize.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}function isWeakSet(e){if(!weakSetHas||!e||"object"!=typeof e)return!1;try{weakSetHas.call(e,weakSetHas);try{weakMapHas.call(e,weakMapHas)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}function isElement(e){return!(!e||"object"!=typeof e)&&("undefined"!=typeof HTMLElement&&e instanceof HTMLElement||"string"==typeof e.nodeName&&"function"==typeof e.getAttribute)}function inspectString(e,a){if(e.length>a.maxStringLength){var p=e.length-a.maxStringLength,t="... "+p+" more character"+(p>1?"s":"");return inspectString(e.slice(0,a.maxStringLength),a)+t}return wrapQuotes(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,lowbyte),"single",a)}function lowbyte(e){var a=e.charCodeAt(0),p={8:"b",9:"t",10:"n",12:"f",13:"r"}[a];return p?"\\"+p:"\\x"+(a<16?"0":"")+a.toString(16).toUpperCase()}function markBoxed(e){return"Object("+e+")"}function weakCollectionOf(e){return e+" { ? }"}function collectionOf(e,a,p,t){return e+" ("+a+") {"+(t?indentedJoin(p,t):p.join(", "))+"}"}function singleLineValues(e){for(var a=0;a<e.length;a++)if(indexOf(e[a],"\n")>=0)return!1;return!0}function getIndent(e,a){var p;if("\t"===e.indent)p="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;p=Array(e.indent+1).join(" ")}return{base:p,prev:Array(a+1).join(p)}}function indentedJoin(e,a){if(0===e.length)return"";var p="\n"+a.prev+a.base;return p+e.join(","+p)+"\n"+a.prev}function arrObjKeys(e,a){var p=isArray$3(e),t=[];if(p){t.length=e.length;for(var d=0;d<e.length;d++)t[d]=has$3(e,d)?a(e[d],e):""}var i,r="function"==typeof gOPS?gOPS(e):[];if(hasShammedSymbols){i={};for(var n=0;n<r.length;n++)i["$"+r[n]]=r[n]}for(var s in e)has$3(e,s)&&(p&&String(Number(s))===s&&s<e.length||hasShammedSymbols&&i["$"+s]instanceof Symbol||(/[^\w$]/.test(s)?t.push(a(s,e)+": "+a(e[s],e)):t.push(s+": "+a(e[s],e))));if("function"==typeof gOPS)for(var o=0;o<r.length;o++)isEnumerable.call(e,r[o])&&t.push("["+a(r[o])+"]: "+a(e[r[o]],e));return t}var $TypeError=getIntrinsic("%TypeError%"),$WeakMap=getIntrinsic("%WeakMap%",!0),$Map=getIntrinsic("%Map%",!0),$weakMapGet=callBound("WeakMap.prototype.get",!0),$weakMapSet=callBound("WeakMap.prototype.set",!0),$weakMapHas=callBound("WeakMap.prototype.has",!0),$mapGet=callBound("Map.prototype.get",!0),$mapSet=callBound("Map.prototype.set",!0),$mapHas=callBound("Map.prototype.has",!0),listGetNode=function(e,a){for(var p,t=e;null!==(p=t.next);t=p)if(p.key===a)return t.next=p.next,p.next=e.next,e.next=p,p},listGet=function(e,a){var p=listGetNode(e,a);return p&&p.value},listSet=function(e,a,p){var t=listGetNode(e,a);t?t.value=p:e.next={key:a,next:e.next,value:p}},listHas=function(e,a){return!!listGetNode(e,a)},sideChannel=function(){var e,a,p,t={assert:function(e){if(!t.has(e))throw new $TypeError("Side channel does not contain "+objectInspect(e))},get:function(t){if($WeakMap&&t&&("object"==typeof t||"function"==typeof t)){if(e)return $weakMapGet(e,t)}else if($Map){if(a)return $mapGet(a,t)}else if(p)return listGet(p,t)},has:function(t){if($WeakMap&&t&&("object"==typeof t||"function"==typeof t)){if(e)return $weakMapHas(e,t)}else if($Map){if(a)return $mapHas(a,t)}else if(p)return listHas(p,t);return!1},set:function(t,d){$WeakMap&&t&&("object"==typeof t||"function"==typeof t)?(e||(e=new $WeakMap),$weakMapSet(e,t,d)):$Map?(a||(a=new $Map),$mapSet(a,t,d)):(p||(p={key:{},next:null}),listSet(p,t,d))}};return t},replace=String.prototype.replace,percentTwenties=/%20/g,Format={RFC1738:"RFC1738",RFC3986:"RFC3986"},formats={default:Format.RFC3986,formatters:{RFC1738:function(e){return replace.call(e,percentTwenties,"+")},RFC3986:function(e){return String(e)}},RFC1738:Format.RFC1738,RFC3986:Format.RFC3986},has$2=Object.prototype.hasOwnProperty,isArray$2=Array.isArray,hexTable=function(){for(var e=[],a=0;a<256;++a)e.push("%"+((a<16?"0":"")+a.toString(16)).toUpperCase());return e}(),compactQueue=function(e){for(;e.length>1;){var a=e.pop(),p=a.obj[a.prop];if(isArray$2(p)){for(var t=[],d=0;d<p.length;++d)void 0!==p[d]&&t.push(p[d]);a.obj[a.prop]=t}}},arrayToObject=function(e,a){for(var p=a&&a.plainObjects?Object.create(null):{},t=0;t<e.length;++t)void 0!==e[t]&&(p[t]=e[t]);return p},merge=function e(a,p,t){if(!p)return a;if("object"!=typeof p){if(isArray$2(a))a.push(p);else{if(!a||"object"!=typeof a)return[a,p];(t&&(t.plainObjects||t.allowPrototypes)||!has$2.call(Object.prototype,p))&&(a[p]=!0)}return a}if(!a||"object"!=typeof a)return[a].concat(p);var d=a;return isArray$2(a)&&!isArray$2(p)&&(d=arrayToObject(a,t)),isArray$2(a)&&isArray$2(p)?(p.forEach((function(p,d){if(has$2.call(a,d)){var i=a[d];i&&"object"==typeof i&&p&&"object"==typeof p?a[d]=e(i,p,t):a.push(p)}else a[d]=p})),a):Object.keys(p).reduce((function(a,d){var i=p[d];return has$2.call(a,d)?a[d]=e(a[d],i,t):a[d]=i,a}),d)},assign=function(e,a){return Object.keys(a).reduce((function(e,p){return e[p]=a[p],e}),e)},decode$1=function(e,a,p){var t=e.replace(/\+/g," ");if("iso-8859-1"===p)return t.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(t)}catch(e){return t}},encode$1=function(e,a,p,t,d){if(0===e.length)return e;var i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===p)return escape(i).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var r="",n=0;n<i.length;++n){var s=i.charCodeAt(n);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||d===formats.RFC1738&&(40===s||41===s)?r+=i.charAt(n):s<128?r+=hexTable[s]:s<2048?r+=hexTable[192|s>>6]+hexTable[128|63&s]:s<55296||s>=57344?r+=hexTable[224|s>>12]+hexTable[128|s>>6&63]+hexTable[128|63&s]:(n+=1,s=65536+((1023&s)<<10|1023&i.charCodeAt(n)),r+=hexTable[240|s>>18]+hexTable[128|s>>12&63]+hexTable[128|s>>6&63]+hexTable[128|63&s])}return r},compact=function(e){for(var a=[{obj:{o:e},prop:"o"}],p=[],t=0;t<a.length;++t)for(var d=a[t],i=d.obj[d.prop],r=Object.keys(i),n=0;n<r.length;++n){var s=r[n],o=i[s];"object"==typeof o&&null!==o&&-1===p.indexOf(o)&&(a.push({obj:i,prop:s}),p.push(o))}return compactQueue(a),e},isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},isBuffer=function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},combine=function(e,a){return[].concat(e,a)},maybeMap=function(e,a){if(isArray$2(e)){for(var p=[],t=0;t<e.length;t+=1)p.push(a(e[t]));return p}return a(e)},utils$1={arrayToObject:arrayToObject,assign:assign,combine:combine,compact:compact,decode:decode$1,encode:encode$1,isBuffer:isBuffer,isRegExp:isRegExp,maybeMap:maybeMap,merge:merge},has$1=Object.prototype.hasOwnProperty,arrayPrefixGenerators={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,a){return e+"["+a+"]"},repeat:function(e){return e}},isArray$1=Array.isArray,split=String.prototype.split,push$1=Array.prototype.push,pushToArray=function(e,a){push$1.apply(e,isArray$1(a)?a:[a])},toISO=Date.prototype.toISOString,defaultFormat=formats.default,defaults$1={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:utils$1.encode,encodeValuesOnly:!1,format:defaultFormat,formatter:formats.formatters[defaultFormat],indices:!1,serializeDate:function(e){return toISO.call(e)},skipNulls:!1,strictNullHandling:!1},isNonNullishPrimitive=function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||"symbol"==typeof e||"bigint"==typeof e},sentinel={},stringify=function e(a,p,t,d,i,r,n,s,o,l,m,u,c,h,v){for(var f=a,_=v,y=0,w=!1;void 0!==(_=_.get(sentinel))&&!w;){var g=_.get(a);if(y+=1,void 0!==g){if(g===y)throw new RangeError("Cyclic object value");w=!0}void 0===_.get(sentinel)&&(y=0)}if("function"==typeof n?f=n(p,f):f instanceof Date?f=l(f):"comma"===t&&isArray$1(f)&&(f=utils$1.maybeMap(f,(function(e){return e instanceof Date?l(e):e}))),null===f){if(d)return r&&!c?r(p,defaults$1.encoder,h,"key",m):p;f=""}if(isNonNullishPrimitive(f)||utils$1.isBuffer(f)){if(r){var b=c?p:r(p,defaults$1.encoder,h,"key",m);if("comma"===t&&c){for(var S=split.call(String(f),","),N="",T=0;T<S.length;++T)N+=(0===T?"":",")+u(r(S[T],defaults$1.encoder,h,"value",m));return[u(b)+"="+N]}return[u(b)+"="+u(r(f,defaults$1.encoder,h,"value",m))]}return[u(p)+"="+u(String(f))]}var E,k=[];if(void 0===f)return k;if("comma"===t&&isArray$1(f))E=[{value:f.length>0?f.join(",")||null:void 0}];else if(isArray$1(n))E=n;else{var D=Object.keys(f);E=s?D.sort(s):D}for(var $=0;$<E.length;++$){var O=E[$],A="object"==typeof O&&void 0!==O.value?O.value:f[O];if(!i||null!==A){var R=isArray$1(f)?"function"==typeof t?t(p,O):p:p+(o?"."+O:"["+O+"]");v.set(a,y);var V=sideChannel();V.set(sentinel,v),pushToArray(k,e(A,R,t,d,i,r,n,s,o,l,m,u,c,h,V))}}return k},normalizeStringifyOptions=function(e){if(!e)return defaults$1;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var a=e.charset||defaults$1.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var p=formats.default;if(void 0!==e.format){if(!has$1.call(formats.formatters,e.format))throw new TypeError("Unknown format option provided.");p=e.format}var t=formats.formatters[p],d=defaults$1.filter;return("function"==typeof e.filter||isArray$1(e.filter))&&(d=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:defaults$1.addQueryPrefix,allowDots:void 0===e.allowDots?defaults$1.allowDots:!!e.allowDots,charset:a,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:defaults$1.charsetSentinel,delimiter:void 0===e.delimiter?defaults$1.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:defaults$1.encode,encoder:"function"==typeof e.encoder?e.encoder:defaults$1.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:defaults$1.encodeValuesOnly,filter:d,format:p,formatter:t,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:defaults$1.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:defaults$1.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:defaults$1.strictNullHandling}},stringify_1=function(e,a){var p,t=e,d=normalizeStringifyOptions(a);"function"==typeof d.filter?t=(0,d.filter)("",t):isArray$1(d.filter)&&(p=d.filter);var i,r=[];if("object"!=typeof t||null===t)return"";i=a&&a.arrayFormat in arrayPrefixGenerators?a.arrayFormat:a&&"indices"in a?a.indices?"indices":"repeat":"indices";var n=arrayPrefixGenerators[i];p||(p=Object.keys(t)),d.sort&&p.sort(d.sort);for(var s=sideChannel(),o=0;o<p.length;++o){var l=p[o];d.skipNulls&&null===t[l]||pushToArray(r,stringify(t[l],l,n,d.strictNullHandling,d.skipNulls,d.encode?d.encoder:null,d.filter,d.sort,d.allowDots,d.serializeDate,d.format,d.formatter,d.encodeValuesOnly,d.charset,s))}var m=r.join(d.delimiter),u=!0===d.addQueryPrefix?"?":"";return d.charsetSentinel&&("iso-8859-1"===d.charset?u+="utf8=%26%2310003%3B&":u+="utf8=%E2%9C%93&"),m.length>0?u+m:""},has=Object.prototype.hasOwnProperty,isArray=Array.isArray,defaults={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:utils$1.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},interpretNumericEntities=function(e){return e.replace(/&#(\d+);/g,(function(e,a){return String.fromCharCode(parseInt(a,10))}))},parseArrayValue=function(e,a){return e&&"string"==typeof e&&a.comma&&e.indexOf(",")>-1?e.split(","):e},isoSentinel="utf8=%26%2310003%3B",charsetSentinel="utf8=%E2%9C%93",parseValues=function(e,a){var p,t={},d=a.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=a.parameterLimit===1/0?void 0:a.parameterLimit,r=d.split(a.delimiter,i),n=-1,s=a.charset;if(a.charsetSentinel)for(p=0;p<r.length;++p)0===r[p].indexOf("utf8=")&&(r[p]===charsetSentinel?s="utf-8":r[p]===isoSentinel&&(s="iso-8859-1"),n=p,p=r.length);for(p=0;p<r.length;++p)if(p!==n){var o,l,m=r[p],u=m.indexOf("]="),c=-1===u?m.indexOf("="):u+1;-1===c?(o=a.decoder(m,defaults.decoder,s,"key"),l=a.strictNullHandling?null:""):(o=a.decoder(m.slice(0,c),defaults.decoder,s,"key"),l=utils$1.maybeMap(parseArrayValue(m.slice(c+1),a),(function(e){return a.decoder(e,defaults.decoder,s,"value")}))),l&&a.interpretNumericEntities&&"iso-8859-1"===s&&(l=interpretNumericEntities(l)),m.indexOf("[]=")>-1&&(l=isArray(l)?[l]:l),has.call(t,o)?t[o]=utils$1.combine(t[o],l):t[o]=l}return t},parseObject=function(e,a,p,t){for(var d=t?a:parseArrayValue(a,p),i=e.length-1;i>=0;--i){var r,n=e[i];if("[]"===n&&p.parseArrays)r=[].concat(d);else{r=p.plainObjects?Object.create(null):{};var s="["===n.charAt(0)&&"]"===n.charAt(n.length-1)?n.slice(1,-1):n,o=parseInt(s,10);p.parseArrays||""!==s?!isNaN(o)&&n!==s&&String(o)===s&&o>=0&&p.parseArrays&&o<=p.arrayLimit?(r=[])[o]=d:"__proto__"!==s&&(r[s]=d):r={0:d}}d=r}return d},parseKeys=function(e,a,p,t){if(e){var d=p.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,r=p.depth>0&&/(\[[^[\]]*])/.exec(d),n=r?d.slice(0,r.index):d,s=[];if(n){if(!p.plainObjects&&has.call(Object.prototype,n)&&!p.allowPrototypes)return;s.push(n)}for(var o=0;p.depth>0&&null!==(r=i.exec(d))&&o<p.depth;){if(o+=1,!p.plainObjects&&has.call(Object.prototype,r[1].slice(1,-1))&&!p.allowPrototypes)return;s.push(r[1])}return r&&s.push("["+d.slice(r.index)+"]"),parseObject(s,a,p,t)}},normalizeParseOptions=function(e){if(!e)return defaults;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var a=void 0===e.charset?defaults.charset:e.charset;return{allowDots:void 0===e.allowDots?defaults.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:defaults.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:defaults.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:defaults.arrayLimit,charset:a,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:defaults.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:defaults.comma,decoder:"function"==typeof e.decoder?e.decoder:defaults.decoder,delimiter:"string"==typeof e.delimiter||utils$1.isRegExp(e.delimiter)?e.delimiter:defaults.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:defaults.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:defaults.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:defaults.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:defaults.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:defaults.strictNullHandling}},parse$4=function(e,a){var p=normalizeParseOptions(a);if(""===e||null==e)return p.plainObjects?Object.create(null):{};for(var t="string"==typeof e?parseValues(e,p):e,d=p.plainObjects?Object.create(null):{},i=Object.keys(t),r=0;r<i.length;++r){var n=i[r],s=parseKeys(n,t[n],p,"string"==typeof e);d=utils$1.merge(d,s,p)}return!0===p.allowSparse?d:utils$1.compact(d)},lib$3={formats:formats,parse:parse$4,stringify:stringify_1};function account(e){if(e)try{return Object.assign(Object.assign({},e),{raw:()=>e,buying_power:number(e.buying_power),regt_buying_power:number(e.regt_buying_power),daytrading_buying_power:number(e.daytrading_buying_power),cash:number(e.cash),created_at:new Date(e.created_at),portfolio_value:number(e.portfolio_value),multiplier:number(e.multiplier),equity:number(e.equity),last_equity:number(e.last_equity),long_market_value:number(e.long_market_value),short_market_value:number(e.short_market_value),initial_margin:number(e.initial_margin),maintenance_margin:number(e.maintenance_margin),last_maintenance_margin:number(e.last_maintenance_margin),sma:number(e.sma),status:e.status})}catch(e){throw new Error(`Account parsing failed. ${e.message}`)}}function clock(e){if(e)try{return{raw:()=>e,timestamp:new Date(e.timestamp),is_open:e.is_open,next_open:new Date(e.next_open),next_close:new Date(e.next_close)}}catch(e){throw new Error(`Order parsing failed. ${e.message}`)}}function latestTrade(e){if(e)try{return Object.assign(Object.assign({},e),{raw:()=>e,trade:Object.assign(Object.assign({},e.trade),{t:new Date(e.trade.t)})})}catch(e){throw new Error(`Latest trade parsing failed. ${e.message}`)}}function order(e){if(e)try{return Object.assign(Object.assign({},e),{raw:()=>e,created_at:new Date(e.created_at),updated_at:new Date(e.updated_at),submitted_at:new Date(e.submitted_at),filled_at:new Date(e.filled_at),expired_at:new Date(e.expired_at),canceled_at:new Date(e.canceled_at),failed_at:new Date(e.failed_at),replaced_at:new Date(e.replaced_at),qty:number(e.qty),filled_qty:number(e.filled_qty),type:e.type,side:e.side,time_in_force:e.time_in_force,limit_price:number(e.limit_price),stop_price:number(e.stop_price),filled_avg_price:number(e.filled_avg_price),status:e.status,legs:orders(e.legs),trail_price:number(e.trail_price),trail_percent:number(e.trail_percent),hwm:number(e.hwm),order_class:e.order_class})}catch(e){throw new Error(`Order parsing failed. ${e.message}`)}}function orders(e){return e?e.map((e=>order(e))):void 0}function canceled_order(e){if(!e)return;let a=e.body;delete e.body;try{return Object.assign(Object.assign({},e),{order:Object.assign(Object.assign({},a),{raw:()=>a,created_at:new Date(a.created_at),updated_at:new Date(a.updated_at),submitted_at:new Date(a.submitted_at),filled_at:new Date(a.filled_at),expired_at:new Date(a.expired_at),canceled_at:new Date(a.canceled_at),failed_at:new Date(a.failed_at),replaced_at:new Date(a.replaced_at),qty:number(a.qty),filled_qty:number(a.filled_qty),type:a.type,side:a.side,time_in_force:a.time_in_force,limit_price:number(a.limit_price),stop_price:number(a.stop_price),filled_avg_price:number(a.filled_avg_price),status:a.status,legs:orders(a.legs),trail_price:number(a.trail_price),trail_percent:number(a.trail_percent),hwm:number(a.hwm),order_class:a.order_class})})}catch(e){throw new Error(`Order parsing failed. ${e.message}`)}}function canceled_orders(e){return e?e.map((e=>canceled_order(e))):void 0}function position(e){if(e)try{return Object.assign(Object.assign({},e),{raw:()=>e,avg_entry_price:number(e.avg_entry_price),qty:number(e.qty),side:e.side,market_value:number(e.market_value),cost_basis:number(e.cost_basis),unrealized_pl:number(e.unrealized_pl),unrealized_plpc:number(e.unrealized_plpc),unrealized_intraday_pl:number(e.unrealized_intraday_pl),unrealized_intraday_plpc:number(e.unrealized_intraday_plpc),current_price:number(e.current_price),lastday_price:number(e.lastday_price),change_today:number(e.change_today)})}catch(e){throw new Error(`Position parsing failed. ${e.message}`)}}function positions(e){return e?e.map((e=>position(e))):void 0}function tradeActivity(e){if(e)try{return Object.assign(Object.assign({},e),{raw:()=>e,cum_qty:number(e.cum_qty),leaves_qty:number(e.leaves_qty),price:number(e.price),qty:number(e.qty),side:e.side,type:e.type})}catch(e){throw new Error(`TradeActivity parsing failed. ${e.message}`)}}function nonTradeActivity(e){if(e)try{return Object.assign(Object.assign({},e),{raw:()=>e,net_amount:number(e.net_amount),qty:number(e.qty),per_share_amount:number(e.per_share_amount)})}catch(e){throw new Error(`NonTradeActivity parsing failed. ${e.message}`)}}function activities(e){if(e)try{return e.map((e=>"FILL"===e.activity_type?tradeActivity(e):nonTradeActivity(e)))}catch(e){throw new Error(`Activity parsing failed. ${e.message}`)}}function pageOfTrades(e){if(e)try{return{raw:()=>e,trades:(null==e.trades?[]:e.trades).map((e=>Object.assign(Object.assign({raw:()=>e},e),{t:new Date(e.t)}))),symbol:e.symbol,next_page_token:e.next_page_token}}catch(e){throw new Error(`PageOfTrades parsing failed "${e.message}"`)}}function pageOfQuotes(e){if(e)try{return{raw:()=>e,quotes:(null==e.quotes?[]:e.quotes).map((e=>Object.assign(Object.assign({raw:()=>e},e),{t:new Date(e.t)}))),symbol:e.symbol,next_page_token:e.next_page_token}}catch(e){throw new Error(`PageOfTrades parsing failed "${e.message}"`)}}function pageOfBars(e){if(e)try{return{raw:()=>e,bars:(null==e.bars?[]:e.bars).map((e=>Object.assign(Object.assign({raw:()=>e},e),{t:new Date(e.t)}))),symbol:e.symbol,next_page_token:e.next_page_token}}catch(e){throw new Error(`PageOfTrades parsing failed "${e.message}"`)}}function snapshot(e){if(e)try{return Object.assign(Object.assign({},e),{raw:()=>e,latestTrade:e.latestTrade?Object.assign(Object.assign({},e.latestTrade),{t:new Date(e.latestTrade.t)}):null,latestQuote:e.latestQuote?Object.assign(Object.assign({},e.latestQuote),{t:new Date(e.latestQuote.t)}):null,minuteBar:e.minuteBar?Object.assign(Object.assign({},e.minuteBar),{t:new Date(e.minuteBar.t)}):null,dailyBar:e.dailyBar?Object.assign(Object.assign({},e.dailyBar),{t:new Date(e.dailyBar.t)}):null,prevDailyBar:e.prevDailyBar?Object.assign(Object.assign({},e.prevDailyBar),{t:new Date(e.prevDailyBar.t)}):null})}catch(e){throw new Error(`Snapshot parsing failed "${e.message}"`)}}function snapshots(e){let a={};for(let[p,t]of Object.entries(e))a[p]=snapshot(t);return a}function number(e){if(void 0===e||null==e)return e;const a=parseFloat(e);return Number.isNaN(a)?null:a}function trade_update(e){if(e)return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({raw:()=>e,event:e.event,execution_id:e.execution_id,order:order(e.order)},e.event_id&&{event_id:number(e.event_id)}),e.at&&{at:new Date(e.at)}),e.timestamp&&{timestamp:new Date(e.timestamp)}),e.position_qty&&{position_qty:number(e.position_qty)}),e.price&&{price:number(e.price)}),e.qty&&{qty:number(e.qty)})}var parse$3={account:account,activities:activities,clock:clock,nonTradeActivity:nonTradeActivity,order:order,orders:orders,canceled_orders:canceled_orders,position:position,positions:positions,tradeActivity:tradeActivity,pageOfTrades:pageOfTrades,pageOfQuotes:pageOfQuotes,pageOfBars:pageOfBars,snapshot:snapshot,snapshots:snapshots,trade_update:trade_update,latestTrade:latestTrade};function unfetch_module(e,a){return a=a||{},new Promise((function(p,t){var d=new XMLHttpRequest,i=[],r=[],n={},s=function(){return{ok:2==(d.status/100|0),statusText:d.statusText,status:d.status,url:d.responseURL,text:function(){return Promise.resolve(d.responseText)},json:function(){return Promise.resolve(d.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([d.response]))},clone:s,headers:{keys:function(){return i},entries:function(){return r},get:function(e){return n[e.toLowerCase()]},has:function(e){return e.toLowerCase()in n}}}};for(var o in d.open(a.method||"get",e,!0),d.onload=function(){d.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,a,p){i.push(a=a.toLowerCase()),r.push([a,p]),n[a]=n[a]?n[a]+","+p:p})),p(s())},d.onerror=t,d.withCredentials="include"==a.credentials,a.headers)d.setRequestHeader(o,a.headers[o]);d.send(a.body||null)}))}var unfetch_module$1=Object.freeze({__proto__:null,default:unfetch_module}),conversions={},lib$2=conversions;function sign(e){return e<0?-1:1}function evenRound(e){return e%1==.5&&0==(1&e)?Math.floor(e):Math.round(e)}function createNumberConversion(e,a){a.unsigned||--e;const p=a.unsigned?0:-Math.pow(2,e),t=Math.pow(2,e)-1,d=a.moduloBitLength?Math.pow(2,a.moduloBitLength):Math.pow(2,e),i=a.moduloBitLength?Math.pow(2,a.moduloBitLength-1):Math.pow(2,e-1);return function(e,r){r||(r={});let n=+e;if(r.enforceRange){if(!Number.isFinite(n))throw new TypeError("Argument is not a finite number");if(n=sign(n)*Math.floor(Math.abs(n)),n<p||n>t)throw new TypeError("Argument is not in byte range");return n}if(!isNaN(n)&&r.clamp)return n=evenRound(n),n<p&&(n=p),n>t&&(n=t),n;if(!Number.isFinite(n)||0===n)return 0;if(n=sign(n)*Math.floor(Math.abs(n)),n%=d,!a.unsigned&&n>=i)return n-d;if(a.unsigned)if(n<0)n+=d;else if(-0===n)return 0;return n}}conversions.void=function(){},conversions.boolean=function(e){return!!e},conversions.byte=createNumberConversion(8,{unsigned:!1}),conversions.octet=createNumberConversion(8,{unsigned:!0}),conversions.short=createNumberConversion(16,{unsigned:!1}),conversions["unsigned short"]=createNumberConversion(16,{unsigned:!0}),conversions.long=createNumberConversion(32,{unsigned:!1}),conversions["unsigned long"]=createNumberConversion(32,{unsigned:!0}),conversions["long long"]=createNumberConversion(32,{unsigned:!1,moduloBitLength:64}),conversions["unsigned long long"]=createNumberConversion(32,{unsigned:!0,moduloBitLength:64}),conversions.double=function(e){const a=+e;if(!Number.isFinite(a))throw new TypeError("Argument is not a finite floating-point value");return a},conversions["unrestricted double"]=function(e){const a=+e;if(isNaN(a))throw new TypeError("Argument is NaN");return a},conversions.float=conversions.double,conversions["unrestricted float"]=conversions["unrestricted double"],conversions.DOMString=function(e,a){return a||(a={}),a.treatNullAsEmptyString&&null===e?"":String(e)},conversions.ByteString=function(e,a){const p=String(e);let t;for(let e=0;void 0!==(t=p.codePointAt(e));++e)if(t>255)throw new TypeError("Argument is not a valid bytestring");return p},conversions.USVString=function(e){const a=String(e),p=a.length,t=[];for(let e=0;e<p;++e){const d=a.charCodeAt(e);if(d<55296||d>57343)t.push(String.fromCodePoint(d));else if(56320<=d&&d<=57343)t.push(String.fromCodePoint(65533));else if(e===p-1)t.push(String.fromCodePoint(65533));else{const p=a.charCodeAt(e+1);if(56320<=p&&p<=57343){const a=1023&d,i=1023&p;t.push(String.fromCodePoint(65536+1024*a+i)),++e}else t.push(String.fromCodePoint(65533))}}return t.join("")},conversions.Date=function(e,a){if(!(e instanceof Date))throw new TypeError("Argument is not a Date object");if(!isNaN(e))return e},conversions.RegExp=function(e,a){return e instanceof RegExp||(e=new RegExp(e)),e};var utils=createCommonjsModule((function(e){e.exports.mixin=function(e,a){const p=Object.getOwnPropertyNames(a);for(let t=0;t<p.length;++t)Object.defineProperty(e,p[t],Object.getOwnPropertyDescriptor(a,p[t]))},e.exports.wrapperSymbol=Symbol("wrapper"),e.exports.implSymbol=Symbol("impl"),e.exports.wrapperForImpl=function(a){return a[e.exports.wrapperSymbol]},e.exports.implForWrapper=function(a){return a[e.exports.implSymbol]}}));const maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\0-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error$1(e){throw new RangeError(errors[e])}function map(e,a){const p=[];let t=e.length;for(;t--;)p[t]=a(e[t]);return p}function mapDomain(e,a){const p=e.split("@");let t="";p.length>1&&(t=p[0]+"@",e=p[1]);return t+map((e=e.replace(regexSeparators,".")).split("."),a).join(".")}function ucs2decode(e){const a=[];let p=0;const t=e.length;for(;p<t;){const d=e.charCodeAt(p++);if(d>=55296&&d<=56319&&p<t){const t=e.charCodeAt(p++);56320==(64512&t)?a.push(((1023&d)<<10)+(1023&t)+65536):(a.push(d),p--)}else a.push(d)}return a}const ucs2encode=e=>String.fromCodePoint(...e),basicToDigit=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:base},digitToBasic=function(e,a){return e+22+75*(e<26)-((0!=a)<<5)},adapt=function(e,a,p){let t=0;for(e=p?floor(e/damp):e>>1,e+=floor(e/a);e>baseMinusTMin*tMax>>1;t+=base)e=floor(e/baseMinusTMin);return floor(t+(baseMinusTMin+1)*e/(e+skew))},decode=function(e){const a=[],p=e.length;let t=0,d=initialN,i=initialBias,r=e.lastIndexOf(delimiter);r<0&&(r=0);for(let p=0;p<r;++p)e.charCodeAt(p)>=128&&error$1("not-basic"),a.push(e.charCodeAt(p));for(let n=r>0?r+1:0;n<p;){let r=t;for(let a=1,d=base;;d+=base){n>=p&&error$1("invalid-input");const r=basicToDigit(e.charCodeAt(n++));(r>=base||r>floor((maxInt-t)/a))&&error$1("overflow"),t+=r*a;const s=d<=i?tMin:d>=i+tMax?tMax:d-i;if(r<s)break;const o=base-s;a>floor(maxInt/o)&&error$1("overflow"),a*=o}const s=a.length+1;i=adapt(t-r,s,0==r),floor(t/s)>maxInt-d&&error$1("overflow"),d+=floor(t/s),t%=s,a.splice(t++,0,d)}return String.fromCodePoint(...a)},encode=function(e){const a=[];let p=(e=ucs2decode(e)).length,t=initialN,d=0,i=initialBias;for(const p of e)p<128&&a.push(stringFromCharCode(p));let r=a.length,n=r;for(r&&a.push(delimiter);n<p;){let p=maxInt;for(const a of e)a>=t&&a<p&&(p=a);const s=n+1;p-t>floor((maxInt-d)/s)&&error$1("overflow"),d+=(p-t)*s,t=p;for(const p of e)if(p<t&&++d>maxInt&&error$1("overflow"),p==t){let e=d;for(let p=base;;p+=base){const t=p<=i?tMin:p>=i+tMax?tMax:p-i;if(e<t)break;const d=e-t,r=base-t;a.push(stringFromCharCode(digitToBasic(t+d%r,0))),e=floor(d/r)}a.push(stringFromCharCode(digitToBasic(e,0))),i=adapt(d,s,n==r),d=0,++n}++d,++t}return a.join("