stoqey / ibkr

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

Is there a way to use this with nodejs without having to use typescritp? #39

Closed gamebak closed 4 years ago

gamebak commented 4 years ago

Can this package be used without typescript?

const { ibkr, AccountSummary, IBKREVENTS, IbkrEvents, PortFolioUpdate, getContractDetails } = require('@stoqey/ibkr')
async f() {
   await ibkr({ port: 7496, host: '127.0.0.1' })

    const accountId = AccountSummary.Instance.accountSummary.AccountId;
    const totalCashValue = AccountSummary.Instance.accountSummary.TotalCashValue;

    console.log('acc id:' + accountId)
}
f()
(node:20068) UnhandledPromiseRejectionWarning: TypeError: ibkr is not a function
ceddybi commented 4 years ago

Hi @gamebak, thanks for reporting this, please import ibkr as the default, const ibkr = require('@stoqey/ibkr'),

PS: if you were using typescript you would see that this would show an error const {ibkr} = require('@stoqey/ibkr'),