Skip to content

Commit

Permalink
Chore: Make release 1.0.70
Browse files Browse the repository at this point in the history
  • Loading branch information
martinroberson authored and DominicCYK committed Mar 27, 2024
1 parent 3f9bd37 commit 312e082
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 133 deletions.
33 changes: 13 additions & 20 deletions gs_quant/api/gs/reports.py
Expand Up @@ -178,7 +178,6 @@ def get_factor_risk_report_results(cls,
@classmethod
def get_factor_risk_report_view(cls,
risk_report_id: str,
view: str = None,
factor: str = None,
factor_category: str = None,
currency: Currency = None,
Expand All @@ -188,26 +187,27 @@ def get_factor_risk_report_view(cls,

query_string = urllib.parse.urlencode(
dict(filter(lambda item: item[1] is not None,
dict(view=view, factor=factor, factorCategory=factor_category,
dict(factor=factor, factorCategory=factor_category,
currency=currency, startDate=start_date, endDate=end_date, unit=unit).items())))

url = f'/risk/factors/reports/{risk_report_id}/views?{query_string}'
return GsSession.current._get(url)
GsSession.current.api_version = "v2"
url = f'/factor/risk/{risk_report_id}/views?{query_string}'
response = GsSession.current._get(url)
GsSession.current.api_version = "v1"
return response

@classmethod
def get_factor_risk_report_table(cls,
risk_report_id: str,
mode: FactorRiskTableMode = None,
factors: List[str] = None,
factor_categories: List[str] = None,
unit: str = None,
currency: Currency = None,
date: dt.date = None,
start_date: dt.date = None,
end_date: dt.date = None,
order_by_column: str = None,
order_type: OrderType = None) -> dict:
url = f'/risk/factors/reports/{risk_report_id}/tables?'
end_date: dt.date = None) -> dict:

GsSession.current.api_version = "v2"
url = f'/factor/risk/{risk_report_id}/tables?'
if mode is not None:
url += f'&mode={mode.value}'
if unit is not None:
Expand All @@ -220,17 +220,10 @@ def get_factor_risk_report_table(cls,
url += f'&startDate={start_date.strftime("%Y-%m-%d")}'
if end_date is not None:
url += f'&endDate={end_date.strftime("%Y-%m-%d")}'
if factors is not None:
factors = map(urllib.parse.quote, factors)
url += f'&factor={"&factor=".join(factors)}'
if factor_categories is not None:
url += f'&factorCategory={"&factorCategory=".join(factor_categories)}'
if order_by_column is not None:
url += f'&orderByColumn={order_by_column}'
if order_type is not None:
url += f'&orderType={order_type}'

return GsSession.current._get(url)
response = GsSession.current._get(url)
GsSession.current.api_version = "v1"
return response

@classmethod
def get_brinson_attribution_results(cls,
Expand Down
Expand Up @@ -106,7 +106,6 @@
"source": [
"# Get Pnl By Type Table\n",
"table_data = risk_report.get_view(\n",
" mode=FactorRiskViewsMode.Attribution,\n",
" start_date=risk_report.latest_end_date - relativedelta(years=1),\n",
" end_date=risk_report.latest_end_date).get('factorCategoriesTable')\n",
"\n",
Expand Down
Expand Up @@ -63,7 +63,6 @@
"outputs": [],
"source": [
"risk_data = risk_report.get_view(\n",
" mode=FactorRiskViewsMode.Risk,\n",
" start_date=risk_report.latest_end_date - relativedelta(years=1),\n",
" end_date=risk_report.latest_end_date)\n",
"\n",
Expand Down Expand Up @@ -129,7 +128,7 @@
"metadata": {
"pycharm": {
"name": "#%%\n"
}
}
},
"outputs": [],
"source": [
Expand All @@ -151,7 +150,7 @@
"metadata": {
"pycharm": {
"name": "#%%\n"
}
}
},
"outputs": [],
"source": [
Expand All @@ -173,7 +172,7 @@
"metadata": {
"pycharm": {
"name": "#%%\n"
}
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -230,4 +229,4 @@
},
"nbformat": 4,
"nbformat_minor": 1
}
}
Expand Up @@ -125,7 +125,6 @@
"outputs": [],
"source": [
"attr_data = risk_report.get_view(\n",
" mode=FactorRiskViewsMode.Attribution,\n",
" start_date=risk_report.earliest_start_date,\n",
" end_date=risk_report.latest_end_date,\n",
" unit=FactorRiskUnit.Notional\n",
Expand Down
Expand Up @@ -129,7 +129,6 @@
"outputs": [],
"source": [
"category_table = risk_report.get_view(\n",
" mode=FactorRiskViewsMode.Risk,\n",
" start_date=risk_report.latest_end_date,\n",
" end_date=risk_report.latest_end_date,\n",
" unit=FactorRiskUnit.Notional\n",
Expand Down Expand Up @@ -171,7 +170,6 @@
"outputs": [],
"source": [
"factor_table = risk_report.get_view(\n",
" mode=FactorRiskViewsMode.Risk,\n",
" factor_category='Style',\n",
" start_date=risk_report.latest_end_date,\n",
" end_date=risk_report.latest_end_date,\n",
Expand Down Expand Up @@ -241,7 +239,6 @@
"outputs": [],
"source": [
"risk_data = risk_report.get_view(\n",
" mode=FactorRiskViewsMode.Risk,\n",
" start_date=risk_report.earliest_start_date,\n",
" end_date=risk_report.latest_end_date,\n",
" unit=FactorRiskUnit.Notional\n",
Expand Down

0 comments on commit 312e082

Please sign in to comment.