Class: Eodhd::Client
- Inherits:
-
Object
- Object
- Eodhd::Client
- Defined in:
- lib/Eodhd/Client.rb
Constant Summary collapse
- API_HOST =
'eodhd.com'
Class Method Summary collapse
Instance Method Summary collapse
- #eod_bulk_last_day(exchange_id:, date:) ⇒ Object
- #eod_data(exchange_id:, symbol:, period:, from: nil, to: nil) ⇒ Object
- #exchange_symbol_list(exchange_code:) ⇒ Object
-
#exchanges_list ⇒ Object
This endpoint always returns json regardless of what fmt is specified.
Class Method Details
.log_file ⇒ Object
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_filename ⇒ Object
16 17 18 |
# File 'lib/Eodhd/Client.rb', line 16 def log_filename File.('~/log/eodhd/log.txt') end |
.logger ⇒ Object
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_list ⇒ Object
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 |