@@ -8,6 +8,7 @@ const _isEmpty = require('lodash/isEmpty')
88const _compact = require ( 'lodash/compact' )
99const _flatten = require ( 'lodash/flatten' )
1010const _includes = require ( 'lodash/includes' )
11+ const _isBoolean = require ( 'lodash/isBoolean' )
1112const _isUndefined = require ( 'lodash/isUndefined' )
1213const { prepareAmount, preparePrice } = require ( 'bfx-api-node-util' )
1314
@@ -101,6 +102,7 @@ class Order extends Model {
101102
102103 if ( ! this . flags ) this . flags = 0
103104 if ( ! _isUndefined ( data . hidden ) ) this . setHidden ( data . hidden )
105+ if ( ! _isUndefined ( data . visibleOnHit ) ) this . setVisibleOnHit ( data . visibleOnHit )
104106 if ( ! _isUndefined ( data . postonly ) ) this . setPostOnly ( data . postonly )
105107 if ( ! _isUndefined ( data . reduceonly ) ) this . setReduceOnly ( data . reduceonly )
106108 if ( ! _isUndefined ( data . oco ) ) {
@@ -159,6 +161,7 @@ class Order extends Model {
159161 / m a r k e t / . test ( type . toLowerCase ( ) ) ? 'MARKET' : preparePrice ( price ) ,
160162
161163 this . isHidden ( ) && 'hidden' ,
164+ this . isVisibleOnHit ( ) && 'visible-on-hit' ,
162165 this . isPostOnly ( ) && 'post-only' ,
163166 this . isReduceOnly ( ) && 'reduce-only' ,
164167 this . isPositionClose ( ) && 'pos-close' ,
@@ -182,6 +185,13 @@ class Order extends Model {
182185 return ! ! ( this . flags & Order . flags . HIDDEN )
183186 }
184187
188+ /**
189+ * @returns {boolean } visibleOnHit
190+ */
191+ isVisibleOnHit ( ) {
192+ return ! ! ( this . isHidden ( ) && this . meta && this . meta . make_visible )
193+ }
194+
185195 /**
186196 * @returns {boolean } postonly
187197 */
@@ -236,9 +246,32 @@ class Order extends Model {
236246 * @returns {number } finalFlags
237247 */
238248 setHidden ( v ) {
249+ if ( ! v && this . meta ) {
250+ delete this . meta . make_visible
251+ }
239252 return this . modifyFlag ( Order . flags . HIDDEN , v )
240253 }
241254
255+ /**
256+ * Update the meta object. The rest part of the hidden order will be visible
257+ * after first hit(partial execution).
258+ *
259+ * @param {boolean } v - visibleOnHit value
260+ * @returns {number } meta
261+ */
262+ setVisibleOnHit ( v ) {
263+ if ( ! this . isHidden ( ) || ! _isBoolean ( v ) ) {
264+ return
265+ }
266+
267+ this . meta = {
268+ ...( this . meta || { } ) ,
269+ make_visible : + v
270+ }
271+
272+ return this . meta
273+ }
274+
242275 /**
243276 * Update the post-only flag value. If post-only and the order would
244277 * immediately fill, the order is automatically cancelled.
0 commit comments