这是我正在使用的代码:
class Trader
def initialize(ticker ="GLD")
@ticker = ticker
end
def yahoo_data(days=12)
require 'yahoofinance'
YahooFinance::get_historical_quotes_days( @ticker, days ) do |row|
puts "#{row.join(',')}" # this is where a solution is required
end
end
end
yahoo_data方法从Yahoo Finance获取数据并将价格历史记录在控制台上。但是,您可以如何使用前面的代码来填充一个数组,以便稍后可以将其作为对象进行操作。类似于:
do |row| populate_an_array_method(row.join(',') end