Giter Club home page Giter Club logo

ib-tws-api's People

Contributors

andrenerd avatar cmchugh39 avatar joseraul avatar maxicus avatar tredondo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ib-tws-api's Issues

TypeScript

Given the complexity of IB classes, TypeScript type information would be tremendously useful for this package.

Would you be interested in a contribution that converted the code to TypeScript and added type annotations and documentation?

Wrong fields for open orders call

Thanks for sharing the package I found it to be very useful (the only one that's working with latest API)

But I found a problem with the openOrders fields for example totalQuantity is at orderType and so on it's all mixed

[
  {
    contract: {
      conId: NaN,
      symbol: 'STK',
      secType: '',
      lastTradeDateOrContractMonth: '0',
      strike: NaN,
      right: '',
      exchange: 'SMART',
      currency: 'USD',
      localSymbol: 'TSLA',
      comboLegsDescrip: ''
    },
    order: {
      orderId: 76792991,
      action: 'NMS',
      totalQuantity: NaN,
      orderType: '1000',
      lmtPrice: NaN,
      auxPrice: 0,
      tif: '0.0',
      ocaGroup: 'DAY',
      account: '',
      openClose: 'DU1900817',
      origin: NaN,
      orderRef: '0',
      clientId: NaN,
      permId: 1,
      outsideRth: false,
      hidden: false,
      discretionaryAmt: 0,
      goodAfterTime: '0',
      faGroup: '797567953.0/DU1900817/100',
      faMethod: '',
      faPercentage: '',
      faProfile: '',
      modelCode: '',
      goodTillDate: '',
      rule80A: '',
      percentOffset: 0,
      settlingFirm: '',
      shortSaleSlot: NaN,
      designatedLocation: '0',
      auctionStrategy: NaN,
      startingPrice: -1,
      stockRefPrice: 0,
      delta: NaN,
      stockRangeLower: NaN,
      stockRangeUpper: NaN,
      displaySize: NaN,
      blockOrder: false,
      sweepToFill: false,
      allOrNone: false,
      minQty: 0,
      ocaType: 0,
      eTradeOnly: false,
      firmQuoteOnly: false,
      nbboPriceCap: 0,
      parentId: 0,
      triggerMethod: NaN,
      volatility: 0,
      volatilityType: 0,
      deltaNeutralOrderType: '',
      deltaNeutralAuxPrice: 0,
      continuousUpdate: false,
      referencePriceType: NaN,
      trailStopPrice: NaN,
      basisPoints: NaN,
      basisPointsType: NaN,
      notSuppScaleNumComponents: NaN,
      scaleInitLevelSize: 0,
      scalePriceIncrement: 0,
      clearingAccount: '',
      clearingIntent: '0',
      whatIf: false,
      conditionsIgnoreRth: false,
      conditionsCancelOrder: false,
      adjustedOrderType: '0',
      triggerPrice: 0,
      lmtPriceOffset: 1.7976931348623157e+308,
      adjustedStopPrice: 1.7976931348623157e+308,
      adjustedStopLimitPrice: 1.7976931348623157e+308,
      adjustedTrailingAmount: 1.7976931348623157e+308,
      adjustableTrailingUnit: 1,
      softDollarTier: [Object],
      cashQty: 1.7976931348623157e+308,
      dontUseAutoPriceForHedge: false,
      isOmsContainer: false,
      discretionaryUpToLimitPrice: false,
      usePriceMgmtAlgo: false
    },
    orderState: {
      status: '',
      initMarginBefore: '',
      maintMarginBefore: '',
      equityWithLoanBefore: '',
      initMarginChange: '',
      maintMarginChange: '0',
      equityWithLoanChange: '0',
      initMarginAfter: '0',
      maintMarginAfter: '',
      equityWithLoanAfter: '',
      commission: NaN,
      minCommission: NaN,
      maxCommission: 0,
      commissionCurrency: '',
      warningText: 'IB'
    }
  },
  {
    contract: {
      conId: NaN,
      symbol: 'STK',
      secType: '',
      lastTradeDateOrContractMonth: '0',
      strike: NaN,
      right: '',
      exchange: 'SMART',
      currency: 'USD',
      localSymbol: 'TSLA',
      comboLegsDescrip: ''
    },
    order: {
      orderId: 76792991,
      action: 'NMS',
      totalQuantity: NaN,
      orderType: '500',
      lmtPrice: NaN,
      auxPrice: 0,
      tif: '0.0',
      ocaGroup: 'DAY',
      account: '',
      openClose: 'DU1900817',
      origin: NaN,
      orderRef: '0',
      clientId: NaN,
      permId: 1,
      outsideRth: false,
      hidden: false,
      discretionaryAmt: 0,
      goodAfterTime: '0',
      faGroup: '797567954.0/DU1900817/100',
      faMethod: '',
      faPercentage: '',
      faProfile: '',
      modelCode: '',
      goodTillDate: '',
      rule80A: '',
      percentOffset: 0,
      settlingFirm: '',
      shortSaleSlot: NaN,
      designatedLocation: '0',
      auctionStrategy: NaN,
      startingPrice: -1,
      stockRefPrice: 0,
      delta: NaN,
      stockRangeLower: NaN,
      stockRangeUpper: NaN,
      displaySize: NaN,
      blockOrder: false,
      sweepToFill: false,
      allOrNone: false,
      minQty: 0,
      ocaType: 0,
      eTradeOnly: false,
      firmQuoteOnly: false,
      nbboPriceCap: 0,
      parentId: 0,
      triggerMethod: NaN,
      volatility: 0,
      volatilityType: 0,
      deltaNeutralOrderType: '',
      deltaNeutralAuxPrice: 0,
      continuousUpdate: false,
      referencePriceType: NaN,
      trailStopPrice: NaN,
      basisPoints: NaN,
      basisPointsType: NaN,
      notSuppScaleNumComponents: NaN,
      scaleInitLevelSize: 0,
      scalePriceIncrement: 0,
      clearingAccount: '',
      clearingIntent: '0',
      whatIf: false,
      conditionsIgnoreRth: false,
      conditionsCancelOrder: false,
      adjustedOrderType: '0',
      triggerPrice: 0,
      lmtPriceOffset: 1.7976931348623157e+308,
      adjustedStopPrice: 1.7976931348623157e+308,
      adjustedStopLimitPrice: 1.7976931348623157e+308,
      adjustedTrailingAmount: 1.7976931348623157e+308,
      adjustableTrailingUnit: 1,
      softDollarTier: [Object],
      cashQty: 1.7976931348623157e+308,
      dontUseAutoPriceForHedge: false,
      isOmsContainer: false,
      discretionaryUpToLimitPrice: false,
      usePriceMgmtAlgo: false
    },
    orderState: {
      status: '',
      initMarginBefore: '',
      maintMarginBefore: '',
      equityWithLoanBefore: '',
      initMarginChange: '',
      maintMarginChange: '0',
      equityWithLoanChange: '0',
      initMarginAfter: '0',
      maintMarginAfter: '',
      equityWithLoanAfter: '',
      commission: NaN,
      minCommission: NaN,
      maxCommission: 0,
      commissionCurrency: '',
      warningText: 'IB'
    }
  }
]

Combo example

How should combos be created? The code isn't quite self-explanatory :) Does a .legs field need to be set? Are the legs passed as an array? Where?

Incomplete API and misformated js docs

The jsdocs are still formatted similar to how they would be in python, so the documentation doesn't show in intellisense. Also the incomplete APIs show in my intellisense, which crouds it when i'm trying to find working APIs.

Less of a complaint and more of an issue for me to attach to a pull request i'm making. Dispite this API being incomplete, the async/await syntax on this is something i've been looking for for a while now, so i'm going to clean up the jsdocs and add typings to the parameters in the jsdocs. I may make other commits to this repo in the future as well.

Great work on this so far, and i'm happy to help going forward!

Error: Warning: You submitted request with date-time attributes without explicit time zone.

IB has changed the timezone format in TWS 10.17+ and now it requires us to provide timezone at the end of the dates.
See info here: https://forum.amibroker.com/t/please-look-at-timeinforce-part-of-place-order-code/31980/3

So instead:

let details = await api.getHistoricalData({
    contract: Contract.stock('AAPL'),
    endDateTime: '20200308 12:00:00,
    duration: '1 D',
    barSizeSetting: '1 min',
    whatToShow: 'TRADES',
    useRth: 1,
    formatDate: 1
});

Valid date format is now:

let details = await api.getHistoricalData({
    contract: Contract.stock('AAPL'),
    endDateTime: '20200308 12:00:00 US/Eastern', // or for UTC: 20200308-12:00:00
    duration: '1 D',
    barSizeSetting: '1 min',
    whatToShow: 'TRADES',
    useRth: 1,
    formatDate: 1
});

Can you give me an example how to fetch the whole option chain from an option?

The problem:
With your example I'm able to see the available expirations + strikes, but not the full option chain with puts/calls side by side.

The problem is that I'll end up with a lot of requests just to see an option chain. The nr of individual requests = 2 * nr of strikes per expiration which is a lot.

There should be a better way to do this, from a single call, in the TWS API I found this: https://interactivebrokers.github.io/tws-api/options.html#option_chains

Potential solution:
What I've tried was to manually "bruteforce" my way into Contract. options removing the asserts and to add the localSymbol, but that actually generated more problems.

Can you help me with an example of how I could get the option chain without doing individual requests for every strike?

cannot obtain historical ticks (TRADES)

When making historical tick requests I can only get BID_ASK, not TRADES. When I request TRADES it returns an empty array. Is this a known bug / limitation?

Scanners

Hi!

I think the scanners are not implemented, right?
I would like to create a PR if you point me in the correct direction.

Thanks!

IB API timeouts for large data requests

Is there a way to set a longer timeout interval for large data requests, or handle / avoid / correct api timeouts for large data requests?
In TWS, I tried changing the value of edit>Global Configuration>API>Settings>Timeout to send bulk data to API, but this did not seem to produce a change in behavior, the timeout is still generated at 30s after the request is submitted.

Why do you need large requests?
The API provides historical ADJUSTED_LAST data, apparently going back a long way. For example:
{contract: Contract.stock('GE'),duration: '10 Y', barSizeSetting: '1 hour', whatToShow: 'ADJUSTED_LAST', useRth: 1, formatDate: 1}
However, pulling a lot of data results in an api timeout.
I don't see a way to page the data because with the use of whatToShow: 'ADJUSTED_LAST', it is disallowed to use endDateTime to request the data in chunks. There are probably other circumstances where people need to make large data requests.

Is there a way to override the api timeout duration, or otherwise succeed in making a large data request?

Thank you

Cannot use import statement outside a module

I get this error while trying your module in v12.16.1. NodeJS:

Looks like the new node requires all the ES6 files named as .mjs

import { Client } from 'ib-tws-api';
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1072:16)
at Module._compile (internal/modules/cjs/loader.js:1122:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.