Class: EOD::Command
- Inherits:
-
MisterBin::Command
- Object
- MisterBin::Command
- EOD::Command
- Defined in:
- lib/eod/command.rb
Instance Method Summary collapse
- #bond_command ⇒ Object
- #bulk_command ⇒ Object
- #calendar_command ⇒ Object
- #data_command ⇒ Object
- #dividends_command ⇒ Object
- #events_command ⇒ Object
- #exchange_command ⇒ Object
- #exchanges_command ⇒ Object
- #fundamental_bulk_command ⇒ Object
- #fundamental_command ⇒ Object
- #get(endpoint) ⇒ Object
- #insider_command ⇒ Object
- #intraday_command ⇒ Object
- #live_command ⇒ Object
- #macro_command ⇒ Object
- #news_command ⇒ Object
- #opts_command ⇒ Object
- #screener_command ⇒ Object
- #search_command ⇒ Object
- #send_output(data) ⇒ Object
- #splits_command ⇒ Object
- #symbols_command ⇒ Object
- #technical_command ⇒ Object
Instance Method Details
#bond_command ⇒ Object
92 93 94 95 |
# File 'lib/eod/command.rb', line 92 def bond_command disallow :csv send_output get("bond-fundamentals/#{symbol}") end |
#bulk_command ⇒ Object
97 98 99 |
# File 'lib/eod/command.rb', line 97 def bulk_command send_output get("eod-bulk-last-day/#{exchange}") end |
#calendar_command ⇒ Object
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_command ⇒ Object
111 112 113 |
# File 'lib/eod/command.rb', line 111 def data_command send_output get("eod/#{symbol}") end |
#dividends_command ⇒ Object
115 116 117 |
# File 'lib/eod/command.rb', line 115 def dividends_command send_output get("div/#{symbol}") end |
#events_command ⇒ Object
119 120 121 |
# File 'lib/eod/command.rb', line 119 def events_command send_output get('economic-events') end |
#exchange_command ⇒ Object
123 124 125 126 |
# File 'lib/eod/command.rb', line 123 def exchange_command disallow :csv send_output get("exchange-details/#{exchange}") end |
#exchanges_command ⇒ Object
128 129 130 |
# File 'lib/eod/command.rb', line 128 def exchanges_command send_output get('exchanges-list') end |
#fundamental_bulk_command ⇒ Object
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_command ⇒ Object
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_command ⇒ Object
142 143 144 |
# File 'lib/eod/command.rb', line 142 def insider_command send_output get('insider-transactions') end |
#intraday_command ⇒ Object
146 147 148 |
# File 'lib/eod/command.rb', line 146 def intraday_command send_output get("intraday/#{symbol}") end |
#live_command ⇒ Object
150 151 152 |
# File 'lib/eod/command.rb', line 150 def live_command send_output get("real-time/#{symbol}") end |
#macro_command ⇒ Object
154 155 156 |
# File 'lib/eod/command.rb', line 154 def macro_command send_output get("macro-indicator/#{country}") end |
#news_command ⇒ Object
158 159 160 161 |
# File 'lib/eod/command.rb', line 158 def news_command disallow :csv send_output get('news') end |
#opts_command ⇒ Object
163 164 165 166 |
# File 'lib/eod/command.rb', line 163 def opts_command disallow :csv send_output get("options/#{symbol}") end |
#screener_command ⇒ Object
168 169 170 |
# File 'lib/eod/command.rb', line 168 def screener_command send_output get('screener') end |
#search_command ⇒ Object
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_command ⇒ Object
176 177 178 |
# File 'lib/eod/command.rb', line 176 def splits_command send_output get("splits/#{symbol}") end |
#symbols_command ⇒ Object
180 181 182 |
# File 'lib/eod/command.rb', line 180 def symbols_command send_output get("exchange-symbol-list/#{exchange}") end |
#technical_command ⇒ Object
184 185 186 |
# File 'lib/eod/command.rb', line 184 def technical_command send_output get("technical/#{symbol}") end |