Class: YfAsDataframe::Tickers
- Inherits:
-
Object
- Object
- YfAsDataframe::Tickers
- Defined in:
- lib/yf_as_dataframe/tickers.rb
Instance Method Summary collapse
- #download(period: "1mo", interval: "1d", start: nil, fin: nil, prepost: false, actions: true, auto_adjust: true, repair: false, proxy: nil, threads: true, group_by: 'column', progress: true, timeout: 10, **kwargs) ⇒ Object
- #history(period: "1mo", interval: "1d", start: nil, fin: nil, prepost: false, actions: true, auto_adjust: true, repair: false, proxy: nil, threads: true, group_by: 'column', progress: true, timeout: 10, **kwargs) ⇒ Object
-
#initialize(tickers, session = nil) ⇒ Tickers
constructor
A new instance of Tickers.
- #news ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(tickers, session = nil) ⇒ Tickers
Returns a new instance of Tickers.
3 4 5 6 7 8 9 |
# File 'lib/yf_as_dataframe/tickers.rb', line 3 def initialize(tickers, session = nil) tickers = tickers.is_a?(Array) ? tickers : tickers.split(',') @symbols = tickers.map(&:upcase) @tickers = @symbols.each_with_object({}) do |ticker, hash| hash[ticker] = Ticker.new(ticker, session: session) end end |
Instance Method Details
#download(period: "1mo", interval: "1d", start: nil, fin: nil, prepost: false, actions: true, auto_adjust: true, repair: false, proxy: nil, threads: true, group_by: 'column', progress: true, timeout: 10, **kwargs) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yf_as_dataframe/tickers.rb', line 23 def download(period: "1mo", interval: "1d", start: nil, fin: nil, prepost: false, actions: true, auto_adjust: true, repair: false, proxy: nil, threads: true, group_by: 'column', progress: true, timeout: 10, **kwargs) data = Multi.download(@symbols, start: start, fin: fin, actions: actions, auto_adjust: auto_adjust, repair: repair, period: period, interval: interval, prepost: prepost, proxy: proxy, group_by: 'ticker', threads: threads, progress: progress, timeout: timeout, **kwargs) @symbols.each do |symbol| @tickers[symbol]._history = data[symbol] if @tickers[symbol] end if group_by == 'column' data.columns = data.columns.swaplevel(0, 1) data.sort_index(level: 0, axis: 1, inplace: true) end data end |
#history(period: "1mo", interval: "1d", start: nil, fin: nil, prepost: false, actions: true, auto_adjust: true, repair: false, proxy: nil, threads: true, group_by: 'column', progress: true, timeout: 10, **kwargs) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/yf_as_dataframe/tickers.rb', line 15 def history(period: "1mo", interval: "1d", start: nil, fin: nil, prepost: false, actions: true, auto_adjust: true, repair: false, proxy: nil, threads: true, group_by: 'column', progress: true, timeout: 10, **kwargs) download(period: period, interval: interval, start: start, fin: fin, prepost: prepost, actions: actions, auto_adjust: auto_adjust, repair: repair, proxy: proxy, threads: threads, group_by: group_by, progress: progress, timeout: timeout, **kwargs) end |
#news ⇒ Object
44 45 46 47 48 |
# File 'lib/yf_as_dataframe/tickers.rb', line 44 def news @symbols.each_with_object({}) do |ticker, hash| hash[ticker] = Ticker.new(ticker).news end end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/yf_as_dataframe/tickers.rb', line 11 def to_s "yfinance.Tickers object <#{@symbols.join(', ')}>" end |