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 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
83 changes: 83 additions & 0 deletions 0_global_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,89 @@ 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)

project_report_name <<- cfg$reporting$project_report_name
display_currency <<- cfg$reporting$display_currency
currency_exchange_value <<- as.numeric(cfg$reporting$currency_exchange_value)

financial_timestamp <<- cfg$parameters$timestamp
dataprep_timestamp <<- cfg$parameters$dataprep_timestamp

start_year <<- as.numeric(cfg$parameters$start_year)
time_horizon <<- as.numeric(cfg$parameters$horizon_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

tech_roadmap_sectors <<- cfg$sectors$tech_roadmap_sectors
pacta_sectors_not_analysed <<- cfg$sectors$pacta_sectors_not_analysed
sector_list <<- c(tech_roadmap_sectors, pacta_sectors_not_analysed)

scenario_sources_list <<- cfg$scenario_sources_list
scenario_geographies_list <<- cfg$scenario_geography_list
asset_types <<- cfg$asset_types
equity_market_list <<- cfg$equity_market_list

grouping_variables <<- cfg$grouping_variables

green_techs <<- cfg$sectors$green_techs
alignment_techs <<- cfg$sectors$alignment_techs

shock_year <<- cfg$stress_test$shock_year


# meta_investor_name <<- cfg$ComparisonBenchmarks$MetaInvestorName
# meta_portfolio_name <<- cfg$ComparisonBenchmarks$MetaPortfolioName

inc_meta_portfolio <<- cfg$ComparisonBenchmarks$CreateMetaPortfolio
if (is.null(inc_meta_portfolio)) {
inc_meta_portfolio <<- FALSE
}

has_map <<- cfg$methodology$has_map
if (is.null(has_map)) {
has_map <<- TRUE
warning("Warning: has_map set to standard value (TRUE) as it is not defined in the parameter file")
}

has_sb <<- cfg$methodology$has_sb
if (is.null(has_sb)) {
has_sb <<- FALSE
warning("Warning: has_sb set to standard value (FALSE) as it is not defined in the parameter file")
}

has_credit <<- cfg$methodology$has_credit
if (is.null(has_credit)) {
has_credit <<- FALSE
warning("Warning: has_credit set to standard value (FALSE) as it is not defined in the parameter file")
}

has_revenue <<- cfg$methodology$has_revenue
if (is.null(has_revenue)) {
has_revenue <<- FALSE
warning("Warning: has_revenue set to standard value (FALSE) as it is not defined in the parameter file")
}

inc_emission_factors <<- cfg$methodology$inc_emissionfactors
if (is.null(inc_emission_factors)) {
inc_emission_factors <<- FALSE
warning("Warning: inc_emission_factors set to standard value (FALSE) as it is not defined in the parameter file")
}

inc_stresstest <<- cfg$methodology$inc_stresstest
if (is.null(inc_stresstest)) {
inc_stresstest <<- FALSE
warning("Warning: inc_stresstest set to standard value (FALSE) as it is not defined in the parameter file")
}

}

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_
)
}

64 changes: 0 additions & 64 deletions parameter_files/AnalysisParameters.yml

This file was deleted.

90 changes: 90 additions & 0 deletions parameter_files/ProjectParameters_CHPA2020.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
default:

reporting:
project_report_name: swiss
display_currency: CHF
currency_exchange_value: 1.03

parameters:
timestamp: 2019Q4
dataprep_timestamp: 2019Q4_250220
start_year: 2020
horizon_year: 5
select_scenario: WEO2019_SDS
scenario_auto: ETP2017_B2DS
scenario_other: ETP2017_B2DS
scenario_shipping: SBTI_SBTI
portfolio_allocation_method: portfolio_weight
scenario_geography: Global

methodology:
has_map: TRUE
has_sb: FALSE
has_revenue: FALSE
has_credit: FALSE
inc_emissionfactors: TRUE
inc_stresstest: TRUE

sectors:
tech_roadmap_sectors:
- Power
- Automotive
- Oil&Gas
- Coal
pacta_sectors_not_analysed:
- Shipping
- Steel
- Aviation
- Cement
green_techs:
- RenewablesCap
- HydroCap
- NuclearCap
- Hybrid
- Electric
- FuelCell
- Hybrid_HDV
- Electric_HDV
- FuelCell_HDV
- Dc-Electric Arc Furnace
- Ac-Electric Arc Furnace
alignment_techs:
- RenewablesCap
- CoalCap
- Coal
- Oil
- Gas
- Electric
- ICE

asset_types:
- Equity
- Bonds
- Others
- Funds

scenario_sources_list:
- ETP2017
- WEO2019
- WEO2020
- GECO2019

scenario_geography_list:
- Global
- GlobalAggregate
- NonOECD
- OECD

equity_market_list:
- GlobalMarket
- DevelopedMarket
- EmergingMarket

grouping_variables:
- investor_name
- portfolio_name

stress_test:
shock_year: 2030


Loading