|
To add to Richard MacCutchan's reply - store the history of the currency rate as well.
|
|
|
|
|
I saw one particular API that actually has the history as well.
Thanks, good advice.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I like the XE.com api.
We're philosophical about power outages here. A.C. come, A.C. go.
|
|
|
|
|
|
K, Thanks.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
What are the rates for?
Indicative or charging?
If you're going to use a rate from an API, make sure that you know the margin to apply. A lot of the time you'll get a spot price, aka mid price. You never trade at spot always at the buy/sell which will be off by a small margin, sometimes it's percentage, others use fixed points.
Pretend GBP-EUR rate is 1.10. A good margin would be +/-4 bp 1.06 / 1.14.
Also take into account reciprocal rates. from the above GBP-EUR would be 0.909090909.... However you apply it you get rounding errors.
FX Rates are bloody awful. If you want rates for anything other than indicative, you need the correct buy / rates and you should always just divide in the rate to reverse directions.
tl;dr;
FX is Evil.
veni bibi saltavi
|
|
|
|
|
Interesting. Thanks.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I don't really have much to offer that Naggy hasn't addressed. But I'll say this... it is possible to get the rate data without a broker's margin, but for that kind of feed you'll need to pay some moola or avoid using a broker for the data altogether and stick with Google or Yahoo et al and just accept the lag those APIs will give you.
Also, if you're doing this for an online business, I'd suggest always, always storing prices in a base currency (even for past orders) and also the currency of the sale along with the exchange rate at that point in history. It'll make your life a lot easier if you only have to think about one currency (preferably the currency you'll be paying taxes in for the company) and deal with exchanges on a case-by-case basis.
Not sure who you'll be processing payments through, but services like PayPal will handle this stuff for you btw. It's a pretty common problem...
ConvertCurrency API Operation - PayPal Developer[^]
Jeremy Falcon
|
|
|
|
|
I am using something I found from
http:
[
"https://openexchangerates.org/api/latest.json?app_id=04f370f1bf4a4ea7a386ade58f07d0e5" ]
myConnection.DownloadFile(Dts.Connections["OpenExchCurrency.json"].ConnectionString, true);
Have SQL 2012 so had to implement reading the JSON file format as a flat file, pretty simplistic it just ignores the first six lines of the file and starts with (example data)
"AED": 3.672761,
"AFN": 67.383551,
Once I read that into a table, parse (known 3 character positional for currency code, ":" to "," for value) for the four currencies I care for for the day. Added an AVG30Days and an AVGPeriod calculation. Then as someone else pointed out, I used a web based CSV request to get and add history back as far as my data goes. from before I had this option.
|
|
|
|
|
Great. Thank you.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Probably too simple but I use a call to google:
{
URI = "http://finance.google.com/finance/converter?a=1&from=NZD&to=" + Currencies[Counter];
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
try
{
System.Net.WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
tmp = sr.ReadToEnd().Trim();
sr.Dispose();
}
and then parse the result.
|
|
|
|
|
Cool, thanks.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
I use the https://www.oanda.com/fx-for-business/exchange-rates-api API which works just great for my needs - tracking USD <-> GBP every minute 24/7
|
|
|
|
|
Maintain separate accounts.
Only convert on-the-fly when reporting; "actual" conversion when laundering.
Maintain a list of daily conversion rates for reporting.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
And I got to one section ... Survey.jpg
I'm reasonably sure they didn't mean to show the "Randomizing section" to punters, but I do wish they had chosen different letters. Kinda shows what they think of me, really...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
A key to a good customer relations is sincerity.
... such stuff as dreams are made on
|
|
|
|
|
James fan is a Bad Singer with Sting and loses a thousand (8)
modified 30-Oct-17 5:46am.
|
|
|
|
|
Jacobite?
Jacko minus the k + bite = sting?
Bit controversial if I'm right, as Jacko was a a way better singer than Mr. Sting!
98.4% of statistics are made up on the spot.
|
|
|
|
|
Well done you're correct.
Not controversial though as the Bad is capatalised as in the singer of Bad.
|
|
|
|
|
Ah, yes! I'd forgotten that one.
98.4% of statistics are made up on the spot.
|
|
|
|
|
Someone decided to write an entire AngularJS application of ~100k lines in a single file
And now here I am swimming through a lake of javas**t to find out why something works. And, to add to the infinite _crazyness_, the app depends on a cordova plugin that will only run on an android device. (Can't use remote debugging either, due to an ancient cordova version).
Beauty cannot be defined by abscissas and ordinates; neither are circles and ellipses created by their geometrical formulas.
Carl von Clausewitz
Source
|
|
|
|
|
ΑlphaΔeltaΘheta wrote: entire AngularJS application of ~100k lines in a single file
Oh, the laziness that later kills! All the original dev had to do was break it up.
ΑlphaΔeltaΘheta wrote: Can't use remote debugging either
I explained this same problem to a dev long ago -- with another JavaScript-based app (written in classic ASP).
The dev told me, "I don't need a debugger. I debug it in my head." He thought he was a genius.
Well, yeah, I understand that knowing what the code is doing is great and all but using debugging tools is like using power tools (instead of hand tools)...it's quite a bit faster.
Good luck.
|
|
|
|
|
ΑlphaΔeltaΘheta wrote: Can't use remote debugging either
raddevus wrote: written in classic ASP
Reminds me of old times! You had to get creative with debugging...displaying variable contents, redirecting to a special page to show results, etc. Classic ASP (or even php) was way more logical to me than .NET where things can happen all over the place...mostly just building the page from the top down...and everything was a string! Do I miss it? Absolutely not!
"Go forth into the source" - Neal Morse
|
|
|
|
|
You must have upset the gods at some point in your life.
|
|
|
|