Class: EOD::Command

Inherits:
MisterBin::Command
  • Object
show all
Defined in:
lib/eod/command.rb

Instance Method Summary collapse

Instance Method Details

#bond_commandObject



92
93
94
95
# File 'lib/eod/command.rb', line 92

def bond_command
  disallow :csv
  send_output get("bond-fundamentals/#{symbol}")
end

#bulk_commandObject



97
98
99
# File 'lib/eod/command.rb', line 97

def bulk_command
  send_output get("eod-bulk-last-day/#{exchange}")
end

#calendar_commandObject



101
102
103
104
105
106
107
108
109
# File 'lib/eod/command.rb', line 101

def calendar_command
  allowed = %w[earnings trends ipos splits]

  unless allowed.include? calendar
    raise InputError, "Invalid calendar #{calendar}. Expecting earnings, trends, ipos or splits"
  end

  send_output get("calendar/#{calendar}")
end

#data_commandObject



111
112
113
# File 'lib/eod/command.rb', line 111

def data_command
  send_output get("eod/#{symbol}")
end

#dividends_commandObject



115
116
117
# File 'lib/eod/command.rb', line 115

def dividends_command
  send_output get("div/#{symbol}")
end

#events_commandObject



119
120
121
# File 'lib/eod/command.rb', line 119

def events_command
  send_output get('economic-events')
end

#exchange_commandObject



123
124
125
126
# File 'lib/eod/command.rb', line 123

def exchange_command
  disallow :csv
  send_output get("exchange-details/#{exchange}")
end

#exchanges_commandObject



128
129
130
# File 'lib/eod/command.rb', line 128

def exchanges_command
  send_output get('exchanges-list')
end

#fundamental_bulk_commandObject



137
138
139
140
# File 'lib/eod/command.rb', line 137

def fundamental_bulk_command
  disallow :csv
  send_output get("bulk-fundamentals/#{symbol}")
end

#fundamental_commandObject



132
133
134
135
# File 'lib/eod/command.rb', line 132

def fundamental_command
  disallow :csv
  send_output get("fundamentals/#{symbol}")
end

#get(endpoint) ⇒ Object



199
200
201
202
203
204
205
206
207
208
# File 'lib/eod/command.rb', line 199

def get(endpoint)
  case format
  when :url           then api.url endpoint, params
  when :csv           then api.get_csv endpoint, params
  when :json, :pretty then api.get endpoint, params
  when :yaml          then api.get(endpoint, params).to_yaml
  else
    raise InputError, "Invalid format #{format}. Expecting csv, json, yaml or pretty"
  end
end

#insider_commandObject



142
143
144
# File 'lib/eod/command.rb', line 142

def insider_command
  send_output get('insider-transactions')
end

#intraday_commandObject



146
147
148
# File 'lib/eod/command.rb', line 146

def intraday_command
  send_output get("intraday/#{symbol}")
end

#live_commandObject



150
151
152
# File 'lib/eod/command.rb', line 150

def live_command
  send_output get("real-time/#{symbol}")
end

#macro_commandObject



154
155
156
# File 'lib/eod/command.rb', line 154

def macro_command
  send_output get("macro-indicator/#{country}")
end

#news_commandObject



158
159
160
161
# File 'lib/eod/command.rb', line 158

def news_command
  disallow :csv
  send_output get('news')
end

#opts_commandObject



163
164
165
166
# File 'lib/eod/command.rb', line 163

def opts_command
  disallow :csv
  send_output get("options/#{symbol}")
end

#screener_commandObject



168
169
170
# File 'lib/eod/command.rb', line 168

def screener_command
  send_output get('screener')
end

#search_commandObject



172
173
174
# File 'lib/eod/command.rb', line 172

def search_command
  send_output get("search/#{query.uri_encode}")
end

#send_output(data) ⇒ Object



188
189
190
191
192
193
194
195
196
197
# File 'lib/eod/command.rb', line 188

def send_output(data)
  if save
    say "saved #{save}"
    File.write save, data
  elsif pretty
    lp data
  else
    puts data
  end
end

#splits_commandObject



176
177
178
# File 'lib/eod/command.rb', line 176

def splits_command
  send_output get("splits/#{symbol}")
end

#symbols_commandObject



180
181
182
# File 'lib/eod/command.rb', line 180

def symbols_command
  send_output get("exchange-symbol-list/#{exchange}")
end

#technical_commandObject



184
185
186
# File 'lib/eod/command.rb', line 184

def technical_command
  send_output get("technical/#{symbol}")
end