{"action":"created","comment":{"url":"https://api.github.com/repos/OpenGamma/Strata/pulls/comments/57145022","id":57145022,"diff_hunk":"@@ -33,7 +35,19 @@ public double fxRate(Currency baseCurrency, Currency counterCurrency) {\n     if (baseCurrency.equals(counterCurrency)) {\n       return 1;\n     }\n-    FxRate rate = marketData.getValue(FxRateKey.of(baseCurrency, counterCurrency));\n-    return rate.fxRate(baseCurrency, counterCurrency);\n+    // Try direct pair\n+    Optional<FxRate> rate = marketData.findValue(FxRateKey.of(baseCurrency, counterCurrency));\n+    if (rate.isPresent()) {\n+      return rate.get().fxRate(baseCurrency, counterCurrency);\n+    }\n+    // Try triangulation on first currency\n+    Currency triangularCcy = baseCurrency.getTriangulationCurrency();\n+    Optional<FxRate> rate1 = marketData.findValue(FxRateKey.of(baseCurrency, triangularCcy));\n+    Optional<FxRate> rate2 = marketData.findValue(FxRateKey.of(triangularCcy, counterCurrency));\n+    if(rate1.isPresent() && rate2.isPresent()) {\n+      return rate1.get().crossRate(rate2.get()).fxRate(baseCurrency, counterCurrency);\n+    }\n+    throw new IllegalArgumentException(\"No market data available for pair \" + baseCurrency + \"/\" + counterCurrency);","path":"modules/pricer/src/main/java/com/opengamma/strata/pricer/calibration/MarketDataFxRateProvider.java","position":27,"original_position":27,"commit_id":"391454895172b4a390bfb0a3d4c89b0bc1a24c0e","original_commit_id":"391454895172b4a390bfb0a3d4c89b0bc1a24c0e","user":{"login":"cjkent","id":98477,"avatar_url":"https://avatars.githubusercontent.com/u/98477?v=3","gravatar_id":"","url":"https://api.github.com/users/cjkent","html_url":"https://github.com/cjkent","followers_url":"https://api.github.com/users/cjkent/followers","following_url":"https://api.github.com/users/cjkent/following{/other_user}","gists_url":"https://api.github.com/users/cjkent/gists{/gist_id}","starred_url":"https://api.github.com/users/cjkent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjkent/subscriptions","organizations_url":"https://api.github.com/users/cjkent/orgs","repos_url":"https://api.github.com/users/cjkent/repos","events_url":"https://api.github.com/users/cjkent/events{/privacy}","received_events_url":"https://api.github.com/users/cjkent/received_events","type":"User","site_admin":false},"body":"Before throwing an exception should we also try:\r\n\r\n* counter currency triangulation currency\r\n* triangulating twice if there are two triangulation currencies","created_at":"2016-03-23T11:36:29Z","updated_at":"2016-03-23T11:36:29Z","html_url":"https://github.com/OpenGamma/Strata/pull/870#discussion_r57145022","pull_request_url":"https://api.github.com/repos/OpenGamma/Strata/pulls/870","_links":{"self":{"href":"https://api.github.com/repos/OpenGamma/Strata/pulls/comments/57145022"},"html":{"href":"https://github.com/OpenGamma/Strata/pull/870#discussion_r57145022"},"pull_request":{"href":"https://api.github.com/repos/OpenGamma/Strata/pulls/870"}}},"pull_request":{"url":"https://api.github.com/repos/OpenGamma/Strata/pulls/870","id":63866998,"html_url":"https://github.com/OpenGamma/Strata/pull/870","diff_url":"https://github.com/OpenGamma/Strata/pull/870.diff","patch_url":"https://github.com/OpenGamma/Strata/pull/870.patch","issue_url":"https://api.github.com/repos/OpenGamma/Strata/issues/870","number":870,"state":"open","locked":false,"title":"Cross FX in FxRateProvider","user":{"login":"marc-opengamma","id":644983,"avatar_url":"https://avatars.githubusercontent.com/u/644983?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-opengamma","html_url":"https://github.com/marc-opengamma","followers_url":"https://api.github.com/users/marc-opengamma/followers","following_url":"https://api.github.com/users/marc-opengamma/following{/other_user}","gists_url":"https://api.github.com/users/marc-opengamma/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-opengamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-opengamma/subscriptions","organizations_url":"https://api.github.com/users/marc-opengamma/orgs","repos_url":"https://api.github.com/users/marc-opengamma/repos","events_url":"https://api.github.com/users/marc-opengamma/events{/privacy}","received_events_url":"https://api.github.com/users/marc-opengamma/received_events","type":"User","site_admin":false},"body":"Add the flexibility for the MarketDataFxRateProvider to compute rates from triangulation.","created_at":"2016-03-23T11:26:13Z","updated_at":"2016-03-23T11:36:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d899439a04c9ab708c7b6fa7809bb77662ae74c1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OpenGamma/Strata/pulls/870/commits","review_comments_url":"https://api.github.com/repos/OpenGamma/Strata/pulls/870/comments","review_comment_url":"https://api.github.com/repos/OpenGamma/Strata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenGamma/Strata/issues/870/comments","statuses_url":"https://api.github.com/repos/OpenGamma/Strata/statuses/391454895172b4a390bfb0a3d4c89b0bc1a24c0e","head":{"label":"OpenGamma:topic/fx-provider-cross","ref":"topic/fx-provider-cross","sha":"391454895172b4a390bfb0a3d4c89b0bc1a24c0e","user":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"repo":{"id":20882897,"name":"Strata","full_name":"OpenGamma/Strata","owner":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenGamma/Strata","description":"OpenGamma's next-generation market risk toolkit","fork":false,"url":"https://api.github.com/repos/OpenGamma/Strata","forks_url":"https://api.github.com/repos/OpenGamma/Strata/forks","keys_url":"https://api.github.com/repos/OpenGamma/Strata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenGamma/Strata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenGamma/Strata/teams","hooks_url":"https://api.github.com/repos/OpenGamma/Strata/hooks","issue_events_url":"https://api.github.com/repos/OpenGamma/Strata/issues/events{/number}","events_url":"https://api.github.com/repos/OpenGamma/Strata/events","assignees_url":"https://api.github.com/repos/OpenGamma/Strata/assignees{/user}","branches_url":"https://api.github.com/repos/OpenGamma/Strata/branches{/branch}","tags_url":"https://api.github.com/repos/OpenGamma/Strata/tags","blobs_url":"https://api.github.com/repos/OpenGamma/Strata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenGamma/Strata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenGamma/Strata/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenGamma/Strata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenGamma/Strata/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenGamma/Strata/languages","stargazers_url":"https://api.github.com/repos/OpenGamma/Strata/stargazers","contributors_url":"https://api.github.com/repos/OpenGamma/Strata/contributors","subscribers_url":"https://api.github.com/repos/OpenGamma/Strata/subscribers","subscription_url":"https://api.github.com/repos/OpenGamma/Strata/subscription","commits_url":"https://api.github.com/repos/OpenGamma/Strata/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenGamma/Strata/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenGamma/Strata/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenGamma/Strata/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenGamma/Strata/contents/{+path}","compare_url":"https://api.github.com/repos/OpenGamma/Strata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenGamma/Strata/merges","archive_url":"https://api.github.com/repos/OpenGamma/Strata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenGamma/Strata/downloads","issues_url":"https://api.github.com/repos/OpenGamma/Strata/issues{/number}","pulls_url":"https://api.github.com/repos/OpenGamma/Strata/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenGamma/Strata/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenGamma/Strata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenGamma/Strata/labels{/name}","releases_url":"https://api.github.com/repos/OpenGamma/Strata/releases{/id}","deployments_url":"https://api.github.com/repos/OpenGamma/Strata/deployments","created_at":"2014-06-16T11:45:55Z","updated_at":"2016-03-15T22:41:23Z","pushed_at":"2016-03-23T11:26:13Z","git_url":"git://github.com/OpenGamma/Strata.git","ssh_url":"git@github.com:OpenGamma/Strata.git","clone_url":"https://github.com/OpenGamma/Strata.git","svn_url":"https://github.com/OpenGamma/Strata","homepage":"http://opengamma.github.io/StrataDocs","size":27491,"stargazers_count":46,"watchers_count":46,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":76,"forks":26,"open_issues":76,"watchers":46,"default_branch":"master"}},"base":{"label":"OpenGamma:master","ref":"master","sha":"8df40bbf81fadf3a5df7993c4d292741dd933fef","user":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"repo":{"id":20882897,"name":"Strata","full_name":"OpenGamma/Strata","owner":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenGamma/Strata","description":"OpenGamma's next-generation market risk toolkit","fork":false,"url":"https://api.github.com/repos/OpenGamma/Strata","forks_url":"https://api.github.com/repos/OpenGamma/Strata/forks","keys_url":"https://api.github.com/repos/OpenGamma/Strata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenGamma/Strata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenGamma/Strata/teams","hooks_url":"https://api.github.com/repos/OpenGamma/Strata/hooks","issue_events_url":"https://api.github.com/repos/OpenGamma/Strata/issues/events{/number}","events_url":"https://api.github.com/repos/OpenGamma/Strata/events","assignees_url":"https://api.github.com/repos/OpenGamma/Strata/assignees{/user}","branches_url":"https://api.github.com/repos/OpenGamma/Strata/branches{/branch}","tags_url":"https://api.github.com/repos/OpenGamma/Strata/tags","blobs_url":"https://api.github.com/repos/OpenGamma/Strata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenGamma/Strata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenGamma/Strata/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenGamma/Strata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenGamma/Strata/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenGamma/Strata/languages","stargazers_url":"https://api.github.com/repos/OpenGamma/Strata/stargazers","contributors_url":"https://api.github.com/repos/OpenGamma/Strata/contributors","subscribers_url":"https://api.github.com/repos/OpenGamma/Strata/subscribers","subscription_url":"https://api.github.com/repos/OpenGamma/Strata/subscription","commits_url":"https://api.github.com/repos/OpenGamma/Strata/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenGamma/Strata/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenGamma/Strata/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenGamma/Strata/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenGamma/Strata/contents/{+path}","compare_url":"https://api.github.com/repos/OpenGamma/Strata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenGamma/Strata/merges","archive_url":"https://api.github.com/repos/OpenGamma/Strata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenGamma/Strata/downloads","issues_url":"https://api.github.com/repos/OpenGamma/Strata/issues{/number}","pulls_url":"https://api.github.com/repos/OpenGamma/Strata/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenGamma/Strata/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenGamma/Strata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenGamma/Strata/labels{/name}","releases_url":"https://api.github.com/repos/OpenGamma/Strata/releases{/id}","deployments_url":"https://api.github.com/repos/OpenGamma/Strata/deployments","created_at":"2014-06-16T11:45:55Z","updated_at":"2016-03-15T22:41:23Z","pushed_at":"2016-03-23T11:26:13Z","git_url":"git://github.com/OpenGamma/Strata.git","ssh_url":"git@github.com:OpenGamma/Strata.git","clone_url":"https://github.com/OpenGamma/Strata.git","svn_url":"https://github.com/OpenGamma/Strata","homepage":"http://opengamma.github.io/StrataDocs","size":27491,"stargazers_count":46,"watchers_count":46,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":76,"forks":26,"open_issues":76,"watchers":46,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenGamma/Strata/pulls/870"},"html":{"href":"https://github.com/OpenGamma/Strata/pull/870"},"issue":{"href":"https://api.github.com/repos/OpenGamma/Strata/issues/870"},"comments":{"href":"https://api.github.com/repos/OpenGamma/Strata/issues/870/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenGamma/Strata/pulls/870/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenGamma/Strata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenGamma/Strata/pulls/870/commits"},"statuses":{"href":"https://api.github.com/repos/OpenGamma/Strata/statuses/391454895172b4a390bfb0a3d4c89b0bc1a24c0e"}}}}