-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
274 additions
and
4,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Type: PACTA | ||
Description: Run PACTA. | ||
Depends: | ||
dplyr, | ||
jsonlite, | ||
pacta.portfolio.allocate, | ||
pacta.portfolio.audit, | ||
pacta.portfolio.import, | ||
pacta.portfolio.utils, | ||
readr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"data_dir": "../pacta-data/2021Q4", | ||
"portfolio_path": "input_dir/default_portfolio.csv", | ||
"output_dir": "output_dir", | ||
"start_year": 2021, | ||
"equity_market_list": ["GlobalMarket", "DevelopedMarket", "EmergingMarket"], | ||
"scenario_sources_list": ["GECO2022", "IPR2021", "ISF2021", "WEO2022"], | ||
"scenario_geographies_list": ["Global", "GlobalAggregate", "NonOECD", "OECD"], | ||
"sector_list": ["Power", "Automotive", "Oil&Gas", "Coal", "Steel", "Aviation", "Cement"], | ||
"has_map": false, | ||
"project_code": "GENERAL" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
isin,market_value,currency | ||
XS1297557172,6821206,USD | ||
DE000A1R07L4,4724723,USD | ||
US345370BV11,5619252,USD | ||
CND10001QD60,1124438,USD | ||
XS2356040357,3076756,USD | ||
US31428XAY22,8235607,USD | ||
FR0012650281,641235,USD | ||
FR001400F2Q0,4190307,USD | ||
USQ94606AE22,4118654,USD | ||
US911312BB15,5414864,USD | ||
INE331A07273,2972779,USD | ||
INE481G07166,3244497,USD | ||
INE010A08065,4488737,USD | ||
US86614RAF47,5793655,USD | ||
FR0124261621,1581767,USD | ||
US60937CAA36,900439,USD | ||
US93317QAD79,9993273,USD | ||
TH0148034703,8657460,USD | ||
XS2325566847,9459870,USD | ||
US02076XAC65,3952496,USD | ||
US880779BA01,3506143,USD | ||
USU88125AC04,3401211,USD | ||
INE208A07281,8670483,USD | ||
US69373UAA51,267878,USD | ||
US12594KAA07,4094599,USD | ||
US205677AB38,3309593,USD | ||
US69370RAK32,3519158,USD | ||
US707887A@47,1577541,USD | ||
US166764AA86,6575752,USD | ||
US71654QCP54,7084677,USD | ||
INE206D08162,6210214,USD | ||
US745310AB85,709698,USD | ||
CA44882ZXZ12,2809584,USD | ||
JP360540AR10,9641731,USD | ||
CA44885ZEQ96,9683822,USD | ||
INE017A08235,3910673,USD | ||
XS1555576641,2598631,USD | ||
XS1381693248,2117715,USD | ||
NO0010892870,8899756,USD | ||
NO0010806912,7280862,USD | ||
USU85795AQ29,2560264,USD | ||
JP338603AA35,6806168,USD | ||
DE000A2GESQ1,1567613,USD | ||
INE114A07802,8605761,USD | ||
US03938LAA26,2698943,USD | ||
KR7005380001,9338795,USD | ||
CNE100000Q35,1068423,USD | ||
KYG3777B1032,9637388,USD | ||
US5787871038,5467105,USD | ||
SE0016844831,4168401,USD | ||
TW0002646007,6371201,USD | ||
INE646L01027,8355228,USD | ||
US38045R2067,7952384,USD | ||
PHY1234G1032,180886,USD | ||
US00910M1009,6809079,USD | ||
INE070A01015,1013567,USD | ||
CNE000000XV4,8873793,USD | ||
PK0059501012,5829360,USD | ||
INE583C01021,6059486,USD | ||
MYL5000OO004,6433976,USD | ||
AU000000BCB5,9186193,USD | ||
US03940R1077,265189,USD | ||
ID1000162902,1712519,USD | ||
US03485P3001,4712749,USD | ||
CNE0000017V2,5989615,USD | ||
NL0010545661,3343735,USD | ||
CNE000000FH0,8915246,USD | ||
US6937181088,9800223,USD | ||
US9288541082,7226287,USD | ||
CA62910L1022,9449577,USD | ||
IL0011419699,7746343,USD | ||
SE0020180917,1788562,USD | ||
AU000000BUY9,1578448,USD | ||
KR7096770003,860209,USD | ||
US45325E2019,4071578,USD | ||
CA45790B7088,8510107,USD | ||
US0188021085,7030638,USD | ||
JP3981200003,344741,USD | ||
GB00B1VNSX38,6493591,USD | ||
BRENGICDAM16,9257903,USD | ||
MHY271836006,1571628,USD | ||
MHY2687W1241,2627572,USD | ||
TH0363010R10,8711798,USD | ||
JP3247600004,4447848,USD | ||
IL0065100930,1121308,USD | ||
QA000A0KD6K3,6405719,USD | ||
US92023R4074,8204370,USD | ||
JP3342000001,8564047,USD | ||
US88031M1099,149263,USD | ||
TW0009957001,4538558,USD |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
suppressPackageStartupMessages({ | ||
library(pacta.portfolio.utils) | ||
library(pacta.portfolio.import) | ||
library(pacta.portfolio.audit) | ||
library(dplyr) | ||
library(readr) | ||
library(jsonlite) | ||
}) | ||
|
||
|
||
# ------------------------------------------------------------------------- | ||
|
||
cfg_path <- commandArgs(trailingOnly = TRUE) | ||
if (length(cfg_path) == 0 || cfg_path == "") { cfg_path <- "input_dir/default_config.json" } | ||
cfg <- fromJSON(cfg_path) | ||
|
||
|
||
# load necessary input data ---------------------------------------------------- | ||
|
||
currencies <- readRDS(file.path(cfg$data_dir, "currencies.rds")) | ||
|
||
fund_data <- readRDS(file.path(cfg$data_dir, "fund_data.rds")) | ||
total_fund_list <- readRDS(file.path(cfg$data_dir, "total_fund_list.rds")) | ||
isin_to_fund_table <- readRDS(file.path(cfg$data_dir, "isin_to_fund_table.rds")) | ||
|
||
fin_data <- readRDS(file.path(cfg$data_dir, "financial_data.rds")) | ||
|
||
entity_info <- get_entity_info(dir = cfg$data_dir) | ||
|
||
abcd_flags_equity <- readRDS(file.path(cfg$data_dir, "abcd_flags_equity.rds")) | ||
abcd_flags_bonds <- readRDS(file.path(cfg$data_dir, "abcd_flags_bonds.rds")) | ||
|
||
entity_emission_intensities <- readRDS(file.path(cfg$data_dir, "iss_entity_emission_intensities.rds")) | ||
average_sector_emission_intensities <- readRDS(file.path(cfg$data_dir, "iss_average_sector_emission_intensities.rds")) | ||
|
||
|
||
# Portfolios ------------------------------------------------------------------- | ||
|
||
portfolio_raw <- read_portfolio_csv(cfg$portfolio_path) | ||
|
||
portfolio <- process_raw_portfolio( | ||
portfolio_raw = portfolio_raw, | ||
fin_data = fin_data, | ||
fund_data = fund_data, | ||
entity_info = entity_info, | ||
currencies = currencies, | ||
total_fund_list = total_fund_list, | ||
isin_to_fund_table = isin_to_fund_table | ||
) | ||
|
||
# FIXME: this is necessary because pacta.portfolio.allocate::add_revenue_split() | ||
# was removed in #142, but later we realized that it had a sort of hidden | ||
# behavior where if there is no revenue data it maps the security_mapped_sector | ||
# column of the portfolio data to financial_sector, which is necessary later | ||
portfolio <- | ||
portfolio %>% | ||
mutate( | ||
has_revenue_data = FALSE, | ||
financial_sector = .data$security_mapped_sector | ||
) | ||
|
||
portfolio <- create_ald_flag(portfolio, comp_fin_data = abcd_flags_equity, debt_fin_data = abcd_flags_bonds) | ||
|
||
portfolio_total <- add_portfolio_flags(portfolio) | ||
|
||
portfolio_overview <- portfolio_summary(portfolio_total) | ||
|
||
audit_file <- create_audit_file(portfolio_total, has_revenue = FALSE) | ||
|
||
emissions_totals <- calculate_portfolio_financed_emissions( | ||
portfolio_total, | ||
entity_info, | ||
entity_emission_intensities, | ||
average_sector_emission_intensities | ||
) | ||
|
||
|
||
# Saving ----------------------------------------------------------------------- | ||
|
||
export_audit_information_data( | ||
audit_file_ = audit_file, | ||
portfolio_total_ = portfolio_total, | ||
folder_path = cfg$output_dir | ||
) | ||
|
||
saveRDS(portfolio_total, file.path(cfg$output_dir, "total_portfolio.rds")) | ||
saveRDS(portfolio_overview, file.path(cfg$output_dir, "overview_portfolio.rds")) | ||
saveRDS(audit_file, file.path(cfg$output_dir, "audit_file.rds")) | ||
write_csv(audit_file, file.path(cfg$output_dir, "audit_file.csv")) | ||
saveRDS(emissions_totals, file.path(cfg$output_dir, "emissions.rds")) |
Oops, something went wrong.