coinpit-common
Advanced tools
Comparing version 0.0.1 to 0.1.1
@@ -28,3 +28,6 @@ var affirm = require('affirm.js') | ||
if (order.orderType === 'STP') { | ||
return Math.abs(sinful.sub(order.entryAmount, sinful.mul(quantity, order.normalizedMaxStop))) | ||
var exitAmount = sinful.mul(quantity, order.normalizedMaxStop) | ||
var diff = sinful.sub(order.entryAmount, exitAmount) | ||
var signedDiff = sinful.multiply(instrument.positionSide[order.side], diff) | ||
return Math.max(0, signedDiff) | ||
} | ||
@@ -31,0 +34,0 @@ if (order.marginPerQty) { |
{ | ||
"name": "coinpit-common", | ||
"version": "0.0.1", | ||
"version": "0.1.1", | ||
"description": "common utils for coinpit", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "gulp test" | ||
"test": "gulp coverage" | ||
}, | ||
@@ -33,3 +33,3 @@ "repository": { | ||
"gulp-jshint-html-reporter": "^0.1.3", | ||
"gulp-mocha": "^4.3.0", | ||
"gulp-mocha": "^3.0.1", | ||
"gulp-nsp": "^2.4.2", | ||
@@ -36,0 +36,0 @@ "jshint": "^2.9.4", |
@@ -92,4 +92,26 @@ { | ||
"stopPrice" : 10 | ||
}, | ||
"maxStopTightenBeyondEntryBuy": { | ||
"instrument": "BTCUSD7F27", | ||
"side": "buy", | ||
"orderType": "STP", | ||
"quantity": 1, | ||
"entryPrice": 1200, | ||
"entryAmount": 41666667, | ||
"price": 1190, | ||
"maxStop": 1188, | ||
"normalizedMaxStop":42087542 | ||
}, | ||
"maxStopTightenBeyondEntrySell": { | ||
"instrument": "BTCUSD7F27", | ||
"side": "sell", | ||
"orderType": "STP", | ||
"quantity": 1, | ||
"entryPrice": 1200, | ||
"entryAmount": 41666667, | ||
"price": 1210, | ||
"maxStop": 1212, | ||
"normalizedMaxStop":41254125 | ||
} | ||
} | ||
} |
@@ -248,2 +248,16 @@ var expect = require('expect.js') | ||
it("should return 0 margin required if max stop is tighten beyond entry price for buy stop order.", function(){ | ||
var order = orders.inverse.maxStopTightenBeyondEntryBuy | ||
var inverse = Inverse(instruments[order.instrument]) | ||
var value = inverse.calculateMarginRequiredByOrder(order, {}, true) | ||
expect(value).to.be.eql(0) | ||
}) | ||
it("should return 0 margin required if max stop is tighten beyond entry price for sell stop order.", function(){ | ||
var order = orders.inverse.maxStopTightenBeyondEntrySell | ||
var inverse = Inverse(instruments[order.instrument]) | ||
var value = inverse.calculateMarginRequiredByOrder(order, {}, true) | ||
expect(value).to.be.eql(0) | ||
}) | ||
}) | ||
@@ -250,0 +264,0 @@ |
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
1163
52378
19