【问题标题】:Google Finance query last 5 trading days excluding weekends谷歌财经查询过去 5 个交易日(不包括周末)
【发布时间】:2020-03-03 08:48:58
【问题描述】:

我有以下 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】:

    如果你运行这个公式,你会得到:

    所以要获得你需要的最后 5 个值:

    因此:

    =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})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-15
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-03
      相关资源
      最近更新 更多