Files
spark/tools/cpp_helper/Generate-Cpps.ps1
T

65 lines
1.5 KiB
PowerShell

$known_good = @{
"6A" = 1000
"6B" = 625
"6D" = 1000
"6E" = 1250
"6J" = 1250
"CL" = 1000
"EMD" = 100
"ES" = 50
"GC" = 100
"GE" = 2500
"HE" = 400
"HG" = 5000
"HO" = 420
"LE" = 400
"M6E" = 125
"NG" = 100
"NQ" = 20
"QM" = 500
"RB" = 420
"RTY" = 50
"SI" = 5000
"VX" = 1000
"YI" = 10
"YM" = 5
"ZB" = 1000
"ZC" = 50
"ZF" = 1000
"ZL" = 600
"ZM" = 100
"ZN" = 1000
"ZQ" = 4167
"ZS" = 50
"ZT" = 2000
"ZW" = 50
}
$cme_file_url = "ftp://ftp.cmegroup.com/pub/fprf/csv/cmeg.fut.prf.csv"
$csv_save_path = ".\cmeg.fut.prf.csv"
$output_file = ".\cpp_config.conf"
# turn off console update progress while downloading
$CurrentProgressPref = $ProgressPreference;
$ProgressPreference = "SilentlyContinue";
Invoke-WebRequest -Uri $cme_file_url -OutFile $csv_save_path
$ProgressPreference = $CurrentProgressPref
$a = Import-Csv $csv_save_path
$b = $a | select Sym, Mult | Group Sym | Sort Name
@"
# Generated by automated script. DO NOT EDIT!
# source: tools/cpp_helper/generate-cpps.ps1
"@ | out-file -Encoding ascii $output_file
"CppConfig`n{`n`tvalue`n`t{" | out-file -Encoding ascii $output_file -Append
$b | % {
if ($known_good.ContainsKey($_.Group[0].Sym)) {
$cpp = $known_good[$_.Group[0].Sym]
} else {
$cpp = $_.Group[0].Mult
}
"`t`tcpp_entry {{ key: `"{0}`" value: {1} }}" -f $_.Group[0].Sym, $cpp } `
| out-file -Encoding ascii $output_file -Append
"`t}`n}" | out-file -Encoding ascii $output_file -Append
Remove-Item $csv_save_path -Force