How to use field_metadata method in lisa

Best Python code snippet using lisa_python

instrument.py

Source:instrument.py Github

copy

Full Screen

1"""2Copyright 2019 Goldman Sachs.3Licensed under the Apache License, Version 2.0 (the "License");4you may not use this file except in compliance with the License.5You may obtain a copy of the License at6 http://www.apache.org/licenses/LICENSE-2.07Unless required by applicable law or agreed to in writing,8software distributed under the License is distributed on an9"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY10KIND, either express or implied. See the License for the11specific language governing permissions and limitations12under the License.13"""14from gs_quant.base import *15from gs_quant.common import *16import datetime17from typing import Dict, Optional, Tuple, Union18from dataclasses import dataclass, field19from dataclasses_json import LetterCase, config, dataclass_json20from gs_quant.instrument.core import Instrument21@handle_camel_case_args22@dataclass_json(letter_case=LetterCase.CAMEL)23@dataclass(unsafe_hash=True, repr=False)24class AssetRef(Instrument):25 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)26 product_code: Optional[ProductCode] = field(default=None, metadata=field_metadata)27 size: Optional[float] = field(default=None, metadata=field_metadata)28 asset_id: Optional[str] = field(default=None, metadata=field_metadata)29 number_of_options: Optional[float] = field(default=None, metadata=field_metadata)30 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Cross_Asset, metadata=field_metadata)31 type_: Optional[AssetType] = field(init=False, default=AssetType.Any, metadata=config(field_name='type', exclude=exclude_none))32 name: Optional[str] = field(default=None, metadata=name_metadata)33@handle_camel_case_args34@dataclass_json(letter_case=LetterCase.CAMEL)35@dataclass(unsafe_hash=True, repr=False)36class Bond(Instrument):37 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)38 identifier: Optional[str] = field(default=None, metadata=field_metadata)39 identifier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)40 size: Optional[float] = field(default=None, metadata=field_metadata)41 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)42 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)43 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Cross_Asset, metadata=field_metadata)44 type_: Optional[AssetType] = field(init=False, default=AssetType.Bond, metadata=config(field_name='type', exclude=exclude_none))45 name: Optional[str] = field(default=None, metadata=name_metadata)46@handle_camel_case_args47@dataclass_json(letter_case=LetterCase.CAMEL)48@dataclass(unsafe_hash=True, repr=False)49class Cash(Instrument):50 currency: Optional[Currency] = field(default=None, metadata=field_metadata)51 payment_date: Optional[datetime.date] = field(default=None, metadata=field_metadata)52 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)53 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Cash, metadata=field_metadata)54 type_: Optional[AssetType] = field(init=False, default=AssetType.Cash, metadata=config(field_name='type', exclude=exclude_none))55 name: Optional[str] = field(default=None, metadata=name_metadata)56@handle_camel_case_args57@dataclass_json(letter_case=LetterCase.CAMEL)58@dataclass(unsafe_hash=True, repr=False)59class CommodOTCOptionPeriod(Instrument):60 start: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)61 end: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)62 quantity: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)63 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)64 type_: Optional[AssetType] = field(init=False, default=AssetType.OptionPeriod, metadata=config(field_name='type', exclude=exclude_none))65 name: Optional[str] = field(default=None, metadata=name_metadata)66@handle_camel_case_args67@dataclass_json(letter_case=LetterCase.CAMEL)68@dataclass(unsafe_hash=True, repr=False)69class CommodOTCSwapLeg(Instrument):70 fixing_currency: Optional[CurrencyName] = field(default=None, metadata=field_metadata)71 leg_description: Optional[str] = field(default=None, metadata=field_metadata)72 contract: Optional[str] = field(default=None, metadata=field_metadata)73 fixing_currency_source: Optional[str] = field(default=None, metadata=field_metadata)74 underlier: Optional[str] = field(default=None, metadata=field_metadata)75 quantity_multiplier: Optional[int] = field(default=None, metadata=field_metadata)76 fixed_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)77 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)78 type_: Optional[AssetType] = field(init=False, default=AssetType.SwapLeg, metadata=config(field_name='type', exclude=exclude_none))79 name: Optional[str] = field(default=None, metadata=name_metadata)80@handle_camel_case_args81@dataclass_json(letter_case=LetterCase.CAMEL)82@dataclass(unsafe_hash=True, repr=False)83class CommodSwap(Instrument):84 commodity: Optional[str] = field(default=None, metadata=field_metadata)85 quantity: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)86 contract: Optional[str] = field(default=None, metadata=field_metadata)87 fixing_currency_source: Optional[str] = field(default=None, metadata=field_metadata)88 start: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)89 floating_type: Optional[str] = field(default=None, metadata=field_metadata)90 number_of_periods: Optional[int] = field(default=None, metadata=field_metadata)91 quantity_unit: Optional[str] = field(default=None, metadata=field_metadata)92 fixed_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)93 settlement: Optional[str] = field(default=None, metadata=field_metadata)94 fixing_currency: Optional[CurrencyName] = field(default=None, metadata=field_metadata)95 fixed_price_unit: Optional[str] = field(default=None, metadata=field_metadata)96 commodity_reference_price: Optional[str] = field(default=None, metadata=field_metadata)97 end: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)98 quantity_period: Optional[Period] = field(default=None, metadata=field_metadata)99 strategy: Optional[str] = field(default=None, metadata=field_metadata)100 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)101 type_: Optional[AssetType] = field(init=False, default=AssetType.Swap, metadata=config(field_name='type', exclude=exclude_none))102 name: Optional[str] = field(default=None, metadata=name_metadata)103@handle_camel_case_args104@dataclass_json(letter_case=LetterCase.CAMEL)105@dataclass(unsafe_hash=True, repr=False)106class EqAutoroll(Instrument):107 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)108 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)109 first_fixing_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)110 last_fixing_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)111 fixing_frequency: Optional[str] = field(default=None, metadata=field_metadata)112 trigger_level: Optional[float] = field(default=None, metadata=field_metadata)113 buffer_level: Optional[float] = field(default=None, metadata=field_metadata)114 local_return_cap: Optional[float] = field(default=None, metadata=field_metadata)115 upside_leverage: Optional[float] = field(default=None, metadata=field_metadata)116 initial_fixing_override: Optional[float] = field(default=None, metadata=field_metadata)117 apply_trigger_level_shift: Optional[str] = field(default=None, metadata=field_metadata)118 trigger_level_shift: Optional[float] = field(default=None, metadata=field_metadata)119 notional: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)120 business_day_calendar: Optional[str] = field(default=None, metadata=field_metadata)121 payment_currency: Optional[Currency] = field(default=None, metadata=field_metadata)122 settlement_delay: Optional[str] = field(default=None, metadata=field_metadata)123 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)124 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)125 premium: Optional[float] = field(default=None, metadata=field_metadata)126 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)127 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)128 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)129 type_: Optional[AssetType] = field(init=False, default=AssetType.Autoroll, metadata=config(field_name='type', exclude=exclude_none))130 name: Optional[str] = field(default=None, metadata=name_metadata)131@handle_camel_case_args132@dataclass_json(letter_case=LetterCase.CAMEL)133@dataclass(unsafe_hash=True, repr=False)134class EqBinary(Instrument):135 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)136 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)137 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)138 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)139 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)140 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)141 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)142 currency: Optional[str] = field(default=None, metadata=field_metadata)143 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)144 premium_settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)145 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)146 type_: Optional[AssetType] = field(init=False, default=AssetType.Binary, metadata=config(field_name='type', exclude=exclude_none))147 name: Optional[str] = field(default=None, metadata=name_metadata)148@handle_camel_case_args149@dataclass_json(letter_case=LetterCase.CAMEL)150@dataclass(unsafe_hash=True, repr=False)151class EqCliquet(Instrument):152 return_style: Optional[str] = field(default='Rate of Return', metadata=field_metadata)153 last_valuation_date: Optional[datetime.date] = field(default=None, metadata=field_metadata)154 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)155 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)156 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)157 payment_frequency: Optional[str] = field(default='Maturity', metadata=field_metadata)158 global_cap: Optional[float] = field(default=1000000.0, metadata=field_metadata)159 first_valuation_date: Optional[datetime.date] = field(default=None, metadata=field_metadata)160 currency: Optional[Currency] = field(default=None, metadata=field_metadata)161 global_floor: Optional[float] = field(default=-1000000.0, metadata=field_metadata)162 strike_price: Optional[float] = field(default=None, metadata=field_metadata)163 return_type: Optional[str] = field(default='Sum', metadata=field_metadata)164 valuation_period: Optional[str] = field(default=None, metadata=field_metadata)165 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)166 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)167 type_: Optional[AssetType] = field(init=False, default=AssetType.Cliquet, metadata=config(field_name='type', exclude=exclude_none))168 name: Optional[str] = field(default=None, metadata=name_metadata)169@handle_camel_case_args170@dataclass_json(letter_case=LetterCase.CAMEL)171@dataclass(unsafe_hash=True, repr=False)172class EqConvertibleBond(Instrument):173 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)174 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)175 premium_settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)176 ref_currency: Optional[Currency] = field(default=None, metadata=field_metadata)177 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)178 quantity: Optional[float] = field(default=None, metadata=field_metadata)179 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)180 type_: Optional[AssetType] = field(init=False, default=AssetType.Convertible, metadata=config(field_name='type', exclude=exclude_none))181 name: Optional[str] = field(default=None, metadata=name_metadata)182@handle_camel_case_args183@dataclass_json(letter_case=LetterCase.CAMEL)184@dataclass(unsafe_hash=True, repr=False)185class EqForward(Instrument):186 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)187 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)188 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)189 forward_price: Optional[float] = field(default=None, metadata=field_metadata)190 number_of_shares: Optional[int] = field(default=1, metadata=field_metadata)191 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)192 type_: Optional[AssetType] = field(init=False, default=AssetType.Forward, metadata=config(field_name='type', exclude=exclude_none))193 name: Optional[str] = field(default=None, metadata=name_metadata)194@handle_camel_case_args195@dataclass_json(letter_case=LetterCase.CAMEL)196@dataclass(unsafe_hash=True, repr=False)197class EqFuture(Instrument):198 total_quantity: float = field(default=None, metadata=field_metadata)199 identifier: Optional[str] = field(default=None, metadata=field_metadata)200 identifier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)201 underlier: Optional[str] = field(default=None, metadata=field_metadata)202 multiplier: Optional[float] = field(default=None, metadata=field_metadata)203 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)204 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)205 quantity: Optional[float] = field(default=None, metadata=field_metadata)206 currency: Optional[Currency] = field(default=None, metadata=field_metadata)207 traded_price: Optional[float] = field(default=0.0, metadata=field_metadata)208 trade_as: Optional[str] = field(default=None, metadata=field_metadata)209 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)210 type_: Optional[AssetType] = field(init=False, default=AssetType.Future, metadata=config(field_name='type', exclude=exclude_none))211 name: Optional[str] = field(default=None, metadata=name_metadata)212@handle_camel_case_args213@dataclass_json(letter_case=LetterCase.CAMEL)214@dataclass(unsafe_hash=True, repr=False)215class EqOption(Instrument):216 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)217 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)218 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)219 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)220 option_style: Optional[OptionStyle] = field(default=None, metadata=field_metadata)221 number_of_options: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)222 exchange: Optional[str] = field(default=None, metadata=field_metadata)223 multiplier: Optional[float] = field(default=None, metadata=field_metadata)224 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)225 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)226 premium: Optional[float] = field(default=0.0, metadata=field_metadata)227 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)228 valuation_time: Optional[ValuationTime] = field(default=None, metadata=field_metadata)229 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)230 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)231 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)232 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)233 trade_as: Optional[TradeAs] = field(default=None, metadata=field_metadata)234 future_contract: Optional[str] = field(default=None, metadata=field_metadata)235 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)236 type_: Optional[AssetType] = field(init=False, default=AssetType.Option, metadata=config(field_name='type', exclude=exclude_none))237 name: Optional[str] = field(default=None, metadata=name_metadata)238 def scale_in_place(self, scaling: Optional[float] = None):239 if self.unresolved is None:240 raise RuntimeError('Can only scale resolved instruments')241 if scaling is None or scaling == 1:242 return243 244 if scaling < 0:245 flip_dict = {BuySell.Buy: BuySell.Sell, BuySell.Sell: BuySell.Buy}246 self.buy_sell = flip_dict[self.buy_sell]247 248 self.number_of_options *= abs(scaling)249 return250@handle_camel_case_args251@dataclass_json(letter_case=LetterCase.CAMEL)252@dataclass(unsafe_hash=True, repr=False)253class EqOptionLeg(Instrument):254 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)255 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)256 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)257 option_style: Optional[OptionStyle] = field(default=None, metadata=field_metadata)258 multiplier: Optional[float] = field(default=None, metadata=field_metadata)259 number_of_options: Optional[float] = field(default=None, metadata=field_metadata)260 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)261 valuation_time: Optional[ValuationTime] = field(default=None, metadata=field_metadata)262 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)263 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)264 premium: Optional[float] = field(default=None, metadata=field_metadata)265 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)266 trade_as: Optional[TradeAs] = field(default=None, metadata=field_metadata)267 exchange: Optional[str] = field(default=None, metadata=field_metadata)268 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)269 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)270 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)271 type_: Optional[AssetType] = field(init=False, default=AssetType.OptionLeg, metadata=config(field_name='type', exclude=exclude_none))272 name: Optional[str] = field(default=None, metadata=name_metadata)273@handle_camel_case_args274@dataclass_json(letter_case=LetterCase.CAMEL)275@dataclass(unsafe_hash=True, repr=False)276class EqStock(Instrument):277 identifier: Optional[str] = field(default=None, metadata=field_metadata)278 identifier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)279 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)280 traded_price: Optional[float] = field(default=0.0, metadata=field_metadata)281 currency: Optional[Currency] = field(default=None, metadata=field_metadata)282 quantity: Optional[float] = field(default=None, metadata=field_metadata)283 settlement_date: Optional[datetime.date] = field(default=None, metadata=field_metadata)284 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)285 type_: Optional[AssetType] = field(init=False, default=AssetType.Single_Stock, metadata=config(field_name='type', exclude=exclude_none))286 name: Optional[str] = field(default=None, metadata=name_metadata)287@handle_camel_case_args288@dataclass_json(letter_case=LetterCase.CAMEL)289@dataclass(unsafe_hash=True, repr=False)290class EqSynthetic(Instrument):291 underlier: Union[float, str] = field(default=None, metadata=field_metadata)292 expiry: str = field(default=None, metadata=field_metadata)293 currency: Optional[Currency] = field(default=None, metadata=field_metadata)294 swap_type: Optional[str] = field(default='Eq Swap', metadata=field_metadata)295 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)296 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)297 effective_date: Optional[datetime.date] = field(default=None, metadata=field_metadata)298 num_of_underlyers: Optional[float] = field(default=None, metadata=field_metadata)299 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)300 type_: Optional[AssetType] = field(init=False, default=AssetType.Synthetic, metadata=config(field_name='type', exclude=exclude_none))301 name: Optional[str] = field(default=None, metadata=name_metadata)302@handle_camel_case_args303@dataclass_json(letter_case=LetterCase.CAMEL)304@dataclass(unsafe_hash=True, repr=False)305class EqVarianceSwap(Instrument):306 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)307 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)308 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)309 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)310 variance_cap: Optional[float] = field(default=None, metadata=field_metadata)311 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)312 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)313 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)314 type_: Optional[AssetType] = field(init=False, default=AssetType.VarianceSwap, metadata=config(field_name='type', exclude=exclude_none))315 name: Optional[str] = field(default=None, metadata=name_metadata)316@handle_camel_case_args317@dataclass_json(letter_case=LetterCase.CAMEL)318@dataclass(unsafe_hash=True, repr=False)319class FXBinary(Instrument):320 pair: Optional[str] = field(default=None, metadata=field_metadata)321 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)322 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)323 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)324 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)325 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)326 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)327 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)328 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)329 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)330 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)331 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)332 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)333 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)334 type_: Optional[AssetType] = field(init=False, default=AssetType.Binary, metadata=config(field_name='type', exclude=exclude_none))335 name: Optional[str] = field(default=None, metadata=name_metadata)336@handle_camel_case_args337@dataclass_json(letter_case=LetterCase.CAMEL)338@dataclass(unsafe_hash=True, repr=False)339class FXDoubleKnockout(Instrument):340 pair: Optional[str] = field(default=None, metadata=field_metadata)341 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)342 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)343 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)344 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)345 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)346 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)347 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)348 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)349 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)350 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)351 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)352 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)353 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)354 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)355 knock_in_or_out: Optional[InOut] = field(default=None, metadata=field_metadata)356 lower_barrier_level: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)357 upper_barrier_level: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)358 knockout_convention: Optional[KnockoutConvention] = field(default=None, metadata=field_metadata)359 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)360 type_: Optional[AssetType] = field(init=False, default=AssetType.DoubleKnockout, metadata=config(field_name='type', exclude=exclude_none))361 name: Optional[str] = field(default=None, metadata=name_metadata)362@handle_camel_case_args363@dataclass_json(letter_case=LetterCase.CAMEL)364@dataclass(unsafe_hash=True, repr=False)365class FXDoubleOneTouch(Instrument):366 pair: Optional[str] = field(default=None, metadata=field_metadata)367 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)368 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)369 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)370 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)371 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)372 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)373 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)374 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)375 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)376 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)377 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)378 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)379 lower_barrier_level: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)380 upper_barrier_level: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)381 payout_type: Optional[PayoutType] = field(default=None, metadata=field_metadata)382 knockout_convention: Optional[KnockoutConvention] = field(default=None, metadata=field_metadata)383 touch_or_no_touch: Optional[TouchNoTouch] = field(default=None, metadata=field_metadata)384 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)385 type_: Optional[AssetType] = field(init=False, default=AssetType.DoubleTouch, metadata=config(field_name='type', exclude=exclude_none))386 name: Optional[str] = field(default=None, metadata=name_metadata)387@handle_camel_case_args388@dataclass_json(letter_case=LetterCase.CAMEL)389@dataclass(unsafe_hash=True, repr=False)390class FXEuropeanKnockout(Instrument):391 pair: Optional[str] = field(default=None, metadata=field_metadata)392 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)393 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)394 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)395 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)396 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)397 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)398 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)399 expiration_date: Optional[str] = field(default=None, metadata=field_metadata)400 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)401 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)402 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)403 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)404 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)405 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)406 barrier_level: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)407 knock_up_or_down: Optional[UpDown] = field(default=None, metadata=field_metadata)408 knock_in_or_out: Optional[InOut] = field(default=None, metadata=field_metadata)409 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)410 type_: Optional[AssetType] = field(init=False, default=AssetType.EuropeanKnockout, metadata=config(field_name='type', exclude=exclude_none))411 name: Optional[str] = field(default=None, metadata=name_metadata)412@handle_camel_case_args413@dataclass_json(letter_case=LetterCase.CAMEL)414@dataclass(unsafe_hash=True, repr=False)415class FXForward(Instrument):416 pair: Optional[str] = field(default=None, metadata=field_metadata)417 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)418 forward_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)419 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)420 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)421 notional_amount_in_other_currency: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)422 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)423 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)424 type_: Optional[AssetType] = field(init=False, default=AssetType.Forward, metadata=config(field_name='type', exclude=exclude_none))425 name: Optional[str] = field(default=None, metadata=name_metadata)426@handle_camel_case_args427@dataclass_json(letter_case=LetterCase.CAMEL)428@dataclass(unsafe_hash=True, repr=False)429class FXKnockout(Instrument):430 pair: Optional[str] = field(default=None, metadata=field_metadata)431 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)432 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)433 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)434 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)435 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)436 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)437 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)438 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)439 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)440 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)441 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)442 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)443 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)444 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)445 knock_in_or_out: Optional[InOut] = field(default=None, metadata=field_metadata)446 knock_up_or_down: Optional[UpDown] = field(default=None, metadata=field_metadata)447 barrier_level: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)448 knockout_convention: Optional[KnockoutConvention] = field(default=None, metadata=field_metadata)449 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)450 type_: Optional[AssetType] = field(init=False, default=AssetType.Knockout, metadata=config(field_name='type', exclude=exclude_none))451 name: Optional[str] = field(default=None, metadata=name_metadata)452@handle_camel_case_args453@dataclass_json(letter_case=LetterCase.CAMEL)454@dataclass(unsafe_hash=True, repr=False)455class FXMultiCrossBinaryLeg(Instrument):456 pair: Optional[str] = field(default=None, metadata=field_metadata)457 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)458 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)459 fixing_source: Optional[str] = field(default=None, metadata=field_metadata)460 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)461 type_: Optional[AssetType] = field(init=False, default=AssetType.MultiCrossBinaryLeg, metadata=config(field_name='type', exclude=exclude_none))462 name: Optional[str] = field(default=None, metadata=name_metadata)463@handle_camel_case_args464@dataclass_json(letter_case=LetterCase.CAMEL)465@dataclass(unsafe_hash=True, repr=False)466class FXOneTouch(Instrument):467 pair: Optional[str] = field(default=None, metadata=field_metadata)468 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)469 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)470 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)471 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)472 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)473 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)474 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)475 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)476 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)477 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)478 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)479 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)480 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)481 knock_up_or_down: Optional[UpDown] = field(default=None, metadata=field_metadata)482 knockout_convention: Optional[KnockoutConvention] = field(default=None, metadata=field_metadata)483 touch_or_no_touch: Optional[TouchNoTouch] = field(default=None, metadata=field_metadata)484 payout_type: Optional[PayoutType] = field(default=None, metadata=field_metadata)485 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)486 type_: Optional[AssetType] = field(init=False, default=AssetType.OneTouch, metadata=config(field_name='type', exclude=exclude_none))487 name: Optional[str] = field(default=None, metadata=name_metadata)488@handle_camel_case_args489@dataclass_json(letter_case=LetterCase.CAMEL)490@dataclass(unsafe_hash=True, repr=False)491class FXOption(Instrument):492 pair: Optional[str] = field(default=None, metadata=field_metadata)493 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)494 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)495 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)496 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)497 notional_amount_in_other_currency: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)498 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)499 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)500 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)501 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)502 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)503 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)504 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)505 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)506 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)507 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)508 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)509 type_: Optional[AssetType] = field(init=False, default=AssetType.Option, metadata=config(field_name='type', exclude=exclude_none))510 name: Optional[str] = field(default=None, metadata=name_metadata)511@handle_camel_case_args512@dataclass_json(letter_case=LetterCase.CAMEL)513@dataclass(unsafe_hash=True, repr=False)514class FXOptionLeg(Instrument):515 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)516 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)517 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)518 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)519 notional_amount_in_other_currency: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)520 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)521 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)522 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)523 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)524 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)525 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)526 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)527 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)528 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)529 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)530 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)531 type_: Optional[AssetType] = field(init=False, default=AssetType.OptionLeg, metadata=config(field_name='type', exclude=exclude_none))532 name: Optional[str] = field(default=None, metadata=name_metadata)533@handle_camel_case_args534@dataclass_json(letter_case=LetterCase.CAMEL)535@dataclass(unsafe_hash=True, repr=False)536class FXShiftingBermForward(Instrument):537 pair: Optional[str] = field(default=None, metadata=field_metadata)538 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)539 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)540 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)541 notional_amount_in_other_currency: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)542 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)543 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)544 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)545 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)546 window_start_date: Optional[str] = field(default=None, metadata=field_metadata)547 exercise_decision_freq: Optional[str] = field(default=None, metadata=field_metadata)548 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)549 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)550 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)551 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)552 type_: Optional[AssetType] = field(init=False, default=AssetType.ShiftingBermForward, metadata=config(field_name='type', exclude=exclude_none))553 name: Optional[str] = field(default=None, metadata=name_metadata)554@handle_camel_case_args555@dataclass_json(letter_case=LetterCase.CAMEL)556@dataclass(unsafe_hash=True, repr=False)557class FXTarfScheduleLeg(Instrument):558 profit_strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)559 loss_strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)560 fixing_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)561 payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)562 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)563 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)564 type_: Optional[AssetType] = field(init=False, default=AssetType.TarfScheduleLeg, metadata=config(field_name='type', exclude=exclude_none))565 name: Optional[str] = field(default=None, metadata=name_metadata)566@handle_camel_case_args567@dataclass_json(letter_case=LetterCase.CAMEL)568@dataclass(unsafe_hash=True, repr=False)569class FXVolatilitySwap(Instrument):570 pair: Optional[str] = field(default=None, metadata=field_metadata)571 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)572 strike_vol: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)573 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)574 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)575 first_fixing_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)576 last_fixing_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)577 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)578 fixing_source: Optional[str] = field(default=None, metadata=field_metadata)579 fixing_frequency: Optional[str] = field(default=None, metadata=field_metadata)580 annualization_factor: Optional[float] = field(default=None, metadata=field_metadata)581 calculate_mean_return: Optional[float] = field(default=0.0, metadata=field_metadata)582 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)583 type_: Optional[AssetType] = field(init=False, default=AssetType.VolatilitySwap, metadata=config(field_name='type', exclude=exclude_none))584 name: Optional[str] = field(default=None, metadata=name_metadata)585@handle_camel_case_args586@dataclass_json(letter_case=LetterCase.CAMEL)587@dataclass(unsafe_hash=True, repr=False)588class Forward(Instrument):589 currency: Optional[Currency] = field(default=None, metadata=field_metadata)590 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)591 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)592 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Cash, metadata=field_metadata)593 type_: Optional[AssetType] = field(init=False, default=AssetType.Forward, metadata=config(field_name='type', exclude=exclude_none))594 name: Optional[str] = field(default=None, metadata=name_metadata)595@handle_camel_case_args596@dataclass_json(letter_case=LetterCase.CAMEL)597@dataclass(unsafe_hash=True, repr=False)598class IRBondFuture(Instrument):599 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)600 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)601 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)602 currency: Optional[Currency] = field(default=None, metadata=field_metadata)603 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)604 exchange: Optional[str] = field(default=None, metadata=field_metadata)605 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)606 type_: Optional[AssetType] = field(init=False, default=AssetType.BondFuture, metadata=config(field_name='type', exclude=exclude_none))607 name: Optional[str] = field(default=None, metadata=name_metadata)608@handle_camel_case_args609@dataclass_json(letter_case=LetterCase.CAMEL)610@dataclass(unsafe_hash=True, repr=False)611class IRCap(Instrument):612 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)613 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)614 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)615 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)616 floating_rate_option: Optional[str] = field(default=None, metadata=field_metadata)617 floating_rate_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)618 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)619 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)620 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)621 cap_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)622 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)623 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)624 fee: Optional[float] = field(default=0.0, metadata=field_metadata)625 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)626 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)627 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)628 type_: Optional[AssetType] = field(init=False, default=AssetType.Cap, metadata=config(field_name='type', exclude=exclude_none))629 name: Optional[str] = field(default=None, metadata=name_metadata)630@handle_camel_case_args631@dataclass_json(letter_case=LetterCase.CAMEL)632@dataclass(unsafe_hash=True, repr=False)633class IRFloor(Instrument):634 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)635 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)636 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)637 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)638 floating_rate_option: Optional[str] = field(default=None, metadata=field_metadata)639 floating_rate_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)640 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)641 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)642 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)643 floor_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)644 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)645 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)646 fee: Optional[float] = field(default=0.0, metadata=field_metadata)647 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)648 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)649 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)650 type_: Optional[AssetType] = field(init=False, default=AssetType.Floor, metadata=config(field_name='type', exclude=exclude_none))651 name: Optional[str] = field(default=None, metadata=name_metadata)652@handle_camel_case_args653@dataclass_json(letter_case=LetterCase.CAMEL)654@dataclass(unsafe_hash=True, repr=False)655class InflationSwap(Instrument):656 pay_or_receive: Optional[PayReceive] = field(default=None, metadata=field_metadata)657 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)658 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)659 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)660 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)661 index: Optional[str] = field(default=None, metadata=field_metadata)662 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)663 fixed_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)664 fixed_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)665 fee: Optional[float] = field(default=0.0, metadata=field_metadata)666 base_cpi: Optional[float] = field(default=None, metadata=field_metadata)667 clearing_house: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)668 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)669 type_: Optional[AssetType] = field(init=False, default=AssetType.InflationSwap, metadata=config(field_name='type', exclude=exclude_none))670 name: Optional[str] = field(default=None, metadata=name_metadata)671 def scale_in_place(self, scaling: Optional[float] = None):672 if self.unresolved is None:673 raise RuntimeError('Can only scale resolved instruments')674 if scaling is None or scaling == 1:675 return676 677 if scaling < 0:678 flip_dict = {PayReceive.Pay: PayReceive.Receive, PayReceive.Receive: PayReceive.Pay}679 self.pay_or_receive = flip_dict[self.pay_or_receive]680 self.fee *= -1681 self.notional_amount *= abs(scaling)682 return683@handle_camel_case_args684@dataclass_json(letter_case=LetterCase.CAMEL)685@dataclass(unsafe_hash=True, repr=False)686class InstrumentsRepoIRDiscreteLock(Instrument):687 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)688 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)689 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)690 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)691 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)692 currency: Optional[Currency] = field(default=None, metadata=field_metadata)693 spot_clean_price: Optional[float] = field(default=None, metadata=field_metadata)694 settlement: Optional[str] = field(default=None, metadata=field_metadata)695 repo_rate: Optional[float] = field(default=None, metadata=field_metadata)696 forward_clean_price: Optional[float] = field(default=None, metadata=field_metadata)697 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Repo, metadata=field_metadata)698 type_: Optional[AssetType] = field(init=False, default=AssetType.Bond_Forward, metadata=config(field_name='type', exclude=exclude_none))699 name: Optional[str] = field(default=None, metadata=name_metadata)700@handle_camel_case_args701@dataclass_json(letter_case=LetterCase.CAMEL)702@dataclass(unsafe_hash=True, repr=False)703class CDIndex(Instrument):704 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)705 clearinghouse: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)706 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)707 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)708 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)709 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)710 first_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)711 first_roll_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)712 fee: Optional[float] = field(default=0.0, metadata=field_metadata)713 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)714 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)715 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)716 index_family: Optional[str] = field(default=None, metadata=field_metadata)717 index_for_basis: Optional[str] = field(default=None, metadata=field_metadata)718 index_series: Optional[float] = field(default=None, metadata=field_metadata)719 index_version: Optional[float] = field(default=None, metadata=field_metadata)720 isda_docs: Optional[str] = field(default='2014', metadata=config(field_name='ISDADocs', exclude=exclude_none))721 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Credit, metadata=field_metadata)722 type_: Optional[AssetType] = field(init=False, default=AssetType.Index, metadata=config(field_name='type', exclude=exclude_none))723 name: Optional[str] = field(default=None, metadata=name_metadata)724@handle_camel_case_args725@dataclass_json(letter_case=LetterCase.CAMEL)726@dataclass(unsafe_hash=True, repr=False)727class CDIndexOption(Instrument):728 automatic_exercise: Optional[float] = field(default=0.0, metadata=field_metadata)729 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)730 clearinghouse: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)731 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)732 earliest_exercise_time: Optional[str] = field(default=None, metadata=field_metadata)733 earliest_exercise_time_centre: Optional[str] = field(default=None, metadata=field_metadata)734 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)735 exercise_date_business_day_convention: Optional[BusinessDayConvention] = field(default='Following', metadata=field_metadata)736 exercise_holidays: Optional[str] = field(default=None, metadata=field_metadata)737 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)738 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)739 expiration_time_centre: Optional[str] = field(default=None, metadata=field_metadata)740 premium: Optional[float] = field(default=0.0, metadata=field_metadata)741 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)742 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)743 first_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)744 first_roll_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)745 index_family: Optional[str] = field(default=None, metadata=field_metadata)746 index_for_basis: Optional[str] = field(default=None, metadata=field_metadata)747 index_series: Optional[float] = field(default=None, metadata=field_metadata)748 index_version: Optional[float] = field(default=None, metadata=field_metadata)749 isda_docs: Optional[str] = field(default='2014', metadata=config(field_name='ISDADocs', exclude=exclude_none))750 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)751 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)752 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)753 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)754 fixed_rate: Optional[float] = field(default=None, metadata=field_metadata)755 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)756 strike_type: Optional[str] = field(default='Spread', metadata=field_metadata)757 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)758 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Credit, metadata=field_metadata)759 type_: Optional[AssetType] = field(init=False, default=AssetType.IndexOption, metadata=config(field_name='type', exclude=exclude_none))760 name: Optional[str] = field(default=None, metadata=name_metadata)761@handle_camel_case_args762@dataclass_json(letter_case=LetterCase.CAMEL)763@dataclass(unsafe_hash=True, repr=False)764class CommodOTCOptionLeg(Instrument):765 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)766 fixing_currency: Optional[CurrencyName] = field(default=None, metadata=field_metadata)767 premium: Optional[CommodPrice] = field(default=None, metadata=field_metadata)768 leg_description: Optional[str] = field(default=None, metadata=field_metadata)769 contract: Optional[str] = field(default=None, metadata=field_metadata)770 fixing_currency_source: Optional[str] = field(default=None, metadata=field_metadata)771 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)772 underlier: Optional[str] = field(default=None, metadata=field_metadata)773 premium_settlement: Optional[str] = field(default=None, metadata=field_metadata)774 quantity_multiplier: Optional[int] = field(default=None, metadata=field_metadata)775 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)776 type_: Optional[AssetType] = field(init=False, default=AssetType.OptionLeg, metadata=config(field_name='type', exclude=exclude_none))777 name: Optional[str] = field(default=None, metadata=name_metadata)778@handle_camel_case_args779@dataclass_json(letter_case=LetterCase.CAMEL)780@dataclass(unsafe_hash=True, repr=False)781class CommodOTCSwap(Instrument):782 quantity: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)783 legs: Optional[Tuple[CommodOTCSwapLeg, ...]] = field(default=None, metadata=field_metadata)784 start: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)785 end: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)786 number_of_periods: Optional[int] = field(default=None, metadata=field_metadata)787 quantity_unit: Optional[str] = field(default=None, metadata=field_metadata)788 quantity_period: Optional[Period] = field(default=None, metadata=field_metadata)789 strategy: Optional[str] = field(default=None, metadata=field_metadata)790 settlement: Optional[str] = field(default=None, metadata=field_metadata)791 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)792 type_: Optional[AssetType] = field(init=False, default=AssetType.SwapStrategy, metadata=config(field_name='type', exclude=exclude_none))793 name: Optional[str] = field(default=None, metadata=name_metadata)794@handle_camel_case_args795@dataclass_json(letter_case=LetterCase.CAMEL)796@dataclass(unsafe_hash=True, repr=False)797class CommodOption(Instrument):798 commodity: Optional[str] = field(default=None, metadata=field_metadata)799 number_of_periods: Optional[int] = field(default=None, metadata=field_metadata)800 quantity_unit: Optional[str] = field(default=None, metadata=field_metadata)801 currency_summary: Optional[CurrencyName] = field(default=None, metadata=field_metadata)802 option_types: Optional[Tuple[str, ...]] = field(default=None, metadata=field_metadata)803 settlement: Optional[str] = field(default=None, metadata=field_metadata)804 option_type: Optional[str] = field(default=None, metadata=field_metadata)805 strike_unit: Optional[str] = field(default=None, metadata=field_metadata)806 strikes: Optional[Tuple[str, ...]] = field(default=None, metadata=field_metadata)807 end: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)808 buy_sells: Optional[Tuple[str, ...]] = field(default=None, metadata=field_metadata)809 underlier_short_name: Optional[str] = field(default=None, metadata=field_metadata)810 settlement_frequency: Optional[str] = field(default=None, metadata=field_metadata)811 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)812 strike_currency: Optional[CurrencyName] = field(default=None, metadata=field_metadata)813 quantity: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)814 contract: Optional[str] = field(default=None, metadata=field_metadata)815 fixing_currency_source: Optional[str] = field(default=None, metadata=field_metadata)816 strike: Optional[str] = field(default=None, metadata=field_metadata)817 start: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)818 floating_type: Optional[str] = field(default=None, metadata=field_metadata)819 fixing_currency: Optional[CurrencyName] = field(default=None, metadata=field_metadata)820 commodity_reference_price: Optional[str] = field(default=None, metadata=field_metadata)821 quantity_period: Optional[str] = field(default=None, metadata=field_metadata)822 strategy: Optional[str] = field(default=None, metadata=field_metadata)823 premium: Optional[str] = field(default=None, metadata=field_metadata)824 period_details: Optional[Tuple[CommodOTCOptionPeriod, ...]] = field(default=None, metadata=field_metadata)825 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)826 type_: Optional[AssetType] = field(init=False, default=AssetType.Option, metadata=config(field_name='type', exclude=exclude_none))827 name: Optional[str] = field(default=None, metadata=name_metadata)828@handle_camel_case_args829@dataclass_json(letter_case=LetterCase.CAMEL)830@dataclass(unsafe_hash=True, repr=False)831class CommodVolVarSwap(Instrument):832 notional_currency: Optional[CurrencyName] = field(default=None, metadata=field_metadata)833 notional: Optional[float] = field(default=1.0, metadata=field_metadata)834 floating_rate_is_capped: Optional[str] = field(default=None, metadata=field_metadata)835 end_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)836 margined: Optional[float] = field(default=None, metadata=field_metadata)837 market_disruption_agreement: Optional[str] = field(default=None, metadata=field_metadata)838 mean_rule: Optional[CommodMeanRule] = field(default=None, metadata=field_metadata)839 divisor: Optional[str] = field(default=None, metadata=field_metadata)840 fixed_mean: Optional[float] = field(default=None, metadata=field_metadata)841 first_fixing: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)842 floating_rate_cap: Optional[float] = field(default=None, metadata=field_metadata)843 fx_fixing_source: Optional[str] = field(default=None, metadata=field_metadata)844 annualization_factor: Optional[float] = field(default=None, metadata=field_metadata)845 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)846 contract: Optional[str] = field(default=None, metadata=field_metadata)847 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)848 swap_type: Optional[str] = field(default=None, metadata=field_metadata)849 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)850 fixing_currency: Optional[CurrencyName] = field(default=None, metadata=field_metadata)851 asset_fixing_source: Optional[str] = field(default=None, metadata=field_metadata)852 sampling_frequency: Optional[str] = field(default=None, metadata=field_metadata)853 variance_convention: Optional[VarianceConvention] = field(default=None, metadata=field_metadata)854 extra_sampling_calendars: Optional[str] = field(default='--Blank--', metadata=field_metadata)855 asset: Optional[str] = field(default=None, metadata=field_metadata)856 start_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)857 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)858 type_: Optional[AssetType] = field(init=False, default=AssetType.VolVarSwap, metadata=config(field_name='type', exclude=exclude_none))859 name: Optional[str] = field(default=None, metadata=name_metadata)860@handle_camel_case_args861@dataclass_json(letter_case=LetterCase.CAMEL)862@dataclass(unsafe_hash=True, repr=False)863class EqOptionStrategy(Instrument):864 underlier: Union[float, str] = field(default=None, metadata=field_metadata)865 strategy: str = field(default=None, metadata=field_metadata)866 legs: Tuple[EqOptionLeg, ...] = field(default=None, metadata=field_metadata)867 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)868 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)869 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)870 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)871 option_style: Optional[OptionStyle] = field(default=None, metadata=field_metadata)872 number_of_options: Optional[float] = field(default=None, metadata=field_metadata)873 multiplier: Optional[float] = field(default=None, metadata=field_metadata)874 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)875 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)876 premium: Optional[float] = field(default=None, metadata=field_metadata)877 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)878 valuation_time: Optional[ValuationTime] = field(default=None, metadata=field_metadata)879 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)880 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)881 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)882 exchange: Optional[str] = field(default=None, metadata=field_metadata)883 trade_as: Optional[TradeAs] = field(default=None, metadata=field_metadata)884 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Equity, metadata=field_metadata)885 type_: Optional[AssetType] = field(init=False, default=AssetType.OptionStrategy, metadata=config(field_name='type', exclude=exclude_none))886 name: Optional[str] = field(default=None, metadata=name_metadata)887@handle_camel_case_args888@dataclass_json(letter_case=LetterCase.CAMEL)889@dataclass(unsafe_hash=True, repr=False)890class FRA(Instrument):891 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)892 clearing_house: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)893 clearing_legally_binding: Optional[float] = field(default=None, metadata=field_metadata)894 day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)895 fee: Optional[float] = field(default=0.0, metadata=field_metadata)896 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)897 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)898 fixed_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)899 frequency: Optional[str] = field(default=None, metadata=field_metadata)900 calendar: Optional[str] = field(default=None, metadata=field_metadata)901 rate_option: Optional[str] = field(default=None, metadata=field_metadata)902 maturity: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)903 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)904 payment_delay: Optional[str] = field(default=None, metadata=field_metadata)905 roll_convention: Optional[str] = field(default=None, metadata=field_metadata)906 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)907 spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)908 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)909 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)910 type_: Optional[AssetType] = field(init=False, default=AssetType.FRA, metadata=config(field_name='type', exclude=exclude_none))911 name: Optional[str] = field(default=None, metadata=name_metadata)912@handle_camel_case_args913@dataclass_json(letter_case=LetterCase.CAMEL)914@dataclass(unsafe_hash=True, repr=False)915class FXMultiCrossBinary(Instrument):916 legs: Tuple[FXMultiCrossBinaryLeg, ...] = field(default=None, metadata=field_metadata)917 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)918 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)919 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)920 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)921 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)922 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)923 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)924 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)925 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)926 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)927 type_: Optional[AssetType] = field(init=False, default=AssetType.MultiCrossBinary, metadata=config(field_name='type', exclude=exclude_none))928 name: Optional[str] = field(default=None, metadata=name_metadata)929@handle_camel_case_args930@dataclass_json(letter_case=LetterCase.CAMEL)931@dataclass(unsafe_hash=True, repr=False)932class FXOptionStrategy(Instrument):933 pair: Optional[str] = field(default=None, metadata=field_metadata)934 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)935 strategy_name: Optional[str] = field(default=None, metadata=field_metadata)936 legs: Optional[Tuple[FXOptionLeg, ...]] = field(default=None, metadata=field_metadata)937 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)938 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)939 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)940 notional_amount_in_other_currency: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)941 strike_price: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)942 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)943 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)944 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)945 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)946 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)947 expiration_time: Optional[str] = field(default=None, metadata=field_metadata)948 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)949 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)950 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)951 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)952 type_: Optional[AssetType] = field(init=False, default=AssetType.OptionStrategy, metadata=config(field_name='type', exclude=exclude_none))953 name: Optional[str] = field(default=None, metadata=name_metadata)954@handle_camel_case_args955@dataclass_json(letter_case=LetterCase.CAMEL)956@dataclass(unsafe_hash=True, repr=False)957class FXTarf(Instrument):958 pair: Optional[str] = field(default=None, metadata=field_metadata)959 new_or_unwind: Optional[NewOrUnwind] = field(default=None, metadata=field_metadata)960 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)961 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)962 profit_strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)963 loss_strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)964 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)965 settlement_currency: Optional[Currency] = field(default=None, metadata=field_metadata)966 fixing_rate_option: Optional[str] = field(default=None, metadata=field_metadata)967 method_of_settlement: Optional[OptionSettlementMethod] = field(default=None, metadata=field_metadata)968 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)969 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)970 premium_currency: Optional[Currency] = field(default=None, metadata=field_metadata)971 premium_payment_date: Optional[str] = field(default=None, metadata=field_metadata)972 long_or_short: Optional[LongShort] = field(default=None, metadata=field_metadata)973 european_knock_in: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)974 number_of_expiry: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)975 coupon_frequency: Optional[str] = field(default=None, metadata=field_metadata)976 first_fixing_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)977 leverage_ratio: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)978 target_type: Optional[TargetType] = field(default=None, metadata=field_metadata)979 target: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)980 schedules: Optional[Tuple[FXTarfScheduleLeg, ...]] = field(default=None, metadata=field_metadata)981 target_adj_notional_or_strike: Optional[NotionalOrStrike] = field(default=None, metadata=field_metadata)982 payment_on_hitting_target: Optional[TargetPaymentType] = field(default=None, metadata=field_metadata)983 settlement_rate_option: Optional[str] = field(default=None, metadata=field_metadata)984 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.FX, metadata=field_metadata)985 type_: Optional[AssetType] = field(init=False, default=AssetType.Tarf, metadata=config(field_name='type', exclude=exclude_none))986 name: Optional[str] = field(default=None, metadata=name_metadata)987@handle_camel_case_args988@dataclass_json(letter_case=LetterCase.CAMEL)989@dataclass(unsafe_hash=True, repr=False)990class IRAssetSwapFxdFlt(Instrument):991 asw_type: Optional[AswType] = field(default=None, metadata=field_metadata)992 clearing_house: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)993 fee: Optional[float] = field(default=None, metadata=field_metadata)994 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)995 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)996 fixed_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)997 fixed_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)998 fixed_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)999 fixed_holidays: Optional[str] = field(default=None, metadata=field_metadata)1000 fixed_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1001 fixed_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1002 floating_rate_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1003 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1004 floating_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1005 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1006 floating_rate_fx: Optional[float] = field(default=None, metadata=field_metadata)1007 floating_holidays: Optional[str] = field(default=None, metadata=field_metadata)1008 floating_maturity: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1009 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1010 identifier: Optional[str] = field(default=None, metadata=field_metadata)1011 identifier_type: Optional[str] = field(default=None, metadata=field_metadata)1012 floating_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1013 floating_rate_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1014 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1015 pay_or_receive: Optional[PayReceive] = field(default=None, metadata=field_metadata)1016 roll_convention: Optional[str] = field(default=None, metadata=field_metadata)1017 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1018 floating_rate_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1019 traded_clean_price: Optional[float] = field(default=100.0, metadata=field_metadata)1020 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1021 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1022 type_: Optional[AssetType] = field(init=False, default=AssetType.AssetSwapFxdFlt, metadata=config(field_name='type', exclude=exclude_none))1023 name: Optional[str] = field(default=None, metadata=name_metadata)1024@handle_camel_case_args1025@dataclass_json(letter_case=LetterCase.CAMEL)1026@dataclass(unsafe_hash=True, repr=False)1027class IRAssetSwapFxdFxd(Instrument):1028 asw_type: Optional[AswType] = field(default=None, metadata=field_metadata)1029 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1030 fee: Optional[float] = field(default=None, metadata=field_metadata)1031 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1032 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1033 fixed_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1034 fixed_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1035 fixed_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1036 fixed_holidays: Optional[str] = field(default=None, metadata=field_metadata)1037 fixed_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1038 fixed_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1039 coupon: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1040 fixed_rate_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1041 asset_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1042 asset_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1043 asset_frequency: Optional[str] = field(default=None, metadata=field_metadata)1044 asset_holidays: Optional[str] = field(default=None, metadata=field_metadata)1045 asset_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1046 identifier: Optional[str] = field(default=None, metadata=field_metadata)1047 identifier_type: Optional[str] = field(default=None, metadata=field_metadata)1048 asset_maturity: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1049 fixed_maturity: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1050 roll_convention: Optional[str] = field(default=None, metadata=field_metadata)1051 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1052 fixed_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1053 clean_price: Optional[float] = field(default=100.0, metadata=field_metadata)1054 settlement_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1055 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1056 type_: Optional[AssetType] = field(init=False, default=AssetType.AssetSwapFxdFxd, metadata=config(field_name='type', exclude=exclude_none))1057 name: Optional[str] = field(default=None, metadata=name_metadata)1058@handle_camel_case_args1059@dataclass_json(letter_case=LetterCase.CAMEL)1060@dataclass(unsafe_hash=True, repr=False)1061class IRBasisSwap(Instrument):1062 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1063 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1064 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1065 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1066 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1067 payer_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1068 payer_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1069 payer_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1070 payer_frequency: Optional[str] = field(default=None, metadata=field_metadata)1071 payer_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1072 payer_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1073 receiver_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1074 receiver_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1075 receiver_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1076 receiver_frequency: Optional[str] = field(default=None, metadata=field_metadata)1077 receiver_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1078 receiver_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1079 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1080 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1081 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1082 clearing_house: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)1083 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1084 type_: Optional[AssetType] = field(init=False, default=AssetType.BasisSwap, metadata=config(field_name='type', exclude=exclude_none))1085 name: Optional[str] = field(default=None, metadata=name_metadata)1086@handle_camel_case_args1087@dataclass_json(letter_case=LetterCase.CAMEL)1088@dataclass(unsafe_hash=True, repr=False)1089class IRBondOption(Instrument):1090 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1091 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1092 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1093 option_type: Optional[OptionType] = field(default=None, metadata=field_metadata)1094 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1095 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1096 strike_type: Optional[BondStrikeType] = field(default=None, metadata=field_metadata)1097 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1098 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1099 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1100 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1101 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1102 settlement: Optional[SettlementType] = field(default=None, metadata=field_metadata)1103 underlier_type: Optional[UnderlierType] = field(default=None, metadata=field_metadata)1104 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1105 type_: Optional[AssetType] = field(init=False, default=AssetType.BondOption, metadata=config(field_name='type', exclude=exclude_none))1106 name: Optional[str] = field(default=None, metadata=name_metadata)1107@handle_camel_case_args1108@dataclass_json(letter_case=LetterCase.CAMEL)1109@dataclass(unsafe_hash=True, repr=False)1110class IRCMSOption(Instrument):1111 cap_floor: Optional[str] = field(default=None, metadata=field_metadata)1112 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1113 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1114 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1115 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1116 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1117 index: Optional[str] = field(default=None, metadata=field_metadata)1118 rate_option: Optional[str] = field(default=None, metadata=field_metadata)1119 multiplier: Optional[float] = field(default=None, metadata=field_metadata)1120 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1121 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1122 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1123 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1124 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1125 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1126 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1127 type_: Optional[AssetType] = field(init=False, default=AssetType.CMSOption, metadata=config(field_name='type', exclude=exclude_none))1128 name: Optional[str] = field(default=None, metadata=name_metadata)1129@handle_camel_case_args1130@dataclass_json(letter_case=LetterCase.CAMEL)1131@dataclass(unsafe_hash=True, repr=False)1132class IRCMSOptionStrip(Instrument):1133 cap_floor: Optional[str] = field(default=None, metadata=field_metadata)1134 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1135 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1136 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1137 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1138 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1139 index: Optional[str] = field(default=None, metadata=field_metadata)1140 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1141 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1142 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1143 reset_delay: Optional[str] = field(default=None, metadata=field_metadata)1144 multiplier: Optional[float] = field(default=None, metadata=field_metadata)1145 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1146 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1147 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1148 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1149 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1150 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1151 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1152 type_: Optional[AssetType] = field(init=False, default=AssetType.CMSOptionStrip, metadata=config(field_name='type', exclude=exclude_none))1153 name: Optional[str] = field(default=None, metadata=name_metadata)1154@handle_camel_case_args1155@dataclass_json(letter_case=LetterCase.CAMEL)1156@dataclass(unsafe_hash=True, repr=False)1157class IRCMSSpreadOption(Instrument):1158 cap_floor: Optional[str] = field(default=None, metadata=field_metadata)1159 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1160 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1161 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1162 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1163 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1164 index1_tenor: Optional[str] = field(default=None, metadata=field_metadata)1165 index2_tenor: Optional[str] = field(default=None, metadata=field_metadata)1166 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1167 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1168 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1169 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1170 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1171 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1172 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1173 type_: Optional[AssetType] = field(init=False, default=AssetType.CMSSpreadOption, metadata=config(field_name='type', exclude=exclude_none))1174 name: Optional[str] = field(default=None, metadata=name_metadata)1175@handle_camel_case_args1176@dataclass_json(letter_case=LetterCase.CAMEL)1177@dataclass(unsafe_hash=True, repr=False)1178class IRCMSSpreadOptionStrip(Instrument):1179 cap_floor: Optional[str] = field(default=None, metadata=field_metadata)1180 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1181 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1182 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1183 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1184 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1185 index1: Optional[str] = field(default=None, metadata=field_metadata)1186 index2: Optional[str] = field(default=None, metadata=field_metadata)1187 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1188 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1189 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1190 reset_delay: Optional[str] = field(default=None, metadata=field_metadata)1191 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1192 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1193 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1194 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1195 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1196 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1197 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1198 type_: Optional[AssetType] = field(init=False, default=AssetType.CMSSpreadOptionStrip, metadata=config(field_name='type', exclude=exclude_none))1199 name: Optional[str] = field(default=None, metadata=name_metadata)1200@handle_camel_case_args1201@dataclass_json(letter_case=LetterCase.CAMEL)1202@dataclass(unsafe_hash=True, repr=False)1203class IRFixedLeg(Instrument):1204 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1205 fixed_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1206 fixed_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1207 fixed_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1208 fixed_holidays: Optional[str] = field(default=None, metadata=field_metadata)1209 fixed_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1210 fixed_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1211 fixed_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1212 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1213 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1214 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1215 roll_convention: Optional[str] = field(default=None, metadata=field_metadata)1216 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1217 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1218 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1219 type_: Optional[AssetType] = field(init=False, default=AssetType.FixedLeg, metadata=config(field_name='type', exclude=exclude_none))1220 name: Optional[str] = field(default=None, metadata=name_metadata)1221@handle_camel_case_args1222@dataclass_json(letter_case=LetterCase.CAMEL)1223@dataclass(unsafe_hash=True, repr=False)1224class IRFloatLeg(Instrument):1225 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1226 floating_rate_for_the_initial_calculation_period: Optional[float] = field(default=None, metadata=field_metadata)1227 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1228 floating_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1229 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1230 floating_holidays: Optional[str] = field(default=None, metadata=field_metadata)1231 floating_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1232 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1233 floating_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1234 floating_rate_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1235 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1236 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1237 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1238 roll_convention: Optional[str] = field(default=None, metadata=field_metadata)1239 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1240 floating_rate_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1241 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1242 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1243 type_: Optional[AssetType] = field(init=False, default=AssetType.FloatLeg, metadata=config(field_name='type', exclude=exclude_none))1244 name: Optional[str] = field(default=None, metadata=name_metadata)1245@handle_camel_case_args1246@dataclass_json(letter_case=LetterCase.CAMEL)1247@dataclass(unsafe_hash=True, repr=False)1248class IRSwap(Instrument):1249 pay_or_receive: Optional[PayReceive] = field(default=None, metadata=field_metadata)1250 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1251 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1252 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1253 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1254 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1255 floating_rate_for_the_initial_calculation_period: Optional[float] = field(default=None, metadata=field_metadata)1256 floating_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1257 floating_rate_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1258 floating_rate_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1259 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1260 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1261 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1262 fixed_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1263 fixed_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1264 fixed_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1265 fixed_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1266 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1267 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1268 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1269 clearing_house: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)1270 fixed_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1271 floating_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1272 fixed_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1273 floating_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1274 fixed_holidays: Optional[str] = field(default=None, metadata=field_metadata)1275 floating_holidays: Optional[str] = field(default=None, metadata=field_metadata)1276 roll_convention: Optional[str] = field(default=None, metadata=field_metadata)1277 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1278 type_: Optional[AssetType] = field(init=False, default=AssetType.Swap, metadata=config(field_name='type', exclude=exclude_none))1279 name: Optional[str] = field(default=None, metadata=name_metadata)1280 def scale_in_place(self, scaling: Optional[float] = None):1281 if self.unresolved is None:1282 raise RuntimeError('Can only scale resolved instruments')1283 if scaling is None or scaling == 1:1284 return1285 1286 if scaling < 0:1287 flip_dict = {PayReceive.Pay: PayReceive.Receive, PayReceive.Receive: PayReceive.Pay}1288 self.pay_or_receive = flip_dict[self.pay_or_receive]1289 self.fee *= -11290 self.notional_amount *= abs(scaling)1291 return1292@handle_camel_case_args1293@dataclass_json(letter_case=LetterCase.CAMEL)1294@dataclass(unsafe_hash=True, repr=False)1295class IRSwaption(Instrument):1296 pay_or_receive: Optional[PayReceive] = field(default=None, metadata=field_metadata)1297 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1298 notional_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1299 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1300 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1301 expiration_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1302 floating_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1303 floating_rate_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1304 floating_rate_spread: Optional[float] = field(default=None, metadata=field_metadata)1305 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1306 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1307 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1308 fixed_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1309 fixed_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1310 fixed_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1311 strike: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1312 premium: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1313 premium_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1314 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1315 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1316 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1317 clearing_house: Optional[SwapClearingHouse] = field(default=None, metadata=field_metadata)1318 settlement: Optional[SwapSettlement] = field(default=None, metadata=field_metadata)1319 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1320 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1321 type_: Optional[AssetType] = field(init=False, default=AssetType.Swaption, metadata=config(field_name='type', exclude=exclude_none))1322 name: Optional[str] = field(default=None, metadata=name_metadata)1323@handle_camel_case_args1324@dataclass_json(letter_case=LetterCase.CAMEL)1325@dataclass(unsafe_hash=True, repr=False)1326class IRXccySwap(Instrument):1327 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1328 notional_amount: Optional[float] = field(default=None, metadata=field_metadata)1329 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1330 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1331 payer_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1332 payer_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1333 payer_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1334 payer_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1335 payer_frequency: Optional[str] = field(default=None, metadata=field_metadata)1336 payer_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1337 payer_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1338 receiver_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1339 receiver_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1340 receiver_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1341 receiver_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1342 receiver_frequency: Optional[str] = field(default=None, metadata=field_metadata)1343 receiver_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1344 receiver_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1345 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1346 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1347 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1348 initial_fx_rate: Optional[float] = field(default=None, metadata=field_metadata)1349 payer_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1350 receiver_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1351 payer_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1352 receiver_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1353 payer_holidays: Optional[str] = field(default=None, metadata=field_metadata)1354 receiver_holidays: Optional[str] = field(default=None, metadata=field_metadata)1355 notional_reset_side: Optional[PayReceive] = field(default=None, metadata=field_metadata)1356 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1357 type_: Optional[AssetType] = field(init=False, default=AssetType.XccySwapMTM, metadata=config(field_name='type', exclude=exclude_none))1358 name: Optional[str] = field(default=None, metadata=name_metadata)1359@handle_camel_case_args1360@dataclass_json(letter_case=LetterCase.CAMEL)1361@dataclass(unsafe_hash=True, repr=False)1362class IRXccySwapFixFix(Instrument):1363 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1364 notional_amount: Optional[float] = field(default=None, metadata=field_metadata)1365 receiver_notional_amount: Optional[float] = field(default=None, metadata=field_metadata)1366 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1367 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1368 payer_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1369 payer_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1370 payer_frequency: Optional[str] = field(default=None, metadata=field_metadata)1371 payer_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1372 payer_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1373 receiver_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1374 receiver_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1375 receiver_frequency: Optional[str] = field(default=None, metadata=field_metadata)1376 receiver_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1377 receiver_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1378 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1379 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1380 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1381 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1382 type_: Optional[AssetType] = field(init=False, default=AssetType.XccySwapFixFix, metadata=config(field_name='type', exclude=exclude_none))1383 name: Optional[str] = field(default=None, metadata=name_metadata)1384@handle_camel_case_args1385@dataclass_json(letter_case=LetterCase.CAMEL)1386@dataclass(unsafe_hash=True, repr=False)1387class IRXccySwapFixFlt(Instrument):1388 pay_or_receive: Optional[PayReceive] = field(default=None, metadata=field_metadata)1389 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1390 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1391 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1392 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1393 floating_rate_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1394 floating_rate_for_the_initial_calculation_period: Optional[float] = field(default=None, metadata=field_metadata)1395 floating_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1396 floating_rate_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1397 floating_rate_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1398 floating_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1399 floating_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1400 floating_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1401 fixed_rate_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1402 fixed_rate: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1403 fixed_rate_frequency: Optional[str] = field(default=None, metadata=field_metadata)1404 fixed_rate_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1405 fixed_rate_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1406 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1407 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1408 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1409 fixed_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1410 floating_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1411 fixed_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1412 floating_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1413 fixed_holidays: Optional[str] = field(default=None, metadata=field_metadata)1414 floating_holidays: Optional[str] = field(default=None, metadata=field_metadata)1415 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1416 type_: Optional[AssetType] = field(init=False, default=AssetType.XccySwapFixFlt, metadata=config(field_name='type', exclude=exclude_none))1417 name: Optional[str] = field(default=None, metadata=name_metadata)1418@handle_camel_case_args1419@dataclass_json(letter_case=LetterCase.CAMEL)1420@dataclass(unsafe_hash=True, repr=False)1421class IRXccySwapFltFlt(Instrument):1422 termination_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1423 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1424 effective_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1425 principal_exchange: Optional[PrincipalExchange] = field(default=None, metadata=field_metadata)1426 payer_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1427 payer_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1428 payer_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1429 payer_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1430 payer_frequency: Optional[str] = field(default=None, metadata=field_metadata)1431 payer_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1432 payer_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1433 receiver_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1434 receiver_spread: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1435 receiver_rate_option: Optional[str] = field(default=None, metadata=field_metadata)1436 receiver_designated_maturity: Optional[str] = field(default=None, metadata=field_metadata)1437 receiver_frequency: Optional[str] = field(default=None, metadata=field_metadata)1438 receiver_day_count_fraction: Optional[DayCountFraction] = field(default=None, metadata=field_metadata)1439 receiver_business_day_convention: Optional[BusinessDayConvention] = field(default=None, metadata=field_metadata)1440 fee: Optional[float] = field(default=0.0, metadata=field_metadata)1441 fee_currency: Optional[Currency] = field(default=None, metadata=field_metadata)1442 fee_payment_date: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1443 payer_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1444 receiver_first_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1445 payer_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1446 receiver_last_stub: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1447 payer_holidays: Optional[str] = field(default=None, metadata=field_metadata)1448 receiver_holidays: Optional[str] = field(default=None, metadata=field_metadata)1449 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1450 type_: Optional[AssetType] = field(init=False, default=AssetType.XccySwap, metadata=config(field_name='type', exclude=exclude_none))1451 name: Optional[str] = field(default=None, metadata=name_metadata)1452@handle_camel_case_args1453@dataclass_json(letter_case=LetterCase.CAMEL)1454@dataclass(unsafe_hash=True, repr=False)1455class CommodOTCOption(Instrument):1456 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1457 quantity: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1458 start: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1459 number_of_periods: Optional[int] = field(default=None, metadata=field_metadata)1460 quantity_unit: Optional[str] = field(default=None, metadata=field_metadata)1461 settlement: Optional[str] = field(default=None, metadata=field_metadata)1462 premium_summary: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1463 legs: Optional[Tuple[CommodOTCOptionLeg, ...]] = field(default=None, metadata=field_metadata)1464 end: Optional[Union[datetime.date, str]] = field(default=None, metadata=field_metadata)1465 quantity_period: Optional[Period] = field(default=None, metadata=field_metadata)1466 strategy: Optional[str] = field(default=None, metadata=field_metadata)1467 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Commod, metadata=field_metadata)1468 type_: Optional[AssetType] = field(init=False, default=AssetType.OptionStrategy, metadata=config(field_name='type', exclude=exclude_none))1469 name: Optional[str] = field(default=None, metadata=name_metadata)1470@handle_camel_case_args1471@dataclass_json(letter_case=LetterCase.CAMEL)1472@dataclass(unsafe_hash=True, repr=False)1473class InvoiceSpread(Instrument):1474 buy_sell: Optional[BuySell] = field(default=None, metadata=field_metadata)1475 notional_amount: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1476 underlier: Optional[Union[float, str]] = field(default=None, metadata=field_metadata)1477 swap: Optional[IRSwap] = field(default=None, metadata=field_metadata)1478 future: Optional[IRBondFuture] = field(default=None, metadata=field_metadata)1479 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Rates, metadata=field_metadata)1480 type_: Optional[AssetType] = field(init=False, default=AssetType.InvoiceSpread, metadata=config(field_name='type', exclude=exclude_none))1481 name: Optional[str] = field(default=None, metadata=name_metadata)1482@handle_camel_case_args1483@dataclass_json(letter_case=LetterCase.CAMEL)1484@dataclass(unsafe_hash=True, repr=False)1485class CSLPython(Instrument):1486 class_name: Optional[str] = field(default=None, metadata=field_metadata)1487 denominated: Optional[Currency] = field(default=None, metadata=field_metadata)1488 double_params: Optional[Tuple[CSLDouble, ...]] = field(default=None, metadata=field_metadata)1489 date_params: Optional[Tuple[CSLDate, ...]] = field(default=None, metadata=field_metadata)1490 string_params: Optional[Tuple[CSLString, ...]] = field(default=None, metadata=field_metadata)1491 simple_schedule_params: Optional[Tuple[CSLSimpleSchedule, ...]] = field(default=None, metadata=field_metadata)1492 schedule_params: Optional[Tuple[CSLSchedule, ...]] = field(default=None, metadata=field_metadata)1493 currency_params: Optional[Tuple[CSLCurrency, ...]] = field(default=None, metadata=field_metadata)1494 stock_params: Optional[Tuple[CSLStock, ...]] = field(default=None, metadata=field_metadata)1495 index_params: Optional[Tuple[CSLIndex, ...]] = field(default=None, metadata=field_metadata)1496 fx_cross_params: Optional[Tuple[CSLFXCross, ...]] = field(default=None, metadata=field_metadata)1497 double_array_params: Optional[Tuple[CSLDoubleArray, ...]] = field(default=None, metadata=field_metadata)1498 date_array_params: Optional[Tuple[CSLDateArray, ...]] = field(default=None, metadata=field_metadata)1499 string_array_params: Optional[Tuple[CSLStringArray, ...]] = field(default=None, metadata=field_metadata)1500 simple_schedule_array_params: Optional[Tuple[CSLSimpleScheduleArray, ...]] = field(default=None, metadata=field_metadata)1501 schedule_array_params: Optional[Tuple[CSLScheduleArray, ...]] = field(default=None, metadata=field_metadata)1502 currency_array_params: Optional[Tuple[CSLCurrencyArray, ...]] = field(default=None, metadata=field_metadata)1503 stock_array_params: Optional[Tuple[CSLStockArray, ...]] = field(default=None, metadata=field_metadata)1504 index_array_params: Optional[Tuple[CSLIndexArray, ...]] = field(default=None, metadata=field_metadata)1505 fx_cross_array_params: Optional[Tuple[CSLFXCrossArray, ...]] = field(default=None, metadata=field_metadata)1506 asset_class: Optional[AssetClass] = field(init=False, default=AssetClass.Cross_Asset, metadata=field_metadata)1507 type_: Optional[AssetType] = field(init=False, default=AssetType.CSL, metadata=config(field_name='type', exclude=exclude_none))...

