A tool for fetching historical data from Interactive Brokers.
- Node.js, https://nodejs.org
- NPM, https://www.npmjs.com
You can install both together either via package manager or installer.
git clone https://github.com/heqian/ibfetch.git
cd ibfetch/
npm install
node index.js combo [symbol]
node index.js forex [symbol]
node index.js future [symbol] [expiry <YYYYMM|YYYYMMDD>]
node index.js option [symbol] [expiry <YYYYMM|YYYYMMDD>] [strike] [right <CALL|PUT|C|P>]
node index.js stock [symbol]
node index.js combo FIT
node index.js forex EUR
node index.js future FIT 201604
node index.js option FIT 20160401 20.0 CALL
node index.js stock FIT
- Launch IB Trader Workstation or IB Gateway;
- Open terminal and enter the directory of ibfetch;
- Execute any command demostrated in Usage section;
- Press Ctrl+C when you think ibfetch has fetched enough data;
- A file with name [SYMBOL]_[SECURITY TYPE].csv (e.g., "FIT_OPT.csv") will be generated.
Edit the config.js file
{
ib: {
host: "127.0.0.1", // the IP address of machine running IB Trader Workstation (TWS) or IB Gateway (IBG)
clientId: 200, // any number
port: 7496 // port number, 7496 (default for TWS) or 4002 (default for IBG)
},
what: "MIDPOINT", // "TRADES", "BID", "ASK", "MIDPOINT"
size: "1 min" // bar size of each entry in the .CSV file
// "1 sec", "5 secs", "15 secs", "30 secs", "1 min", "2 mins", "3 mins", "5 mins", "15 mins", "30 mins", "1 hour", "1 day"
}