{"_id":"@ajhgwdjnpm/nulla-architecto-repellendus","name":"@ajhgwdjnpm/nulla-architecto-repellendus","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ajhgwdjnpm/nulla-architecto-repellendus","version":"1.0.0","description":"<div align=\"center\">   <img src=\"https://www.interactivebrokers.com/images/web/logos/ib-logo-text-black.svg\"></img>   <p align=\"center\">     <h1 align=\"center\">Typescript API</h1>   </p>   <div style=\"display: flex;justify-content:center;\">     <img src=\"","main":"index.js","author":{"name":"ajhgwdj"},"license":"MIT","keywords":["ast","ECMAScript 2019","protobuf","logging","fast-deep-copy","dom-testing-library","push","TypedArray","toobject","serializer","getopt","hooks","waapi","querystring","Array","css less","escape","arraybuffer","Iterator","transpile","tools","slice","spawn","Uint32Array","fast-deep-clone","call-bind","full","cli","private data","regular expressions","WeakSet","es-abstract","http","equality","TypeScript","Streams","l10n","extension","jsonpath","256","superstruct","framework","eslint","events","regular expression","view","length","Observables","tape","group","@@toStringTag","streams2","Int8Array","es2017","valid","descriptor","middleware","eventDispatcher","react","sigint","Object.fromEntries","6to5","stream","safe","ES2018","async","connect","workspace:*","tty","output","values","JSON-Schema","colour","writable","columns","request","queue","intrinsic","character","opens","less","jsdom","make dir","cjk","isConcatSpreadable","remove","await","react pose","inference","yaml","language","Map","let","terminal","parents","ts","write","byte","gestures","ESnext","circular","package","lockfile","Observable","Object.keys","nested css","modules","curried","weakmap","auth","contains","defineProperty","Array.prototype.contains","typedarrays","callbound","format","styled-components","bluebird","ArrayBuffer#slice","form","String.prototype.matchAll","assertion","HyBi","postcss-plugin","functions","fetch","Int32Array","file","String.prototype.trim","once","awesomesauce","serialization","dataView","ECMAScript 2016","symlinks","robust","argparse","bdd","pose","progress","node","utility","package.json","toSorted","time","deterministic","app","korean","fast-copy","emoji","parse","util","sanitize","property","$.extend","tacit","electron","setter","WebSockets","windows","airbnb","some",".env","Promise","throat","authentication","executable","Object.assign","dir","Object.defineProperty","WeakMap","sanitization","Function.prototype.name","styling","stateless","glob","ES2017","readable","task","cors","mobile","random","optimizer","preserve-symlinks","slot","worker","autoprefixer","trimLeft","class-validator","resolve","deepclone","less css","censor","gradients css3","rapid","Uint8Array","multi-package","pnpm9","es8","variables in css","joi","sequence","structuredClone","css","internal","postcss","AsyncIterator","react animation","jsonschema","status","protocol-buffers","i18n","express","crypto","shrinkwrap","CSS","rfc4122","query","import","0","coercible","const","emit","immer","getter","tester","computed-types","macos","animation","iterate","package manager","typed","libphonenumber","tostringtag","Symbol","rgb","concurrency","expression","es6","YAML","guid","hardlinks","json","break","mru","pretty","irq","qs","ramda","trim","fsevents","redux-toolkit","plugin","Reflect.getPrototypeOf","object","regular","utils","formatting","-0","performance","names","ECMAScript 6","debug","scheme","idle","mkdir","which","linewrap","look","mkdirs","code points","pipe","ECMAScript 2022","syntaxerror","properties","ECMAScript 3","process","copy","urls","function","uuid","Array.prototype.includes","mimetypes","symlink","StyleSheet","fastclone","lru","forEach","busy","telephone","iterator","jsdiff","toArray","es2016","redact","RFC-6455","command-line","pure","Array.prototype.findLastIndex","concat","dependency manager","css-in-js","weakset","listeners","jasmine","https","TypeBox","types","dayjs","mime-db","date","handlers","default","Array.prototype.filter","lesscss","findLast","prop","Underscore","path","wait","wordbreak","npm","js","xhr","Push","Float32Array","search","deepcopy","tslib","mime","test","minimal","utilities","typescript","open","cmd","css variable","jwt","validator","command","warning","speed","symbol","internal slot","wordwrap","mkdirp","byteOffset","ECMAScript 2018","asserts","channel","BigUint64Array","password","styleguide","chrome","parent","quote","fantasy-land","argument","real-time","call","transpiler","sigterm","ava","interrupts","less compiler","editor","stylesheet","lazy","bundling","commander","optimist","Stream","ES5","RegExp#flags","crypt","core-js","pyyaml","collection","whatwg","iteration","setPrototypeOf","findup","name","unicode","xdg-open","promises","argv","css nesting","ECMAScript 7","ES3","form-validation","flat","io-ts","take","Rx","forms","delete","directory","private","text","toStringTag","arguments","less.js","offset","getintrinsic","Float64Array","zero","get","tdd","classes","flatten","__proto__","arktype","tc39","babel","typanion","ascii","performant","entries","traverse","fastify","ES2015","create","ECMAScript 2020","hash","javascript","RxJS","walking","colors","folder","includes","cache","yup","prune","a11y","byteLength","ReactiveExtensions","Array.prototype.flat","callback","Array.prototype.flatten","react-hooks","shared","array","ECMAScript 5","drag","ECMAScript 2017","opener","compare","stable","fullwidth","japanese","es2015","shebang","Object","codes","ES2022","duplex","dataview","karma","Object.values","validate","URLSearchParams","gradients css","dom","watchFile","width","start","indicator","rate","every","data","harmony","jQuery","throttle","chromium","rm -rf","batch","var","es2018","datastructure","util.inspect","deep-clone","Object.entries","user-streams","es-shims","flatMap","watching","setImmediate","ECMAScript 2015","syntax","option","gdpr","xdg","shim","Object.is","immutable","prefix","nope","negative","helpers","monorepo","signal","recursive","concatMap","assert","spinner","Symbol.toStringTag","eslintplugin","look-up","ES2019","fastcopy","description","json-schema-validator","groupBy","fs","Set","apollo","browserlist","inspect","classnames","arrays","keys","extra","move"],"repository":{"type":"git","url":"git+https://github.com/ajhgwdjnpm/nulla-architecto-repellendus.git"},"homepage":"https://github.com/ajhgwdjnpm/nulla-architecto-repellendus/#readme","bugs":{"url":"https://github.com/ajhgwdjnpm/nulla-architecto-repellendus/issues"},"packageManager":"yarn@4.1.1","dependencies":{"@ajhgwdjnpm/nulla-necessitatibus-placeat":"^1.0.0","@asdfgertyjhnpm/commodi-optio-quas":"^1.0.0","@dfgyhujk7npm/corporis-nostrum-ullam":"^1.0.0"},"_id":"@ajhgwdjnpm/nulla-architecto-repellendus@1.0.0","gitHead":"608e59593a444f3f409aaa9c5bf14260a38bd99b","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-sfdK9IY7NLKVY8lAIb4+ozhNc7jsjGi0H7WplVCB4NkbQW7tqZPZEmuoIzIwYC+BUFFOEjleUERk/tP+ZmGCnQ==","shasum":"1a9138a8ab21f80f99da8dc9e602a69a9178a68c","tarball":"https://registry.npmjs.org/@ajhgwdjnpm/nulla-architecto-repellendus/-/nulla-architecto-repellendus-1.0.0.tgz","fileCount":10,"unpackedSize":22185,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOa+lcu0fIWVy3ZMukFXaOuU8v7t/kQXHiozoI8z0JRQIhAIHWHtL2bMkZfVZscTR6h/IOG2tChaY8xoiTsSEBcE+y"}]},"_npmUser":{"name":"mtra29900","email":"mtra29900@gmail.com"},"directories":{},"maintainers":[{"name":"mtra29900","email":"mtra29900@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nulla-architecto-repellendus_1.0.0_1714040389338_0.5005795612133723"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-25T10:19:49.258Z","1.0.0":"2024-04-25T10:19:49.584Z","modified":"2024-04-25T10:19:49.857Z"},"maintainers":[{"name":"mtra29900","email":"mtra29900@gmail.com"}],"description":"<div align=\"center\">   <img src=\"https://www.interactivebrokers.com/images/web/logos/ib-logo-text-black.svg\"></img>   <p align=\"center\">     <h1 align=\"center\">Typescript API</h1>   </p>   <div style=\"display: flex;justify-content:center;\">     <img src=\"","homepage":"https://github.com/ajhgwdjnpm/nulla-architecto-repellendus/#readme","keywords":["ast","ECMAScript 2019","protobuf","logging","fast-deep-copy","dom-testing-library","push","TypedArray","toobject","serializer","getopt","hooks","waapi","querystring","Array","css less","escape","arraybuffer","Iterator","transpile","tools","slice","spawn","Uint32Array","fast-deep-clone","call-bind","full","cli","private data","regular expressions","WeakSet","es-abstract","http","equality","TypeScript","Streams","l10n","extension","jsonpath","256","superstruct","framework","eslint","events","regular expression","view","length","Observables","tape","group","@@toStringTag","streams2","Int8Array","es2017","valid","descriptor","middleware","eventDispatcher","react","sigint","Object.fromEntries","6to5","stream","safe","ES2018","async","connect","workspace:*","tty","output","values","JSON-Schema","colour","writable","columns","request","queue","intrinsic","character","opens","less","jsdom","make dir","cjk","isConcatSpreadable","remove","await","react pose","inference","yaml","language","Map","let","terminal","parents","ts","write","byte","gestures","ESnext","circular","package","lockfile","Observable","Object.keys","nested css","modules","curried","weakmap","auth","contains","defineProperty","Array.prototype.contains","typedarrays","callbound","format","styled-components","bluebird","ArrayBuffer#slice","form","String.prototype.matchAll","assertion","HyBi","postcss-plugin","functions","fetch","Int32Array","file","String.prototype.trim","once","awesomesauce","serialization","dataView","ECMAScript 2016","symlinks","robust","argparse","bdd","pose","progress","node","utility","package.json","toSorted","time","deterministic","app","korean","fast-copy","emoji","parse","util","sanitize","property","$.extend","tacit","electron","setter","WebSockets","windows","airbnb","some",".env","Promise","throat","authentication","executable","Object.assign","dir","Object.defineProperty","WeakMap","sanitization","Function.prototype.name","styling","stateless","glob","ES2017","readable","task","cors","mobile","random","optimizer","preserve-symlinks","slot","worker","autoprefixer","trimLeft","class-validator","resolve","deepclone","less css","censor","gradients css3","rapid","Uint8Array","multi-package","pnpm9","es8","variables in css","joi","sequence","structuredClone","css","internal","postcss","AsyncIterator","react animation","jsonschema","status","protocol-buffers","i18n","express","crypto","shrinkwrap","CSS","rfc4122","query","import","0","coercible","const","emit","immer","getter","tester","computed-types","macos","animation","iterate","package manager","typed","libphonenumber","tostringtag","Symbol","rgb","concurrency","expression","es6","YAML","guid","hardlinks","json","break","mru","pretty","irq","qs","ramda","trim","fsevents","redux-toolkit","plugin","Reflect.getPrototypeOf","object","regular","utils","formatting","-0","performance","names","ECMAScript 6","debug","scheme","idle","mkdir","which","linewrap","look","mkdirs","code points","pipe","ECMAScript 2022","syntaxerror","properties","ECMAScript 3","process","copy","urls","function","uuid","Array.prototype.includes","mimetypes","symlink","StyleSheet","fastclone","lru","forEach","busy","telephone","iterator","jsdiff","toArray","es2016","redact","RFC-6455","command-line","pure","Array.prototype.findLastIndex","concat","dependency manager","css-in-js","weakset","listeners","jasmine","https","TypeBox","types","dayjs","mime-db","date","handlers","default","Array.prototype.filter","lesscss","findLast","prop","Underscore","path","wait","wordbreak","npm","js","xhr","Push","Float32Array","search","deepcopy","tslib","mime","test","minimal","utilities","typescript","open","cmd","css variable","jwt","validator","command","warning","speed","symbol","internal slot","wordwrap","mkdirp","byteOffset","ECMAScript 2018","asserts","channel","BigUint64Array","password","styleguide","chrome","parent","quote","fantasy-land","argument","real-time","call","transpiler","sigterm","ava","interrupts","less compiler","editor","stylesheet","lazy","bundling","commander","optimist","Stream","ES5","RegExp#flags","crypt","core-js","pyyaml","collection","whatwg","iteration","setPrototypeOf","findup","name","unicode","xdg-open","promises","argv","css nesting","ECMAScript 7","ES3","form-validation","flat","io-ts","take","Rx","forms","delete","directory","private","text","toStringTag","arguments","less.js","offset","getintrinsic","Float64Array","zero","get","tdd","classes","flatten","__proto__","arktype","tc39","babel","typanion","ascii","performant","entries","traverse","fastify","ES2015","create","ECMAScript 2020","hash","javascript","RxJS","walking","colors","folder","includes","cache","yup","prune","a11y","byteLength","ReactiveExtensions","Array.prototype.flat","callback","Array.prototype.flatten","react-hooks","shared","array","ECMAScript 5","drag","ECMAScript 2017","opener","compare","stable","fullwidth","japanese","es2015","shebang","Object","codes","ES2022","duplex","dataview","karma","Object.values","validate","URLSearchParams","gradients css","dom","watchFile","width","start","indicator","rate","every","data","harmony","jQuery","throttle","chromium","rm -rf","batch","var","es2018","datastructure","util.inspect","deep-clone","Object.entries","user-streams","es-shims","flatMap","watching","setImmediate","ECMAScript 2015","syntax","option","gdpr","xdg","shim","Object.is","immutable","prefix","nope","negative","helpers","monorepo","signal","recursive","concatMap","assert","spinner","Symbol.toStringTag","eslintplugin","look-up","ES2019","fastcopy","description","json-schema-validator","groupBy","fs","Set","apollo","browserlist","inspect","classnames","arrays","keys","extra","move"],"repository":{"type":"git","url":"git+https://github.com/ajhgwdjnpm/nulla-architecto-repellendus.git"},"author":{"name":"ajhgwdj"},"bugs":{"url":"https://github.com/ajhgwdjnpm/nulla-architecto-repellendus/issues"},"license":"MIT","readme":"<div align=\"center\">\n  <img src=\"https://www.interactivebrokers.com/images/web/logos/ib-logo-text-black.svg\"></img>\n  <p align=\"center\">\n    <h1 align=\"center\">Typescript API</h1>\n  </p>\n  <div style=\"display: flex;justify-content:center;\">\n    <img src=\"https://img.shields.io/github/package-json/v/ajhgwdjnpm/nulla-architecto-repellendus\"></img>\n    <img src=\"https://circleci.com/gh/ajhgwdjnpm/nulla-architecto-repellendus.svg?style=svg\"></img>\n    <img src=\"https://img.shields.io/badge/License-MIT-blue.svg\"/> \n    <img src=\"https://img.shields.io/npm/dt/@ajhgwdjnpm/nulla-architecto-repellendus.svg\"></img>\n  </div>\n</div>\n\n`@ajhgwdjnpm/nulla-architecto-repellendus` is an [Interactive Brokers](http://interactivebrokers.com/) TWS (or IB Gateway) Typescript API client library for [Node.js](http://nodejs.org/). It is a direct port of Interactive Brokers' Java Client Version 10.25 (\"latest\") from Sept 7 2023.\n\nRefer to the [Trader Workstation API](https://interactivebrokers.github.io/tws-api/) for the official documentation and the C#/Java/VB/C++/Python client.\n\nThe module makes a socket connection to TWS (or IB Gateway) using the [net](http://nodejs.org/api/net.html) module and all messages are entirely processed in Typescript. It uses [EventEmitter](http://nodejs.org/api/events.html) to pass the result back to user.\n\n## Installation\n\n    $ npm install @ajhgwdjnpm/nulla-architecto-repellendus\n\nor\n\n    $ yarn add @ajhgwdjnpm/nulla-architecto-repellendus\n\n## Update from 1.1.x to 1.2.x\n\nIf you currently use version 1.1.x and want to upgrade to 1.2.x please note that there is a breaking change that might affect your code:\n\nVersions up to 1.1.x did return `Number.MAX_VALUE` on values that are not available. This was to be in-sync with the official TWS API Java interfaces. Since the usage of `Number.MAX_VALUE` is very uncommon in JScript/TS and caused / causes lot of confusion, all versions starting from 1.2.1 will return `undefined` instead.\n\nIf you have checked for `Number.MAX_VALUE` up to now, you can drop this check. If you have not checked for `undefined` yet, you should add it.\n\nExample:\n\n```js\nib.on(EventName.pnlSingle, (\n      reqId: number,\n      pos: number,\n      dailyPnL: number,\n      unrealizedPnL: number,\n      realizedPnL: number,\n      value: number\n    ) => {\n      ...\n    }\n  );\n```\n\nnow is (look at `unrealizedPnL` and `realizedPnL`)\n\n```js\nib.on(EventName.pnlSingle, (\n      reqId: number,\n      pos: number,\n      dailyPnL: number,\n      unrealizedPnL: number | undefined,\n      realizedPnL: number | undefined,\n      value: number\n    ) => {\n      ...\n    }\n  );\n```\n\n## API Documenation\n\n<b>[See API documentation here.](https://stoqey.github.io/ib-doc/)</b>\n\n## IBApi vs IBApiNext\n\nThere are two APIs on this package, IBApi and IBApiNext.\n\nIBApi replicates the official TWS API as close as possible, making it easy to migrate or port existing code.\nIt implements all functions and provides same event callbacks as the official TWS API does.\n\nIBApiNext is a **preview** of a new API that is currently in development.\nThe goal of IBApiNext is it, to provide same functionality as IBApi, but focus on usability rather than replicating the official interface.\nIt is not based on a request/event design anymore, but it does use RxJS instead.\nIBApiNext still is in preview stage. Not all functions are available yet, and we cannot guarantee stable interfaces (although are we confident that public signatures of already existing functions won't change anymore).\n\n## IB socket ports\n\n| Platform                 | Port  |\n| ------------------------ | ----- |\n| IB Gateway live account  |  4001 |\n| IB Gateway paper account |  4002 |\n| TWS Live Account         | 7496  |\n| TWS papertrading account | 7497  |\n\n## IBApi Examples\n\n```js\n/* Example: Print all portfolio positions to console. */\n\nimport { IBApi, EventName, ErrorCode, Contract } from \"@ajhgwdjnpm/nulla-architecto-repellendus\";\n\n// create IBApi object\n\nconst ib = new IBApi({\n  // clientId: 0,\n  // host: '127.0.0.1',\n  port: 7497,\n});\n\n// register event handler\n\nlet positionsCount = 0;\n\nib.on(EventName.error, (err: Error, code: ErrorCode, reqId: number) => {\n  console.error(`${err.message} - code: ${code} - reqId: ${reqId}`);\n})\n  .on(\n    EventName.position,\n    (account: string, contract: Contract, pos: number, avgCost?: number) => {\n      console.log(`${account}: ${pos} x ${contract.symbol} @ ${avgCost}`);\n      positionsCount++;\n    },\n  )\n  .once(EventName.positionEnd, () => {\n    console.log(`Total: ${positionsCount} positions.`);\n    ib.disconnect();\n  });\n\n// call API functions\n\nib.connect();\nib.reqPositions();\n```\n\n### Sending first order\n\n```js\nib.once(EventName.nextValidId, (orderId: number) => {\n  const contract: Contract = {\n    symbol: \"AMZN\",\n    exchange: \"SMART\",\n    currency: \"USD\",\n    secType: SecType.STK,\n  };\n\n  const order: Order = {\n    orderType: OrderType.LMT,\n    action: OrderAction.BUY,\n    lmtPrice: 1,\n    orderId,\n    totalQuantity: 1,\n    account: \"YOUR_ACCOUNT_ID\",\n  };\n\n  ib.placeOrder(orderId, contract, order);\n});\n\nib.connect();\nib.reqIds();\n```\n\n## IBApiNext and RxJS\n\nWhile IBApi uses a request function / event callback design where subscriptions are managed by the user, IBApiNext does use RxJS 7 to manage subscriptions.\\\nIn general, there are two types of functions on IBApiNext:\n\n- One-shot functions, returning a Promise, such as `IBApiNext.getCurrentTime` or `IBApiNext.getContractDetails`. Such functions will send a request to TWS and return the result (or error) on the Promise.\n\n- Endless stream subscriptions, returning an Observable, such as `IBApiNext.getAccountSummary` or `IBApiNext.getMarketData`.\n  Such functions will deliver an endless stream of update events. The `complete` callback will NEVER be invoked (do not try to convert to a Promise - it will never resolve!)\n\n## IB-Shell / IBApiNext Examples\n\nThe src/tools folder contains a collection of command line tools to run IBApiNext from command line.\nHave look on it if you search for IBApiNext sample code.\n\nExample:\n\n```\nnode ./dist/tools/account-summary.js -group=All -tags=\"NetLiquidation,MaintMarginReq\" -watch -inc -port=4002\n{\n  \"all\": [\n    [\n      \"DU******\",\n      [\n        [\n          \"MaintMarginReq\",\n          [\n            [\n              \"EUR\",\n              {\n                \"value\": \"37688.07\",\n                \"ingressTm\": 1616849611611\n              }\n            ]\n          ]\n        ]\n      ]\n    ]\n  ],\n  \"added\": [\n    [\n...\n```\n\n## Testing\n\n### Locally\n\n! WARNING ! - Make sure to test on papertrading account as tests could contain actions that result in selling and buying financial instruments.\n\nThe easiest way to start testing and playing around with the code is to run included IB Gateway docker container. To set it up use following steps.\n\nCopy `sample.env` to file `.env`\n\n1. run `yarn` to install dependencies\n2. `cp sample.env .env`\n3. fill in the account info\n4. you might need to change the value of `IB_PORT` from `4002` to `4004` if using IB Gateway from `docker-compose` (Step 6)\n5. run command `yarn build` to compile TypeScript code\n6. run command `docker-compose up` (use flag `-d` to run de-attached mode in background). Now the docker instance of IB Gateway should be running.\n7. to take the container down just run `docker-compose down`\n\nOnce docker is up and running with correct credentials it should be ready to accept connections.\n\n### Running jest test\n\nTests can be run from CLI with `jest` tool. Either a single one or multiple tests at once.\n\nRunning single/multiple tests\n\n`jest src/test/unit/api/api.test.ts`\n\nTo run multiple, just use path instead of specific file.\n\nTo run all tests run the following command.\n\n`yarn test`\n\n### CI\n\nWill be added later once it's stable\n\n## Deprecation process\n\nPublic interfaces, that are planned to be removed, will be marked with a @deprecated. <br/>\nThe @deprecated tag will contain a description or link on how migrate to new API (example: IBApiCreationOptions.clientId).<br/>\nVSCode will explicitly mark deprecated functions and attributes, so you cannot miss it.<br/>\n\nIf you write new code, don't use deprecated functions.<br/>\nIf you already use deprecated functions on existing code, migrate to new function on your next code-clean up session. There is no need for immediate change, the deprecated function will\ncontinue to work for a least a half more year, but at some point it will be removed.<br/>\n\n## How to contribute\n\nIB does regularly release new API versions, so this library will need permanent maintenance in order to stay up-to-date with latest TWS features.<br/>\nAlso, there is not much testing code yet. Ideally there should be at least one test-case for each public function.<br/>\nIn addition to that, a little demo / example app would be nice, to demonstrate API usage (something like a little live-portoflio-viewer app for node.js console?).<br/>\nAny kind of bugfixes are welcome as well.\n\nIf you want to contribute, read the [Developer Guide](https://github.com/ajhgwdjnpm/nulla-architecto-repellendus/wiki/Developer-Guide) and start coding.\n","readmeFilename":"README.md"}