Google Finance查询最近5个交易日,不包括周末

问题描述 投票:0回答:1

我有以下Google和yahoo财务查询,它们在最近5天内生成了一个简单的图形。我将如何对其进行修改以查看最近5个交易日。仅在星期一至星期五。

=IFERROR(sparkline(query(googlefinance($A16, "price", today()-5, today()), "select Col2 label Col2 ''", 1),{"color",if( INDEX(googlefinance($A16,"price",today()-5),2,2) < INDEX(googlefinance($A16, "price", today()-2),2,2),"green","red");"linewidth",2}))


=SPARKLINE(QUERY(IMPORTHTML(
 "https://finance.yahoo.com/quote/AAPL/history?period1=“&86400*(
 TODAY()-5)-2209161600&"&period2=“&86400*TODAY()-2209161600&
 "&interval=1d&filter=history&frequency=1d”,
 "table", 1),
 “select Col5 order by Col1 asc offset 1”, 0), {“color”, IF(INDEX(SORT(IMPORTHTML(
 "https://finance.yahoo.com/quote/AAPL/history?period1="&86400*(
 TODAY()-5)-2209161600&"&period2="&86400*TODAY()-2209161600&
 "&interval=1d&filter=history&frequency=1d", 
 "table", 1), 1, 1), 1, 5) < INDEX(IMPORTXML(
 "https://finance.yahoo.com/quote/AAPL", 
 "//*[@id='quote-header-info']//span"), 2),
 "green", "red"); "linewidth", 2})
if-statement google-sheets google-sheets-query yahoo-finance google-finance
1个回答
0
投票

如果运行此公式,您将得到:

0

所以要获得最后5个值,您需要:

0

因此:

=SPARKLINE(QUERY(QUERY(IMPORTHTML(
 "https://finance.yahoo.com/quote/AAPL/history?period1="&86400*(
 TODAY()-15)-2209161600&"&period2="&86400*TODAY()-2209161600&
 "&interval=1d&filter=history&frequency=1d",
 "table", 1), "limit 5", 1),
 "select Col5 order by Col1 offset 1", 0), {"color", IF(QUERY(QUERY(IMPORTHTML(
 "https://finance.yahoo.com/quote/AAPL/history?period1="&86400*(
 TODAY()-15)-2209161600&"&period2="&86400*TODAY()-2209161600&
 "&interval=1d&filter=history&frequency=1d",
 "table", 1), "limit 5", 1),
 "select Col5 order by Col1 limit 1 offset 1", 0) < INDEX(IMPORTXML(
 "https://finance.yahoo.com/quote/AAPL", 
 "//*[@id='quote-header-info']//span"), 2),
 "green", "red"); "linewidth", 2})

0

© www.soinside.com 2019 - 2024. All rights reserved.