Skip to content

Commit

Permalink
Pn/anonymize (#306)
Browse files Browse the repository at this point in the history
* Added LEI to anonymization

* remove unused companies in anonymization

* Update to writer in NB #5

* bumped version

* Can read CTA locally if requests fails

* add portfolio coverage NB

* Remove data provider temp example

* Added link to new NB in docs

* Changed to .csv in NB

* Fixed filtering error in NB

* Update weights in example portfolio
  • Loading branch information
mountainrambler authored Aug 31, 2023
1 parent dee0716 commit f4bd7db
Show file tree
Hide file tree
Showing 12 changed files with 467 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pip install -e .
For installing the latest stable release in PyPi run:

```bash
pip install sbti
pip install sbti-finance-tool
```

## Development
Expand Down
17 changes: 11 additions & 6 deletions SBTi/data/sbti.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ def __init__(
self.c = config
# Fetch CTA file from SBTi website
resp = requests.get(self.c.CTA_FILE_URL)
# Write CTA file to disk
with open(self.c.FILE_TARGETS, 'wb') as output:
output.write(resp.content)
print(f'Status code from fetching the CTA file: {resp.status_code}, 200 = OK')
# Read CTA file into pandas dataframe
# Suppress warning about openpyxl - check if this is still needed in the released version.
# If status code == 200 then Write CTA file to disk
if resp.status_code == 200:
with open(self.c.FILE_TARGETS, 'wb') as output:
output.write(resp.content)
print(f'Status code from fetching the CTA file: {resp.status_code}, 200 = OK')
# Read CTA file into pandas dataframe
# Suppress warning about openpyxl - check if this is still needed in the released version.
else:
print('Could not fetch the CTA file from the SBTi website')
print('Will read older file from this package version')

warnings.filterwarnings('ignore', category=UserWarning, module='openpyxl')
self.targets = pd.read_excel(self.c.FILE_TARGETS)

Expand Down
Binary file added SBTi/inputs/current-Companies-Taking-Action.xlsx
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ methodology <https://sciencebasedtargets.org/wp-content/uploads/2020/09/Temperat
- 4b `Aggregation of ready made scores from data providers <https://colab.research.google.com/github/ScienceBasedTargets/SBTi-finance-tool/blob/main/examples/4b_portfolio_agg_readymade_TS.ipynb>`__
5. `Reporting <https://colab.research.google.com/github/ScienceBasedTargets/SBTi-finance-tool/blob/main/examples/5_reporting.ipynb>`__

We have also added a simplied notebook for calculations of Portfolio Coverage using only a portfolio file:
`Simplified PC <https://colab.research.google.com/github/ScienceBasedTargets/SBTi-finance-tool/blob/main/examples/Simple_portfolio_coverage.ipynb>`__



Jupyter Notebooks
-----------------
Expand Down
21 changes: 17 additions & 4 deletions examples/5_reporting.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -16,6 +17,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -60,6 +62,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -97,6 +100,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -131,6 +135,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -158,6 +163,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -179,6 +185,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -200,6 +207,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -248,6 +256,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -271,6 +280,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -326,6 +336,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -348,6 +359,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -357,6 +369,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -380,13 +393,13 @@
"provider_filename = 'provider.xlsx'\n",
"portfolio.to_excel(portfolio_filename, index=False)\n",
"\n",
"writer = pd.ExcelWriter(provider_filename, engine='openpyxl')\n",
"provider.data['fundamental_data'].to_excel(writer, sheet_name='fundamental_data')\n",
"provider.data['target_data'].to_excel(writer, sheet_name='target_data')\n",
"writer.save()"
"with pd.ExcelWriter(provider_filename, engine='openpyxl') as writer:\n",
" provider.data['fundamental_data'].to_excel(writer, sheet_name='fundamental_data')\n",
" provider.data['target_data'].to_excel(writer, sheet_name='target_data')\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
Loading

0 comments on commit f4bd7db

Please sign in to comment.