Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Powershell Script For Windows User. #384

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions powershell/download-klines.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This is a simple powershell script to download klines by given parameters for Windows user.

$symbols = @("BNBUSDT", "BTCUSDT") # add symbols here to download
$intervals = @("1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1mo")
$years = @("2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024")
$months = 1..12 | ForEach-Object { ("{0:D2}" -f $_) }

$baseurl = "https://data.binance.vision/data/spot/monthly/klines"

foreach ($symbol in $symbols) {
foreach ($interval in $intervals) {
foreach ($year in $years) {
foreach ($month in $months) {
$url = "${baseurl}/${symbol}/${interval}/${symbol}-${interval}-${year}-${month}.zip"
try {
$webRequest = Invoke-WebRequest -Uri $url -Method HEAD -ErrorAction Stop
if ($webRequest.StatusCode -eq 200) {
Invoke-WebRequest -Uri $url -OutFile "$symbol-$interval-$year-$month.zip"
Write-Output "downloaded: $url"
} else {
Write-Output "File not exist: $url"
}
} catch {
Write-Output "File not exist: $url"
}
}
}
}
}