Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Clean web tool script 3 #350

Merged
merged 25 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
27 changes: 27 additions & 0 deletions 0_global_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,33 @@ set_col_types <- function(grouping_variables, fixed_col_types) {
return(port_col_types)
}

set_project_parameters <- function(file_path){
cfg <- config::get(file = file_path)

report_name <<- cfg$reporting$report_name
exec_summary_name <<- cfg$reporting$report_name

financial_timestamp <<- cfg$parameters$timestamp
start_year <<- as.numeric(cfg$parameters$start_year)
select_scenario <<- cfg$parameters$select_scenario
scenario_auto <<- cfg$parameters$scenario_auto
scenario_other <<- cfg$parameters$scenario_other
scenario_shipping <<- cfg$parameters$scenario_shipping
portfolio_allocation_method <<- cfg$parameters$portfolio_allocation_method
scenario_geography <<- cfg$parameters$scenario_geography
display_currency <<- cfg$parameters$display_currency
currency_exchange_value <<- as.numeric(cfg$parameters$currency_exchange_value)

tech_roadmap_sectors <<- cfg$sectors$tech_roadmap_sectors
pacta_sectors_not_analysed <<- cfg$sectors$pacta_sectors_not_analysed
twodi_sectors <<- cfg$sectors$twodi_sectors
green_techs <<- cfg$sectors$green_techs
alignment_techs <<- cfg$sectors$alignment_techs

shock_year <<- cfg$stress_test$shock_year

}

set_global_parameters <- function(file_path) {
cfg <- config::get(file = file_path)

Expand Down
101 changes: 101 additions & 0 deletions 0_web_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,104 @@ check_file_size <- function(folder_to_check) {
files_to_check <- list.files(folder_to_check, full.names = T)
any(file.size(files_to_check) > 100e6)
}

empty_portfolio_results <- function(){
tibble(
"investor_name" = NA_character_, "portfolio_name" = NA_character_,
"scenario" = NA_character_, "allocation" = NA_character_,
"equity_market" = NA_character_, "scenario_geography" = NA_character_,
"year" = NA_integer_, "ald_sector" = NA_character_, "technology" = NA_character_,
"plan_tech_prod" = NA_integer_, "plan_alloc_wt_tech_prod" = NA_integer_,
"plan_carsten" = NA_integer_, "plan_emission_factor" = NA_integer_,
"scen_tech_prod" = NA_integer_, "scen_alloc_wt_tech_prod" = NA_integer_,
"scen_carsten" = NA_integer_, "scen_emission_factor" = NA_integer_,
"plan_sec_prod" = NA_integer_, "plan_alloc_wt_sec_prod" = NA_integer_,
"plan_sec_carsten" = NA_integer_, "plan_sec_emissions_factor" = NA_integer_,
"scen_sec_prod" = NA_integer_, "scen_alloc_wt_sec_prod" = NA_integer_,
"scen_sec_carsten" = NA_integer_, "scen_sec_emissions_factor" = NA_integer_,
"plan_tech_share" = NA_integer_, "scen_tech_share" = NA_integer_,
"trajectory_deviation" = NA_integer_, "trajectory_alignment" = NA_integer_
)
}

empty_company_results <- function(){
tibble(
"investor_name" = NA_character_, "portfolio_name" = NA_character_,
"scenario" = NA_character_, "allocation" = NA_character_,
"id" = NA_character_, "company_name" = NA_character_,
"financial_sector" = NA_character_, "port_weight" = NA_integer_,
"allocation_weight" = NA_integer_, "plan_br_dist_alloc_wt" = NA_integer_,
"scen_br_dist_alloc_wt" = NA_integer_,
"equity_market" = NA_character_, "scenario_geography" = NA_character_,
"year" = NA_integer_, "ald_sector" = NA_character_, "technology" = NA_character_,
"plan_tech_prod" = NA_integer_, "plan_alloc_wt_tech_prod" = NA_integer_,
"plan_carsten" = NA_integer_, "plan_emission_factor" = NA_integer_,
"scen_tech_prod" = NA_integer_, "scen_alloc_wt_tech_prod" = NA_integer_,
"scen_carsten" = NA_integer_, "scen_emission_factor" = NA_integer_,
"plan_sec_prod" = NA_integer_, "plan_alloc_wt_sec_prod" = NA_integer_,
"plan_sec_carsten" = NA_integer_, "plan_sec_emissions_factor" = NA_integer_,
"scen_sec_prod" = NA_integer_, "scen_alloc_wt_sec_prod" = NA_integer_,
"scen_sec_carsten" = NA_integer_, "scen_sec_emissions_factor" = NA_integer_,
"plan_tech_share" = NA_integer_, "scen_tech_share" = NA_integer_,
"trajectory_deviation" = NA_integer_, "trajectory_alignment" = NA_integer_
)
}

empty_emissions_results <- function(){
tibble("investor_name" = NA_character_, "portfolio_name" = NA_character_,
"asset_type" = NA_character_, "sector" = NA_character_,
"weighted_sector_emissions" = NA_real_)
}

empty_audit_file <- function(){
tibble("investor_name" = NA_character_, "portfolio_name" = NA_character_,
"asset_type" = NA_character_, "valid_input" = NA, "isin" = NA_character_,
"direct_holding" = NA, "value_usd" = NA_real_)
}

empty_map_results <- function(){
tibble(
"investor_name" = NA_character_, "portfolio_name" = NA_character_,
"ald_location" = NA_character_, "year" = NA_integer_,
"ald_sector" = NA_character_, "technology" = NA_character_,
"financial_sector" = NA_character_, "allocation" = NA_character_,
"allocation_weight" = NA_integer_, "ald_production_unit" = NA_character_,
"plan_alloc_wt_tech_prod" = NA_integer_, "plan_alloc_wt_sec_prod" = NA_integer_,
"equity_market" = NA_character_, "scenario" = NA_character_,
"scenario_geography" = NA_character_
)
}

empty_st_results <- function(){
tibble(
"investor_name" = NA_character_, "portfolio_name" = NA_character_,
"ald_sector" = NA_character_, "technology" = NA_character_,
"scenario_geography" = NA_character_, "VaR_technology" = NA_real_,
"asset_portfolio_value" = NA_real_, "VaR_Sector" = NA_real_,
"scenario_name" = NA_character_, "technology_exposure" = NA_real_,
"ector_exposure" = NA_real_, "sector_loss" = NA_real_,
"climate_relevant_var" = NA_real_, "portfolio_aum" = NA_real_,
"portfolio_loss_percentage" = NA_real_, "year_of_shock" = NA_integer_,
"duration_of_shock" = NA_integer_, "production_shock_percentage" = NA_real_
)
}

empty_ipr_st_results <- function(){
tibble(
"investor_name" = NA_character_, "portfolio_name" = NA_character_,
"sector" = NA_character_, "subsector" = NA_character_,
"exposure" = NA_real_, "description" = NA_character_,
"scenario" = NA_character_, "shock" = NA_real_,
"loss" = NA_real_
)
}

empty_portfolio_overview <- function(){
tibble(
"investor_name" = NA_character_, "portfolio_name" = NA_character_,
"asset_type" = NA_character_, "financial_sector" = NA_character_,
"valid_input" = NA, "valid_value_usd" = NA_real_,
"asset_value_usd" = NA_real_, "portfolio_value_usd" = NA_real_
)
}

Loading