Class: Eodhd::Client

Inherits:
Object
  • Object
show all
Includes:
Validations
Defined in:
lib/Eodhd/Client.rb

Constant Summary collapse

API_HOST =
'eodhd.com'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Validations

#validate_arguments, #validate_date, #validate_date_range, #validate_exchange_code, #validate_interval, #validate_period, #validate_symbol

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



79
80
81
# File 'lib/Eodhd/Client.rb', line 79

def api_token
  @api_token
end

#loggerObject

Returns the value of attribute logger.



79
80
81
# File 'lib/Eodhd/Client.rb', line 79

def logger
  @logger
end

Class Method Details

.path_prefixObject



20
21
22
# File 'lib/Eodhd/Client.rb', line 20

def path_prefix
  '/api'
end

Instance Method Details

#eod_bulk_last_day(exchange_id:, date:) ⇒ Object



52
53
54
55
56
57
# File 'lib/Eodhd/Client.rb', line 52

def eod_bulk_last_day(exchange_id:, date:)
  validate_arguments(exchange_id: exchange_id, date: date)
  args = {date: date}
  response = get(path: "/eod-bulk-last-day/#{exchange_id}", args: args)
  handle_response(response)
end

#eod_data(exchange_id:, symbol:, period:, from: nil, to: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/Eodhd/Client.rb', line 39

def eod_data(exchange_id:, symbol:, period:, from: nil, to: nil)
  validate_arguments(
    exchange_id: exchange_id,
    symbol: symbol,
    period: period,
    from: from,
    to: to
  )
  args = {period: period, from: from, to: to}.compact
  response = get(path: "/eod/#{symbol}.#{exchange_id}", args: args)
  handle_response(response)
end

#exchange_symbol_list(exchange_code:) ⇒ Object



33
34
35
36
37
# File 'lib/Eodhd/Client.rb', line 33

def exchange_symbol_list(exchange_code:)
  validate_arguments(exchange_code: exchange_code)
  response = get(path: "/exchange-symbol-list/#{exchange_code}")
  handle_response(response)
end

#exchanges_listObject

This endpoint always returns json regardless of what fmt is specified.



28
29
30
31
# File 'lib/Eodhd/Client.rb', line 28

def exchanges_list
  response = get(path: '/exchanges-list')
  handle_response(response)
end

#fundamentals(exchange_code:, symbol:, filter: nil) ⇒ Object



72
73
74
75
76
77
# File 'lib/Eodhd/Client.rb', line 72

def fundamentals(exchange_code:, symbol:, filter: nil)
  validate_arguments(exchange_code: exchange_code, symbol: symbol)
  args = {filter: filter}.compact
  response = get(path: "/fundamentals/#{symbol}.#{exchange_code}", args: args)
  handle_response(response)
end

#intraday(exchange_code:, symbol:, interval:, from: nil, to: nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/Eodhd/Client.rb', line 59

def intraday(exchange_code:, symbol:, interval:, from: nil, to: nil)
  validate_arguments(
    exchange_code: exchange_code,
    symbol: symbol,
    interval: interval,
    from: from,
    to: to
  )
  args = {interval: interval, from: from, to: to}.compact
  response = get(path: "/intraday/#{symbol}.#{exchange_code}", args: args)
  handle_response(response)
end