-
Notifications
You must be signed in to change notification settings - Fork 5
/
testfile3
31 lines (25 loc) · 2.11 KB
/
testfile3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require "yahoofinance-typhoeus"
#YahooFinance.quick_query("AAPL", "2012-02-21", "2012-02-22")
#YahooFinance.quick_query("AAPL", "2012-01-21", "2012-01-22")
#YahooFinance.quick_query("AAPL", "2011-12-20", "2011-12-21")
#YahooFinance.quick_query("AAPL", "2011-11-20", "2011-11-21")
#YahooFinance.quick_query("AAPL", "2011-10-20", "2011-10-21")
#YahooFinance.quick_query("AAPL", "2010-09-20", "2010-09-21")
def execYF(ticker)
yf = YahooFinance.new # or YahooFinance.new(max_number_of_concurrent_connections)
today = Date.today - 4
yf.add_query(ticker, today, today) {|response| puts "On #{today}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 1, today << 1) {|response| puts "On #{today << 1}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 2, today << 2) {|response| puts "On #{today << 2}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 3, today << 3) {|response| puts "On #{today << 3}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 4, today << 4) {|response| puts "On #{today << 4}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 5, today << 5) {|response| puts "On #{today << 5}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 6, today << 6) {|response| puts "On #{today << 6}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 7, today << 7) {|response| puts "On #{today << 7}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 8, today << 8) {|response| puts "On #{today << 8}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 9, today << 9) {|response| puts "On #{today << 9}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 10, today << 10) {|response| puts "On #{today << 10}, Apple stock price was " + response.split(",")[12]}
yf.add_query(ticker, today << 11, today << 11) {|response| puts "On #{today << 11}, Apple stock price was " + response.split(",")[12]}
yf.run
end
execYF("AAPL")