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 1
is equal to ‘EUR’, ‘USD’, ‘JPY’, ‘AUD’, or ‘MXN’, theCurrency 2
is equal to ‘EUR’, ‘USD’, ‘JPY’, ‘AUD’, or ‘MXN’, and theDays
is less than or equal to 2, the trade should be excluded. - If the
Currency 1
or theCurrency 2
is not equal to ‘EUR’, ‘USD’, ‘JPY’, ‘AUD’, or ‘MXN’, and theDay
is less than or equal to thesettlement period
for 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 1
or theCurrency 2
is equal to ‘USD’, the settlement period should be equal to theminimum
value of[SETTLEMENT]
. - Where the
Currency 1
or theCurrency 2
are both not equal to ‘USD’, the settlement period should be equal to themaximum
value 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.