Class ConfigCrossCurrencyPairProvider

  • All Implemented Interfaces:
    CrossCurrencyPairProvider

    public class ConfigCrossCurrencyPairProvider
    extends java.lang.Object
    implements CrossCurrencyPairProvider
    Provides the cross currencies required to retrieve the conversion rate for the instrument currency pair

    e.g. given the configuration:
    instruments = [ { name = "FX.CROSS" currencyPairs = [ { targetCurrencyPair = DKKSGD crossCurrencyPairs = [DKKEUR, EURSGD] } { targetCurrencyPair = BRLSGD crossCurrencyPairs = [BRLJPY, SGDJPY] } # Currency pairs with no inverse need to be configured at the moment { targetCurrencyPair = JPYSGD crossCurrencyPairs = [SGDJPY] } ] }

    { name = "FX.Branch" currencyPairs = [ { targetCurrencyPair = EURSGD crossCurrencyPairs = [EURUSD, USDSGD] } ] } ]

    A search for FX.CROSS and currency pair DKKSGD would return

    DKKEUR, EURSGD

    A search for FX.CROSS and currency pair BRLSGD would return
    BRLJPY, SGDJPY

    A search for FX.CROSS and currency pair JPYSGD would return
    SGDJPY

    Any other currency pair combination for FX.CROSS, such as a search for currency pair AUDSGD will simply return itself, i.e.
    AUDSGD

    Any combination for an unknown instrument, such as FX.Branch and currency pair JPYSGD will simply return itself, i.e.
    JPYSGD
    • Constructor Detail

      • ConfigCrossCurrencyPairProvider

        public ConfigCrossCurrencyPairProvider()
      • ConfigCrossCurrencyPairProvider

        public ConfigCrossCurrencyPairProvider​(InjectableConfigFactory configFactory)
    • Method Detail

      • getCrossCurrencyPairChain

        public com.google.common.collect.ImmutableList<java.lang.String> getCrossCurrencyPairChain​(java.lang.String instrument,
                                                                                                   java.lang.String currencyPair)
        Description copied from interface: CrossCurrencyPairProvider
        Given the supplied instrument and currency pair, should return a list of currency pairs to traverse in order to provide the conversion rate.

        e.g. given the parameters FX.CROSS and GBPSGD it might return the currency pairs:
        GBPUSD USDEUR EURSGD
        which can then be traversed to get the conversion rate between GBP and SGD.

        If the inverse format does not exist, then it may still return a cross currency pair in its normal format.
        e.g. given the parameters FX.CROSS and BRLSGD, if the inverse currency pair JPYSGD does not exist, it might return the currency pairs:
        BRLJPY SGDJPY

        This may also be used for simple currency pair conversions where the inverse does not exist. e.g. given the parameters FX.CROSS and JPYSGD, if this inverse currency pair does not exist, it may return the currency pair:
        SGDJPY

        There must always be a linking currency between the cross currency pairs. The following would be invalid as there is no common currency between the last two currency pairs - we would expect USD to be the common currency:
        BRLJPY JPYUSD SGDEUR

        A common currency must be seen only twice. The following would be invalid as JPY is a common currency in more than two currency pairs:
        BRLJPY JPYUSD JPYEUR

        Additionally, the first currency pair in the chain must contain the base currency from the requested currency pair, and the last currency pair in the chain must contain the term currency from the requested currency pair.
        e.g. given the parameters FX.CROSS and BRLSGD
        the following chain would be invalid as the first currency pair does not contain the base currency of BRLSGD, BRL:
        JPYEUR EURUSD USDSGD
        the following chain would be invalid as the last currency pair does not contain the term currency of BRLSGD, SGD:
        BRLEUR EURUSD USDDKK
        Specified by:
        getCrossCurrencyPairChain in interface CrossCurrencyPairProvider