Full Screen

Full Screen

sample_CQQ_specs_with_data.py

Source:sample_CQQ_specs_with_data.py Github

copy

Full Screen

1'''2Script used to find valid datasets, extract exact CQQ datasets, randomly selecting one spec, then printing data3Output: tab-separated file with:4 corpus5 locator6 dataset_id7 column_metadata JSON-encoded specifications (list of { order, name, general_type })8 data9'''10import os11from os.path import join12import argparse13import pandas as pd14import numpy as np15import random16from time import time, strftime17import itertools18import json19import traceback20from collections import Counter21from read_raw_data import get_plotly_dfs, get_manyeyes_dfs, get_webtables_dfs, get_opendata_dfs22from feature_extraction.type_detection import detect_field_type, data_type_to_general_type, data_types, general_types23from feature_extraction.helpers import get_unique24parser = argparse.ArgumentParser()25parser.add_argument('corpus', type=str)26args = parser.parse_args()27corpus = args.corpus28get_dfs_by_corpus = {29 'plotly': get_plotly_dfs,30 'manyeyes': get_manyeyes_dfs,31 'webtables': get_webtables_dfs,32 'opendata': get_opendata_dfs33}34timeout=1535write_header = True36total_num = 037valid_features = 038output_dir = 'randomly_selected_cqq_specs_with_data'39os.makedirs(output_dir, exist_ok=True)40headers = [41 'corpus',42 'locator',43 'dataset_id',44 'combination_number',45 'column_metadata',46 'data'47]48output_file = open(join(output_dir, '{}_cqq_specs_with_data_all.tsv'.format(corpus)), 'w')49output_file.write('\t'.join(headers) + '\n')50one_per_dataset_output_file = open(join(output_dir, '{}_cqq_specs_with_data_one_per_dataset.tsv'.format(corpus)), 'w')51one_per_dataset_output_file.write('\t'.join(headers) + '\n')52print('Enumerating datasets for corpus:', corpus)53column_limits = {54 'min': 3,55 'max': 10056}57group_length_limits = {58 'min': 1,59 'max': 5060}61name_length_limits = {62 'min': 1,63 'max': 3064}65cardinality_limits = {66 'min': 3,67 'max': 3068}69num_per_category_limits = {70 'min': 3,71 'max': 3072}73def is_all_ascii(s):74 return all(ord(char) < 128 for char in s)75def get_combinations(field_metadata):76 combinations = []77 c_fields = [ f for f in field_metadata if f['general_type'] == 'c']78 q_fields = [ f for f in field_metadata if f['general_type'] == 'q']79 for c_field in c_fields:80 for q_pair in itertools.combinations(q_fields, 2):81 combinations.append([ c_field ] + list(q_pair))82 return combinations83c_dtypes = [ np.dtype('O'), np.dtype('bool') ]84q_dtypes = [ np.dtype('float32'), np.dtype('float32'), np.dtype('float64'), np.dtype('int64')]85t_dtypes = [ np.dtype('datetime64[ns]'), np.dtype('<M8[ns]') ]86def parse_datetime(v, value_limit=100):87 if v.dtypes == object:88 v = pd.to_datetime(v[:value_limit], errors='ignore')89 return v90def has_alpha(s):91 return any([ c.isalpha() for c in str(s) ])92def isNotEmpty(s):93 return bool(s and s.strip())94def get_field_metadata_if_valid(df):95 field_general_types = []96 field_metadata = []97 remappings = {} # For re-parsed fields98 if df.empty:99 print('Empty df')100 return False101 dtypes = dict(df.dtypes)102 for field_order, field_name in enumerate(df.columns):103 # Name length104 if len(field_name) >= name_length_limits['max'] or len(field_name) <= name_length_limits['min']:105 continue106 # ASCII Name107 if not is_all_ascii(field_name):108 continue109 v = df[field_name]110 dtype = dtypes[field_name]111 # For webtables112 v = v.replace(('*', '-', '--'), np.nan)113 # All valid types114 has_any_null = v.isnull().values.any()115 if has_any_null:116 continue117 # None are empty118 all_are_not_empty = all([ isNotEmpty(str(s)) for s in v ])119 if not all_are_not_empty:120 continue121 # Force to numeric if possible122 v = pd.to_numeric(v, errors='ignore')123 dtype = v.dtype124 # Parse certain categorical fields125 if dtype in c_dtypes:126 # Try coercing again after replacing commas127 v_without_commas = v.replace(',', '')128 dtype_without_commas = pd.to_numeric(v_without_commas, errors='ignore').dtype129 if dtype_without_commas in q_dtypes:130 v = v_without_commas131 dtype = dtype_without_commas132 # Convert percentages and dollars133 if dtype in c_dtypes:134 num_percent = sum([ True for s in v if str(s).endswith('%') ])135 num_dollar = sum([ True for s in v if str(s).endswith('$') ])136 if num_percent / len(v) > 0.5:137 try:138 v = pd.to_numeric(v.str.rstrip('%').astype('float') / 100.0, errors='coerce')139 dtype = v.dtype140 except Exception as e:141 print(e)142 if num_dollar / len(v) > 0.5:143 try:144 v = pd.to_numeric(v.str.lstrip('$'), errors='coerce')145 dtype = v.dtype146 except Exception as e:147 print(e)148 date_strings = ('date', 'Date', 'DATE', 'year', 'Year', 'YEAR')149 if field_name in date_strings or field_name.endswith(date_strings):150 v = v.astype('str')151 dtype = np.dtype('O')152 # Force year to categorical153 if dtype in q_dtypes:154 num_year = sum([ True for s in v if (len(str(s)) >= 4 and str(s).startswith(('18', '19', '20', '21')))])155 months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']156 num_month = sum([ True for s in v if any((m in str(s)) for m in months) ])157 if num_year / len(v) > 0.5:158 v = v.astype('str')159 dtype = np.dtype('O')160 # Catch ID field161 if dtype in q_dtypes:162 if (field_name in ['id', 'ID', 'Id', 'name']) or field_name.endswith(('id', 'ID', 'Id', 'name')):163 v = v.astype('str')164 dtype = np.dtype('O')165 # All valid names166 if dtype in c_dtypes:167 field_general_type = 'c'168 # Remove list edgecase for Plotly169 if isinstance(list(v)[0], (list,)): continue170 # Constrain cardinality171 unique_elements = get_unique(list(v)).size172 if unique_elements < cardinality_limits['min'] or unique_elements > cardinality_limits['max']: continue173 # Constrain number per category174 num_per_category = pd.Series(list(v)).value_counts() # df.groupby(field_name).count()175 num_per_category_mean = np.mean(num_per_category)176 if num_per_category_mean < num_per_category_limits['min'] or num_per_category_mean > num_per_category_limits['max']: continue177 # Constrain category value lenths178 categories = pd.Series(list(v)).unique()179 category_lengths = [ len(str(c)) for c in categories ]180 invalid_category_lengths = [ (l > group_length_limits['max'] or l < group_length_limits['min']) for l in category_lengths]181 if any(invalid_category_lengths):182 continue183 # Force all groups to have at least one alphabetical character184 all_categories_have_alphabetical = all([has_alpha(c) for c in categories])185 if not all_categories_have_alphabetical:186 continue187 # Finally, after all the filters, try to parse datetimes -- then filter them out188 attempted_datetime_parse_dtype = pd.to_datetime(v[:100], errors='ignore').dtype189 if attempted_datetime_parse_dtype in t_dtypes:190 field_general_type = 't'191 elif dtype in q_dtypes:192 field_general_type = 'q'193 # Return if all elements are the same194 if len(set(v)) <= 1:195 continue196 # Infinity197 has_any_inf = np.isinf(v).any()198 if has_any_inf:199 print('Inf')200 continue201 else:202 print('No matching dtype', dtype)203 continue204 df[field_name] = v205 field_general_types.append(field_general_type)206 field_metadata.append({207 'index': field_order,208 'name': field_name,209 'general_type': field_general_type,210 'dtype': dtype.name,211 'length': len(v)212 })213 lengths = [ fm['length'] for fm in field_metadata ]214 if len(set(lengths)) > 1:215 return False216 if field_general_types.count('c') < 1 or field_general_types.count('q') < 2:217 return False218 return { 'df': df, 'field_metadata': field_metadata }219total_num_combinations = 0220total_valid_datasets = 0221for d in get_dfs_by_corpus[corpus]():222 locator = d['locator']223 dataset_id = d['dataset_id']224 df = d['df']225 total_num += 1226 if total_num % 100 == 0:227 print('Number of datasets: ({} valid / {} total)'.format(total_valid_datasets, total_num))228 if len(df.columns) < column_limits['min'] or len(df.columns) > column_limits['max']: continue229 field_metadata = []230 start_time = time()231 while time() < (start_time + timeout):232 try:233 r = get_field_metadata_if_valid(df)234 if r:235 df = r['df']236 field_metadata = r['field_metadata']237 except Exception as e:238 print('Get metadata exception', e)239 continue240 break241 if not field_metadata: continue242 combinations = get_combinations(field_metadata)243 total_valid_datasets += 1244 print('\tNum combinations:', len(combinations))245 total_num_combinations += len(combinations)246 print('\tTotal num combinations:', total_num_combinations)247 random_to_pick = random.choice(range(0, len(combinations)))248 for combination_number, random_combination in enumerate(combinations):249 random_combination_names = [ fm['name'] for fm in random_combination ]250 df_cqq_subset = df[random_combination_names]251 df_cqq_subset_as_json = df_cqq_subset.to_json(orient='records')252 fields_to_write = [253 corpus,254 locator,255 dataset_id,256 str(combination_number),257 json.dumps(random_combination),258 df_cqq_subset_as_json259 ]260 print(df_cqq_subset.head())261 output_file.write('\t'.join(fields_to_write)+ '\n')262 if combination_number == random_to_pick:263 one_per_dataset_output_file.write('\t'.join(fields_to_write)+ '\n')264print('Total datasets:', total_num)265print('Total valid datasets:', total_valid_datasets)...

