Skip to content

Commit

Permalink
(refactor) OCOCO: check action and ocoAction validity
Browse files Browse the repository at this point in the history
  • Loading branch information
f3rno authored and JacobPlaster committed Jan 29, 2020
1 parent 9d5248b commit 981e854
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ococo/meta/validate_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ORDER_TYPES = ['MARKET', 'LIMIT']
module.exports = (args = {}) => {
const {
orderPrice, amount, orderType, submitDelay, cancelDelay, limitPrice,
stopPrice, ocoAmount, lev, _futures
stopPrice, ocoAmount, lev, _futures, action, ocoAction
} = args

if (ORDER_TYPES.indexOf(orderType) === -1) return `Invalid order type: ${orderType}`
Expand All @@ -22,6 +22,9 @@ module.exports = (args = {}) => {
if (!_isFinite(stopPrice)) return 'Invalid OCO stop price'
if (!_isFinite(ocoAmount)) return 'Invalid OCO amount'

if (action !== 'Buy' && action !== 'Sell') return `Invalid action: ${action}`
if (ocoAction !== 'Buy' && ocoAction !== 'Sell') return `Invalid OCO action: ${ocoAction}`

if (_futures) {
if (!_isFinite(lev)) return 'Invalid leverage'
if (lev < 1) return 'Leverage less than 1'
Expand Down

0 comments on commit 981e854

Please sign in to comment.