class Darwinex::Api::InvestorAccountInfoApi

Constants

BASE_URI

Attributes

config[R]

Public Class Methods

new(config:, logger:) click to toggle source
Calls superclass method Darwinex::Api::Api::new
# File lib/darwinex/api/investor_account_info_api.rb, line 14
def initialize(config:, logger:)
  super(logger)
  @config = config
end

Public Instance Methods

get_conditional_order(account_id, conditional_order_id) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 40
def get_conditional_order(account_id, conditional_order_id)
  send('get', "/investoraccounts/#{account_id}/conditionalorders/conditional_order_id", options, max_retries: config.max_retries)
end
get_current_positions(account_id, product_name: nil) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 44
def get_current_positions(account_id, product_name: nil)
  query = {
    query: {
      productName: product_name
    }
  }

  send('get', "/investoraccounts/#{account_id}/currentpositions", options.merge(query), max_retries: config.max_retries)
end
get_executed_orders(account_id, product_name: nil, page: nil, per_page: nil) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 54
def get_executed_orders(account_id, product_name: nil, page: nil, per_page: nil)
  query = {
    query: {
      productName: product_name,
      page: page,
      per_page: per_page
    }
  }

  send('get', "/investoraccounts/#{account_id}/orders/executed", options.merge(query), max_retries: config.max_retries)
end
get_investor_account(account_id) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 23
def get_investor_account(account_id)
  send('get', "/investoraccounts/#{account_id}", options, max_retries: config.max_retries)
end
get_order(account_id, order_id) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 66
def get_order(account_id, order_id)
  send('get', "/investoraccounts/#{account_id}/orders/#{order_id}", options, max_retries: config.max_retries)
end
get_performance_fees(account_id, page: nil, per_page: nil) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 70
def get_performance_fees(account_id, page: nil, per_page: nil)
  query = {
    query: {
      page: page,
      per_page: per_page
    }
  }

  send('get', "/investoraccounts/#{account_id}/performancefees", options.merge(query), max_retries: config.max_retries)
end
get_performance_fees_for_product(account_id, product_name) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 81
def get_performance_fees_for_product(account_id, product_name)
  send('get', "/investoraccounts/#{account_id}/performancefees/#{product_name}", options, max_retries: config.max_retries)
end
get_trade(account_id, trade_id) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 98
def get_trade(account_id, trade_id)
  send('get', "/investoraccounts/#{account_id}/trades/#{trade_id}", options, max_retries: config.max_retries)
end
list_conditional_orders(account_id, status, product_name: nil, page: nil, per_page: nil) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 27
def list_conditional_orders(account_id, status, product_name: nil, page: nil, per_page: nil)
  # TODO: status validation
  query = {
    query: {
      productName: product_name,
      page: page,
      per_page: per_page
    }
  }

  send('get', "/investoraccounts/#{account_id}/conditionalorders/#{status}", options.merge(query), max_retries: config.max_retries)
end
list_investor_accounts() click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 19
def list_investor_accounts
  send('get', '/investoraccounts', options, max_retries: config.max_retries)
end
list_trades(account_id, trade_status, product_name: nil, page: nil, per_page: nil) click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 85
def list_trades(account_id, trade_status, product_name: nil, page: nil, per_page: nil)
  # todo: verify status
  query = {
    query: {
      product_name: product_name,
      page: page,
      per_page: per_page
    }
  }

  send('get', "/investoraccounts/#{account_id}/trades/#{trade_status}", options.merge(query), max_retries: config.max_retries)
end

Private Instance Methods

options() click to toggle source
# File lib/darwinex/api/investor_account_info_api.rb, line 106
def options
  {
    headers: {
      Authorization: "Bearer #{config.access_token}",
      'Content-Type' => 'application/json'
    }
  }
end