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

51 lines
1.7 KiB
PowerShell

# Dot sourcing the reqs file will make
. .\Generate-Cpps-reqs.ps1
$cme_file_url = "ftp://ftp.cmegroup.com/pub/fprf/csv/cmeg.fut.prf.csv"
$csv_save_path = ".\cmeg.fut.prf.csv"
$output_file = ".\cme_reference_data.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
$mic_grouping = $a | select Sym, Exch | Group Sym | Sort Name
# Automated header disclaimer
@"
#
# Entire file generated by automated script. DO NOT EDIT!
# source: tools/cpp_helper/generate-cpps.ps1
#
"@ | out-file -Encoding ascii $output_file
# cpps
"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}`n" | out-file -Encoding ascii $output_file -Append
# mics
"CmeSymbolMics`n{`n`tvalue`n`t{" | out-file -Encoding ascii $output_file -Append
$mic_grouping | % {
"`t`tcme_mic {{ key: `"{0}`" value: {1} }}" -f $_.Group[0].Sym, $cme_mics[$_.Group[0].Exch] } `
| out-file -Encoding ascii $output_file -Append
"`t}`n}" | out-file -Encoding ascii $output_file -Append
Remove-Item $csv_save_path -Force
# You can now copy the output file to defaults assuming all looks good
# Copy-Item .\cme_reference_data.conf ..\..\src\lib\config\defaults\ -Force
# Remove-Item cme_reference_data.conf