Comparing version 0.1.17 to 0.1.18
@@ -1,5 +0,6 @@ | ||
// In this example, we will submit orders through different ways | ||
// In this example, we will submit orders with different methods | ||
var addon = require('../ibapi'); | ||
var obj = new addon.NodeIbapi(); | ||
var ibcontract = require('../lib/contract'); | ||
var iborder = require('../lib/order'); | ||
@@ -29,9 +30,9 @@ var orderId = -1; | ||
var msftContract2 = ibcontract.createContract(); | ||
msftContract2.conId = 272093; // you can look this up from Contract Details in TWS | ||
msftContract2.conId = 272093; // look this up from Contract Details in TWS | ||
msftContract2.exchange = 'SMART'; | ||
// Must have lmtPrice and auxPrice in the arguments | ||
var placeMsftLmtOrder = function (contract, oId) { | ||
console.log('Next valid order Id: %d',oId); | ||
console.log("Placing order for MSFT"); | ||
console.log("Order %d: Placing LMT order for MSFT",oId); | ||
obj.placeOrder(oId,contract, | ||
@@ -41,7 +42,18 @@ "BUY", 1000, "LMT", 0.11, 0.11); | ||
var placeMsftMitOrder = function (contract, oId) { | ||
console.log('Next valid order Id: %d',oId); | ||
console.log("Placing order for MSFT"); | ||
console.log("Order %d: Placing MIT order for MSFT",oId); | ||
obj.placeOrder(oId,contract, | ||
"BUY", 1000, "MIT", 0.11, 0.11); | ||
} | ||
// Now supports using order.js | ||
var placeOrderUsingLib = function (contract, oId) { | ||
console.log("Order %d: Placing LMT order for MSFT with order.js lib", oId); | ||
var newOrder = iborder.createOrder(); | ||
newOrder.action = "BUY"; | ||
newOrder.totalQuantity = 1000; | ||
newOrder.orderType = "LMT"; | ||
newOrder.lmtPrice = 0.12; | ||
newOrder.auxPrice = 0.12; | ||
obj.placeOrder(oId,contract,newOrder); | ||
} | ||
var cancelPrevOrder = function (oId) { | ||
@@ -66,10 +78,11 @@ console.log('canceling order: %d', oId); | ||
setInterval(doReqFunc,100); | ||
setInterval(function () { | ||
obj.funcQueue.push(placeMsftLmtOrder(msftContract1, orderId)); | ||
obj.funcQueue.push(cancelPrevOrder(orderId)); | ||
orderId = orderId + 1; | ||
obj.funcQueue.push(placeMsftMitOrder(msftContract2, orderId)); | ||
obj.funcQueue.push(cancelPrevOrder(orderId)); | ||
orderId = orderId + 1; | ||
},2000); | ||
obj.funcQueue.push(placeMsftLmtOrder(msftContract1, orderId)); | ||
obj.funcQueue.push(cancelPrevOrder(orderId)); | ||
orderId = orderId + 1; | ||
obj.funcQueue.push(placeMsftMitOrder(msftContract2, orderId)); | ||
obj.funcQueue.push(cancelPrevOrder(orderId)); | ||
orderId = orderId + 1; | ||
obj.funcQueue.push(placeOrderUsingLib(msftContract2, orderId)); | ||
obj.funcQueue.push(cancelPrevOrder(orderId)); | ||
orderId = orderId + 1; | ||
setTimeout(disconnectClient,9001); | ||
@@ -76,0 +89,0 @@ }) |
@@ -22,3 +22,3 @@ // In this example, we will request a scanner subscription and receive the | ||
impVolGainers.instrument = "STK"; | ||
impVolGainers.scanCode = "TOP_OPT_IMP_VOLAT_GAIN"; | ||
impVolGainers.scanCode = "TOP_PERC_GAIN"; | ||
@@ -25,0 +25,0 @@ var impVolGainerScan = function () { |
@@ -8,7 +8,7 @@ function scannerSubscription() { | ||
scannerSubscription.prototype.scanCode = ''; //IBString | ||
scannerSubscription.prototype.abovePrice = -1; //double | ||
scannerSubscription.prototype.belowPrice = -1; //double | ||
scannerSubscription.prototype.aboveVolume = -1; //int | ||
scannerSubscription.prototype.marketCapAbove = -1; //double | ||
scannerSubscription.prototype.marketCapBelow = -1; //double | ||
scannerSubscription.prototype.abovePrice = Number.MAX_VALUE; //double | ||
scannerSubscription.prototype.belowPrice = Number.MAX_VALUE; //double | ||
scannerSubscription.prototype.aboveVolume = Number.MAX_VALUE; //int | ||
scannerSubscription.prototype.marketCapAbove = Number.MAX_VALUE; //double | ||
scannerSubscription.prototype.marketCapBelow = Number.MAX_VALUE; //double | ||
scannerSubscription.prototype.moodyRatingAbove = ''; //IBString | ||
@@ -20,4 +20,4 @@ scannerSubscription.prototype.moodyRatingBelow = ''; //IBString | ||
scannerSubscription.prototype.maturityDateBelow = ''; //IBString | ||
scannerSubscription.prototype.couponRateAbove = -1; //double | ||
scannerSubscription.prototype.couponRateBelow = -1; //double | ||
scannerSubscription.prototype.couponRateAbove = Number.MAX_VALUE; //double | ||
scannerSubscription.prototype.couponRateBelow = Number.MAX_VALUE; //double | ||
scannerSubscription.prototype.excludeConvertible = 0; //int | ||
@@ -24,0 +24,0 @@ scannerSubscription.prototype.averageOptionVolumeAbove = 0; //int |
{ | ||
"name": "ibapi", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"description": "Interactive Brokers API addon for NodeJS ", | ||
@@ -5,0 +5,0 @@ "main": "ibapi.js", |
@@ -15,2 +15,3 @@ node-ibapi-addon | ||
* 2014-09-09 - 0.1.19 - Adds order.js and placeOrder can use order obj | ||
* 2014-04-22 - 0.1.17 - Compatibility fix for API 9.70 | ||
@@ -30,6 +31,10 @@ * 2014-03-17 - 0.1.13 - Smoother installation to multiple OSes | ||
``` | ||
* Install unzip if Linux | ||
``` | ||
sudo apt-get install unzip | ||
``` | ||
### Additional installation dependency for Windows: | ||
* Install MinGW | ||
* Install msys-unzip | ||
* Install msys-unzip instead of unzip | ||
``` | ||
@@ -104,2 +109,9 @@ mingw-get install msys-unzip | ||
}) | ||
.on('clientError', function (clientError) { | ||
console.log('Client error' + clientError.id.toString()); | ||
}) | ||
.on('svrError', function (svrError) { | ||
console.log('Error: ' + svrError.id.toString() + ' - ' + | ||
svrError.errorCode.toString() + ' - ' + svrError.errorString.toString()); | ||
}) | ||
.on('disconnected', function () { | ||
@@ -139,2 +151,5 @@ console.log('disconnected'); | ||
.cancelMktData(reqId) | ||
// placeOrder can take either | ||
.placeOrder(orderId, contrct, order) | ||
// or | ||
.placeOrder(orderId, contract, action, quantity, orderType, price, auxPrice) | ||
@@ -141,0 +156,0 @@ .cancelOrder(orderId) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
203107
26
1001
253