Class: Eodhd::Client

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

Constant Summary collapse

API_HOST =
'eodhd.com'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_fileObject



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

def log_file
  File.open(log_filename, File::WRONLY | File::APPEND | File::CREAT)
end

.log_filenameObject



16
17
18
# File 'lib/Eodhd/Client.rb', line 16

def log_filename
  File.expand_path('~/log/eodhd/log.txt')
end

.loggerObject



24
25
26
# File 'lib/Eodhd/Client.rb', line 24

def logger
  @logger ||= Logger.new(log_file, 'daily')
end

Instance Method Details

#eod_bulk_last_day(exchange_id:, date:) ⇒ Object



48
49
50
51
52
# File 'lib/Eodhd/Client.rb', line 48

def eod_bulk_last_day(exchange_id:, date:)
  path = "/api/eod-bulk-last-day/#{exchange_id}"
  args = {date: date}
  do_request(request_string: request_string(path), args: args)
end

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



40
41
42
43
44
45
46
# File 'lib/Eodhd/Client.rb', line 40

def eod_data(exchange_id:, symbol:, period:, from: nil, to: nil)
  path = "/api/eod/#{symbol}.#{exchange_id}"
  args = {period: period}
  args.merge!(from: from) if from
  args.merge!(to: to) if to
  do_request(request_string: request_string(path), args: args)
end

#exchange_symbol_list(exchange_code:) ⇒ Object



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

def exchange_symbol_list(exchange_code:)
  path = "/api/exchange-symbol-list/#{exchange_code}"
  do_request(request_string: request_string(path))
end

#exchanges_listObject

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



30
31
32
33
# File 'lib/Eodhd/Client.rb', line 30

def exchanges_list
  path = "/api/exchanges-list"
  do_request(request_string: request_string(path))
end