stoqey / ibkr

Interactive Brokers wrapper 🚩
MIT License
59 stars 11 forks source link

Compatible with IBeam? #86

Closed jussirantala closed 1 year ago

jussirantala commented 1 year ago

Hey,

I'm running IBeam and Node in Docker compose. When I try to connect to my IBeam gateway nothing happens. Even though I have set DEBUG=ibkr* env variable.

I use the following code with node18:

import ibkr, { AccountSummary, IBKREVENTS, IbkrEvents, PortFolioUpdate, getContractDetails } from '@stoqey/ibkr';

const ibkrEvents = IbkrEvents.Instance;

console.log('connecting ibkr');

ibkr({ port: 5000, host: 'ibeam' })
  .then(started => {
    if (!started) {
      // Error IBKR has not started
      console.log('error cannot start ibkr');
      //   Not to proceed if not connected with interactive brokers
      return process.exit(1);
    } else {
      console.log('ibkr agent started');
    }

    // subscribe for price updates
    ibkrEvents.on(IBKREVENTS.ON_PRICE_UPDATES, priceUpdates => {
      console.log(priceUpdates);
      // use the price updates here
    });

    //  Request price updates
    ibkrEvents.emit(IBKREVENTS.SUBSCRIBE_PRICE_UPDATES, { symbol: 'AAPL' });
  })
  .catch(e => {
    console.error(e);
  });

What my console logs is only "connecting ibkr".

I've tried to wait for over 10 minutes. If I change the host or port, I get errors so I guess those are correct. Is there a timeout for the requests?

jussirantala commented 1 year ago

Now I removed ibeam from the same docker network and used host.docker.internal for the host but still nothing happens. I think it connects but for some reason doesn't log anything. If I change the host to something random, I get a clear error message.

Ibeam works fine from terminal with curl.

ceddybi commented 1 year ago

use https://github.com/stoqey/ib