Method: Hive::Broadcast.limit_order_create

Defined in:
lib/hive/broadcast.rb

.limit_order_create(options, &block) ⇒ Object

This operation creates a limit order and matches it against existing open orders.

Parameters:

  • options (Hash)

    options

Options Hash (options):

  • :wif (String)

    Active wif

  • :params (Hash)
    • :owner (String)

    • :orderid (String)

    • :amount_to_sell (String)

    • :min_to_receive (String)

    • :fill_or_kill (Boolean)

    • :expiration (String)

  • :pretend (Boolean)

    Just validate, do not broadcast.

See Also:



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/hive/broadcast.rb', line 365

def self.limit_order_create(options, &block)
  required_fields = %i(owner orderid amount_to_sell min_to_receive
    fill_or_kill)
  params = options[:params]
  check_required_fields(params, *required_fields)
  
  params[:amount_to_sell] = normalize_amount(options.merge amount: params[:amount_to_sell])
  params[:min_to_receive] = normalize_amount(options.merge amount: params[:min_to_receive])
  
  if !!params[:expiration]
    params[:expiration] = Time.parse(params[:expiration].to_s)
    params[:expiration] = params[:expiration].strftime('%Y-%m-%dT%H:%M:%S')
  end
  
  ops = [[:limit_order_create, params]]
  
  process(options.merge(ops: ops), &block)
end