I have dataset of trade records with Type, Currency 1, Currency 2, and Days columns. I would like to filter the records that should be excluded based on the following criteria:
If the Type is equal to ‘FO’, then the below logic should be applied:
- If the
Currency 1is equal to ‘EUR’, ‘USD’, ‘JPY’, ‘AUD’, or ‘MXN’, theCurrency 2is equal to ‘EUR’, ‘USD’, ‘JPY’, ‘AUD’, or ‘MXN’, and theDaysis less than or equal to 2, the trade should be excluded. - If the
Currency 1or theCurrency 2is not equal to ‘EUR’, ‘USD’, ‘JPY’, ‘AUD’, or ‘MXN’, and theDayis less than or equal to thesettlement periodfor the currency pair or seven business days (whichever is earlier), then the trade should be excluded.
I also have a dictionary of [SETTLEMENT] value for each currency. The way to obtain the settlement period is the following:
- Where the
Currency 1or theCurrency 2is equal to ‘USD’, the settlement period should be equal to theminimumvalue of[SETTLEMENT]. - Where the
Currency 1or theCurrency 2are both not equal to ‘USD’, the settlement period should be equal to themaximumvalue of[SETTLEMENT].
The dictionary would look like such:
settlement_dict = {'AED':2, 'PHP' = 1, 'AUD' = 2, ...}
The logics are so embedded with one another and I have no clue how to use pandas to apply the logics to filter out the excluded trades. I would really appreciate your help on this. Thank you.