Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 966589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:10:52+00:00 2026-05-16T02:10:52+00:00

Given a data set of various currency pairs, how do I efficiently compute the

  • 0

Given a data set of various currency pairs, how do I efficiently compute the implied fx rate for a pair not supplied in the data set?

For example, say my database/table looks like this (this data is fudged):

GBP x USD = 1.5
USD x GBP = 0.64
GBP x EUR = 1.19
AUD x USD = 1.1  

Notice that (GBP,USD) != 1/(USD,GBP).

I would expect the following results:

print rate('GBP','USD')
> 1.5

print rate('USD','GBP')
> 0.64

print rate('GBP','EUR')
> 1.19

#now in the absence of an explicit pair, we imply one using the inverse
print rate('EUR','GBP')
> 0.84

These are the simple cases, it gets more interesting:

#this is the implied rate from (GBP,EUR) and (GBP,USD)
print rate('EUR','USD')
> 1.26

Or an even more complicated example is finding the most efficient translation using 3 or more pairs:

print rate('EUR','AUD')
> 1.38

I think that details the programming related aspects of this problem. I’d imagine there’s an efficient or clever recursion that can be done here. The only requirement is that the least number of pairs are used to arrive at the asked for pair (this is to reduce error). If no explicit inverse is given, then inverting a pair costs you nothing.

Motivation
In the ideal financial world, currency markets are efficient. In reality, that’s 99% true. Often times, odd currency pairs aren’t quoted or they’re quoted infrequently. If an explicit quote exists, we must use it in our arbitrary calculations. If not, we must imply the most accurate pair, out to as many decimal places as we can. Furthermore, they don’t always multiply to 1 (actually, they never multiply to 1); this reflects the bid/ask spread in the market. So we keep as many pairs as we can in both directions, but would like to be able to code in general for all currencies.

I think I have a decent, brute force solution implemented. It works, but I thought the problem was interesting and was wondering if anyone else thought it was interesting/challenging. I’m personally working in Python but it’s more an exercise than an implementation, so psuedo code is “good enough”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:10:53+00:00Added an answer on May 16, 2026 at 2:10 am

    You’re looking for the shortest path in a directed graph, where the currencies are the vertices and the given exchange rates are the edges.
    If an exchange rate is given only for one direction, you can add one for the opposite direction with a higher cost.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this data set: ID Name City Birthyear 1 Egon Spengler New York 1957
Given that indexing is so important as your data set increases in size, can
first, an example: given a bunch of Person objects with various attributes (name, ssn,
Given a data structure (e.g. a hash of hashes), what's the clean/recommended way to
I know you could make a helper pretty easily given the data. So, if
Given an InputStream called in which contains audio data in a compressed format (such
Given a situation in Django 1.0 where you have extra data on a Many-to-Many
Given a database field named widget_ids, containing data like 67/797/124/ or 45/, where the
If the amount of data stored within a given field of a database is
I have a very uniform set of data from Radius messages that I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.