Full Screen

Full Screen

model_performance_metrics.py

Source:model_performance_metrics.py Github

copy

Full Screen

1from logging import getLogger2from typing import Dict, List, Optional, Set, Union3from whylogs.core.metrics.metrics import Metric4from whylogs.core.proto.v0 import ModelMetricsMessage, ModelProfileMessage, ModelType5from .confusion_matrix import ConfusionMatrix6from .regression_metrics import RegressionMetrics7OUTPUT_FIELD_CATEGORY = "output"8logger = getLogger(__name__)9class ModelPerformanceMetrics:10 """11 Container class for various model-related performance metrics12 Attributes:13 confusion_matrix (ConfusionMatrix): ConfusionMatrix which keeps it track of counts with NumberTracker14 regression_metrics (RegressionMetrics): Regression Metrics keeps track of a common regression metrics in case the targets are continous.15 """16 def __init__(17 self,18 confusion_matrix: Optional[ConfusionMatrix] = None,19 regression_metrics: Optional[RegressionMetrics] = None,20 metrics: Optional[Dict[str, Metric]] = None,21 field_metadata: Optional[Dict[str, Set[str]]] = None,22 ):23 self.model_type = None24 self.confusion_matrix = confusion_matrix25 self.regression_metrics = regression_metrics26 self.metrics = metrics27 self.field_metadata = field_metadata28 def to_protobuf(29 self,30 ) -> ModelProfileMessage:31 model_type = ModelType.UNKNOWN32 if not self.model_type:33 if self.confusion_matrix:34 model_type = ModelType.CLASSIFICATION35 elif self.regression_metrics:36 model_type = ModelType.REGRESSION37 else:38 model_type = self.model_type39 model_metrics = ModelMetricsMessage(40 scoreMatrix=self.confusion_matrix.to_protobuf() if self.confusion_matrix else None,41 regressionMetrics=self.regression_metrics.to_protobuf() if self.regression_metrics else None,42 modelType=model_type,43 )44 return ModelProfileMessage(output_fields=self.output_fields, metrics=model_metrics)45 @classmethod46 def from_protobuf(47 cls,48 message: ModelProfileMessage,49 ) -> "ModelPerformanceMetrics":50 # TODO: update format to support storing other field metadata, for now just support output field in v0 message format51 output_fields = (52 {column_name: set([OUTPUT_FIELD_CATEGORY]) for column_name in message.output_fields}53 if message.output_fields54 else None55 )56 confusion_matrix = None57 regression_metrics = None58 if message.metrics is None:59 logger.warning("deserializing a ModelPerformanceMetrics without a metrics field")60 else:61 confusion_matrix = ConfusionMatrix.from_protobuf(message.metrics.scoreMatrix)62 regression_metrics = RegressionMetrics.from_protobuf(message.metrics.regressionMetrics)63 return ModelPerformanceMetrics(64 confusion_matrix=confusion_matrix, regression_metrics=regression_metrics, field_metadata=output_fields65 )66 def compute_confusion_matrix(67 self,68 predictions: List[Union[str, int, bool, float]],69 targets: List[Union[str, int, bool, float]],70 scores: List[float] = None,71 ):72 """73 computes the confusion_matrix, if one is already present merges to old one.74 Args:75 predictions (List[Union[str, int, bool]]):76 targets (List[Union[str, int, bool]]):77 scores (List[float], optional):78 """79 labels = sorted(list(set(targets + predictions)))80 confusion_matrix = ConfusionMatrix(labels=labels)81 confusion_matrix.add(predictions, targets, scores)82 if self.confusion_matrix is None or self.confusion_matrix.labels is None or self.confusion_matrix.labels == []:83 self.confusion_matrix = confusion_matrix84 else:85 self.confusion_matrix = self.confusion_matrix.merge(confusion_matrix)86 def compute_regression_metrics(87 self,88 predictions: List[Union[float, int]],89 targets: List[Union[float, int]],90 ):91 regression_metrics = RegressionMetrics()92 regression_metrics.add(predictions, targets)93 if self.regression_metrics:94 self.regression_metrics = self.regression_metrics.merge(regression_metrics)95 else:96 self.regression_metrics = regression_metrics97 def add_metadata_to_field(self, column_name: str, categories: Set[str]) -> None:98 if not self.field_metadata:99 self.field_metadata = dict()100 self.field_metadata[column_name] = categories101 def _set_column_value(self, column_name, value):102 if column_name not in self.field_metadata:103 self.field_metadata[column_name] = set([value])104 else:105 self.field_metadata[column_name].add(value)106 def specify_output_fields(self, column_names: Union[str, Set[str]]) -> None:107 if not self.field_metadata:108 self.field_metadata = dict()109 if isinstance(column_names, str):110 self._set_column_value(column_names, OUTPUT_FIELD_CATEGORY)111 else:112 for column_name in column_names:113 self._set_column_value(column_name, OUTPUT_FIELD_CATEGORY)114 @property115 def output_fields(self) -> Optional[List[str]]:116 output_column_names = None117 if self.field_metadata:118 for column_name in self.field_metadata:119 field_categories = self.field_metadata[column_name]120 if OUTPUT_FIELD_CATEGORY in field_categories:121 if output_column_names is None:122 output_column_names = []123 output_column_names.append(column_name)124 return output_column_names125 def merge(self, other):126 """127 :type other: ModelMetrics128 """129 if other is None or (other.confusion_matrix is None and other.regression_metrics is None):130 return self131 merged_field_metadata: Optional[Dict[str, Set[str]]] = None132 if self.field_metadata is not None:133 if other.field_metadata is None:134 merged_field_metadata = self.field_metadata135 else:136 merged_keys = set(self.field_metadata.keys() + other.field_metadata.keys)137 merged_field_metadata = dict()138 for key in merged_keys:139 categories = self.field_metadata.get(key)140 other_categories = other.field_metadata.get(key)141 if categories and other_categories:142 merged_field_metadata[key] = categories.union(other_categories)143 elif categories:144 merged_field_metadata[key] = categories145 else:146 merged_field_metadata[key] = other_categories147 else:148 merged_field_metadata = other.field_metadata149 self.field_metadata = merged_field_metadata150 return ModelPerformanceMetrics(151 confusion_matrix=self.confusion_matrix.merge(other.confusion_matrix)152 if self.confusion_matrix153 else other.confusion_matrix,154 regression_metrics=self.regression_metrics.merge(other.regression_metrics)155 if self.regression_metrics156 else other.regression_metrics,157 field_metadata=merged_field_metadata,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful