From 775421cad38c095bbaf772cf61bfff82fa4d7eee Mon Sep 17 00:00:00 2001 From: dfinke Date: Thu, 17 Dec 2015 17:50:10 -0500 Subject: [PATCH] Initial commit --- .gitignore | 1 + Examples/Stocks/Get-StockInfo.ps1 | 21 +++++++++++++++++++++ Examples/Stocks/GetMSFT.ps1 | 14 ++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 Examples/Stocks/Get-StockInfo.ps1 create mode 100644 Examples/Stocks/GetMSFT.ps1 diff --git a/.gitignore b/.gitignore index ca85b7f..9ffdd83 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ test.xlsx testCCFMT.ps1 testHide.ps1 ImportExcel.zip +*.xlsx diff --git a/Examples/Stocks/Get-StockInfo.ps1 b/Examples/Stocks/Get-StockInfo.ps1 new file mode 100644 index 0000000..fff9c38 --- /dev/null +++ b/Examples/Stocks/Get-StockInfo.ps1 @@ -0,0 +1,21 @@ +function Get-StockInfo { + param( + $stock, + [datetime]$startDate, + [datetime]$endDate + ) + + Process { + + if(!$endDate) { $endDate = $startDate} + + $baseUrl = "http://query.yahooapis.com/v1/public/yql?q=" + $q = @" +select * from yahoo.finance.historicaldata where symbol = "$($stock)" and startDate = "$($startDate.ToString('yyyy-MM-dd'))" and endDate = "$($endDate.ToString('yyyy-MM-dd'))" +"@ + $suffix = "&env=store://datatables.org/alltableswithkeys&format=json" + $r=Invoke-RestMethod ($baseUrl + $q + $suffix) + $r.query.results.quote + + } +} \ No newline at end of file diff --git a/Examples/Stocks/GetMSFT.ps1 b/Examples/Stocks/GetMSFT.ps1 new file mode 100644 index 0000000..3d91b31 --- /dev/null +++ b/Examples/Stocks/GetMSFT.ps1 @@ -0,0 +1,14 @@ +$Symbol = "MSFT" + +. .\Get-StockInfo.ps1 + +rm *.xlsx + +$chart = New-ExcelChart -XRange Date -YRange Volume ` + -ChartType ColumnStacked ` + -Column 9 -Title "$Symbol Volume" + +Get-StockInfo $Symbol 11/2 11/30 | + Export-Excel .\stocks.xlsx -Show ` + -AutoSize -AutoNameRange ` + -ExcelChartDefinition $chart \ No newline at end of file