diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 00000000..62c7209a --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,15 @@ +version = 1 + +test_patterns = ["*/test/**"] + +exclude_patterns = [ + "*/data/**", + "*/examples/**" +] + +[[analyzers]] +name = "python" +enabled = true + + [analyzers.meta] + runtime_version = "3.x.x" \ No newline at end of file diff --git a/dco/Prajjwal Nijhara.dco b/dco/Prajjwal Nijhara.dco new file mode 100644 index 00000000..dc58e904 --- /dev/null +++ b/dco/Prajjwal Nijhara.dco @@ -0,0 +1,9 @@ +1) I, Prajjwal Nijhara, certify that all work committed with the commit message +"covered by: Prajjwal Nijhara.dco" is my original work and I own the copyright +to this work. I agree to contribute this code under the Apache 2.0 license. + +2) I understand and agree all contribution including all personal +information I submit with it is maintained indefinitely and may be +redistributed consistent with the open source license(s) involved. + +This certification is effective for all code contributed from 2020-04-28 to 9999-01-01. diff --git a/gs_quant/api/fred/data.py b/gs_quant/api/fred/data.py index 40759861..cdcb722b 100644 --- a/gs_quant/api/fred/data.py +++ b/gs_quant/api/fred/data.py @@ -137,7 +137,7 @@ def construct_dataframe_with_types(self, dataset_id: str, data: pd.Series) -> pd :param data: Data to convert with correct types :return: Dataframe with correct types """ - if len(data) and isinstance(data, pd.Series): + if data and isinstance(data, pd.Series): return data.to_frame() else: return pd.DataFrame({}) diff --git a/gs_quant/api/gs/content.py b/gs_quant/api/gs/content.py index f18c2adb..07312456 100644 --- a/gs_quant/api/gs/content.py +++ b/gs_quant/api/gs/content.py @@ -47,7 +47,7 @@ def get_contents( tags: set = None, offset: int = 0, limit: int = 10, - order_by: dict = {'direction': OrderBy.DESC, 'field': 'createdTime'} + order_by: dict = None ) -> List[ContentResponse]: """ Get contents for given parameters @@ -69,6 +69,8 @@ def get_contents( >>> GsSession.use() >>> contents = GsContentApi.get_contents(channels=['G10']) """ + if order_by is None: + order_by = {'direction': OrderBy.DESC, 'field': 'createdTime'} if limit and limit > 1000: raise ValueError('Limit is too large. Limit must be <= 1000.') diff --git a/gs_quant/target/backtests.py b/gs_quant/target/backtests.py index 3cb832a4..457ff11d 100644 --- a/gs_quant/target/backtests.py +++ b/gs_quant/target/backtests.py @@ -2552,9 +2552,11 @@ def __init__( trading_parameters: BacktestTradingParameters, index_initial_value: float, underliers: Tuple[BacktestStrategyUnderlier, ...] = None, - measures: Tuple[Union[FlowVolBacktestMeasure, str], ...] = ['ALL MEASURES'], + measures: Tuple[Union[FlowVolBacktestMeasure, str], ...] = None, name: str = None - ): + ): + if measures is None: + measures = ['ALL MEASURES'] super().__init__() self.index_initial_value = index_initial_value self.underliers = underliers diff --git a/gs_quant/timeseries/measures.py b/gs_quant/timeseries/measures.py index e09dbbf9..3af1cd4d 100644 --- a/gs_quant/timeseries/measures.py +++ b/gs_quant/timeseries/measures.py @@ -1321,6 +1321,15 @@ def vol_term(asset: Asset, strike_reference: VolReference, relative_strike: Real raise NotImplementedError('realtime forward term not implemented') # TODO if asset.asset_class == AssetClass.FX: + if strike_reference in (VolReference.FORWARD, VolReference.SPOT) and relative_strike != 100: + raise MqValueError('relative strike must be 100 for Spot or Forward strike reference') + if strike_reference == VolReference.NORMALIZED: + raise MqValueError(f'strike reference {strike_reference} not supported for FX') + if strike_reference == VolReference.DELTA_NEUTRAL and relative_strike != 0: + raise MqValueError('relative_strike must be 0 for delta_neutral') + + if strike_reference == VolReference.DELTA_PUT: + relative_strike *= -1 sr_string, relative_strike = _preprocess_implied_vol_strikes_fx(strike_reference, relative_strike) asset_id = cross_stored_direction_for_fx_vol(asset) buffer = 1 # FX vol data is loaded later