How to use the bfx-api-node-models.Order.type function in bfx-api-node-models

To help you get started, we’ve selected a few bfx-api-node-models examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitfinexcom / bitfinex-api-node / examples / rest2 / submit_order.js View on Github external
process.env.DEBUG = 'bfx:examples:*'

const debug = require('debug')('bfx:examples:submit_order')
const bfx = require('../bfx')
const { Order } = require('bfx-api-node-models')
const rest = bfx.rest(2)

debug('Submitting new order...')

// Build new order
const o = new Order({
  cid: Date.now(),
  symbol: 'tBTCUSD',
  price: 18000,
  amount: -0.02,
  type: Order.type.LIMIT,
  lev: 10
}, rest)

o.submit().then(() => {
  debug(
    'got submit confirmation for order %d [%d] [tif: %d]',
    o.cid, o.id, o.mtsTIF
  )
})
  .catch((err) => console.log(err))

// update order

setTimeout(() => {
  o.update({
    price: 17000
github bitfinexcom / bitfinex-api-node / examples / ws2 / atomic_order_update.js View on Github external
ws.onOrderBook({ symbol: SYMBOL }, (ob) => {
  const topBidL = ob.topBidLevel()

  if (topBidL === null || orderSent) {
    return
  }

  debug('taking out price level: %j', topBidL)

  const o = new Order({
    symbol: SYMBOL,
    type: Order.type.EXCHANGE_LIMIT,
    price: topBidL[0],
    amount: topBidL[2] * -1.1 // sell through top bid
  }, ws)

  o.registerListeners()
  o.submit().then(() => debug('order submitted'))
  o.once('update', (o) => {
    debug('got order update: %s', o.status)

    if (o.isPartiallyFilled()) {
      debug('order is partially filled, amount %f', o.amount)
      debug('increasing amount w/ delta %f', o.amount * 2)

      o.update({ delta: `${o.amount * 2}` }).then(() => {
        debug('order updated, new amount %f', o.amount)
        debug('setting price to %f', o.price * 1.05)
github bitfinexcom / bitfinex-api-node / examples / ws2 / order_tif.js View on Github external
ws.once('auth', () => {
  debug('authenticated')

  // Build new order
  const o = new Order({
    cid: Date.now(),
    symbol: 'tBTCUSD',
    price: 17833.5,
    amount: -0.02,
    type: Order.type.LIMIT,
    tif: '2019-03-08 15:00:00'
  }, ws)

  o.registerListeners()

  o.on('update', () => {
    debug('order updated: %j', o.serialize())
  })

  o.on('close', () => {
    debug('order closed: %s', o.status)
  })

  debug('submitting order %d', o.cid)

  o.submit().then(() => {
github bitfinexcom / bitfinex-api-node / examples / ws2 / oco-order.js View on Github external
ws.once('auth', () => {
  debug('authenticated')

  // Build new order
  const o = new Order({
    cid: Date.now(),
    symbol: 'tBTCUSD',
    type: Order.type.EXCHANGE_LIMIT,
    amount: -0.05,

    oco: true,
    price: 2000,
    priceAuxLimit: 1000
  }, ws)

  let closed = false

  // Enable automatic updates
  o.registerListeners()

  o.on('update', () => {
    debug('order updated: %j', o.serialize())
  })
github bitfinexcom / bitfinex-api-node / examples / ws2 / orders.js View on Github external
ws.once('auth', () => {
  debug('authenticated')

  // Build new order
  const o = new Order({
    cid: Date.now(),
    symbol: 'tBTCUSD',
    price: 589.10,
    amount: -0.02,
    type: Order.type.EXCHANGE_LIMIT
  }, ws)

  let closed = false

  // Enable automatic updates
  o.registerListeners()

  o.on('update', () => {
    debug('order updated: %j', o.serialize())
  })

  o.on('close', () => {
    debug('order closed: %s', o.status)
    closed = true
  })