Swedish Stock Exchange Hit By Programming Snafu 136
New submitter whizzter writes "I was reading the Swedish national news today and an image in a stock exchange related article struck my eye. An order had been placed for 4 294 967 290 futures (0xfffffffa or -6 if treated as a 32-bit signed integer), each valued at approximately 16,000 USD, giving a neat total of almost 69 trillion USD. The order apparently started to affect valuations and was later annulled, however it is said to have caused residual effects in the system and trading was halted for several hours."
Sven and Ole Found a Trading App (Score:5, Funny)
Ole: *takes the phone and looks at the screen* Oh hey idn't dat neat? A stock trading app!
Sven: Yeah I'm like a big shot power björker now! Börk! Börk! Börk!
Ole: Oh ja, you betcha, hey I gotta a hot tip, I'm gonna buy six futures of Ikea for ya.
Sven: Ole, you idiot! Stop that, I've only got a few cents on my account.
Ole: Oh! Jajaja, oops, you're in da red now. Oofta, I'll fix this here, lemme just sell 'em real quick.
Sven: No, stop, you'll just make things worse!
Ole: I don't see a 'sell' button on dis thing, oh, I know! *punches some buttons* Oh dear. Oh shoot. Ja, I'm in a little over my head here, Sven.
Sven: *grabs the phone* Negative 460 trillion dollars!? OLE, WHAT DID YOU DO?
Ole: Oh well, ya see, I just bought negative six shares, ja? To undo me buying six positive shares, ja? And I guess der was like
Re: (Score:3, Funny)
'll pay ya back after I settle up with da liquor store first, of course.
Slashdot: We aren't racist/sexist. We shamelessly pick on everyone.
Re:Sven and Ole Found a Trading App (Score:5, Informative)
As a Swede I found the above posts very funny, though some things could be pointed out for the sake of clarity.
1) Björk is actually from Iceland. Can we elect The Swedish House Mafia as representatives of our culture instead please? ;-)
2) While I think Swedes on average consume a bit more hard liquor than the US, it's nothing like eastern Europe. We are mostly a beer people, and we are not afraid to import quality stuff. Though I guess in comparison to what goes for beer in the US, it's can almost be considered hard liquor
3) IKEA isn't a publicly traded company, and it's now owned by what is a series of (supposedly) non-profit trusts across the world with the single objective to keep it alive forever. Yes, Billy the bookcase will probably outlive you.
Re: (Score:1)
While we are happy to absolve you of the atrocity known as Bjork, us Americans of a certain age will always remember our first encounter with the Swedes:
http://muppet.wikia.com/wiki/The_Swedish_Chef
Börk! Börk! Börk!
Good times.
Re: (Score:3)
One of the first Slashdot April Fool's Day jokes had stories written in different fake languages; the Swedish one was written as tho by the Muppets' Swedish Chef. :)
Re: (Score:2)
From the very early days of usenet:
alt.swedish.chef.bork.bork.bork
alt.french.captain.borg.borg.borg
alt.ensign.crusher.die.die.die
CleverNickname took the last one a bit personally, but he was young then.
Re: (Score:3)
As a USAian of midwestern extraction and mixed Scandinavian heritage, we enjoy our "Sven & Ole" (and sometimes Lena) jokes. I was most impressed by eldavojohn's shibboleth, "oofta" (though more usually spelled uff-da). eldavojohn, where are you from? Wisconsin, Minnesota, or Michigan's U.P.? :)
Re: (Score:2)
"uff-da" I suppose that is supposed to mean usch då..?
It's the Norwegian equivalent. I wince every time I catch myself saying it.
Re: (Score:2)
The Swedes in TGWTDT practically lived on aquavit, alongside coffee and sandwiches.
Then again I think those books were more about Stieg Larsson's much more exciting, thriller-screenplay Sweden than actual Sweden.
Re: (Score:3)
Signs you haven't been to the US: mentioning that "what goes for beer in the US" is low alcohol...
Standard draft or canned beer in the US is (a) tasteless and (b) not very alcoholic. Yes, I know you have organic microbreweries in Seattle making 13% ABV stouts (or whatever), but when Joe Sixpack gets his beer it will normally be some variant of Miller/Bud/Coors Light. Those are by far the top-selling beers in America, and are 4% alcohol, which is pretty much the minimum you can make something and still call it beer.
Re: (Score:2)
Hmmm..... Pripps Blå (Bl\aa) - surely named after the sound you make when trying to drink it?
Re: (Score:2)
Then they're turned into html entities.
Then those are escaped such that they're rendered literally.
So that's 3 conversions when in fact none was necessary.
I'm glad I supplied the TeX equivalents, I suspected something might go wrong, but even I am shocked how braindead
Re: (Score:2)
Re: (Score:2)
Signs you haven't been out of the US: You think US beer is either good, or contains a normal amount of alcohol compared to the rest of the world.
Just be happy they weren't using 64-bit integers (Score:2, Funny)
Imagine it 0xFFFFFFFFFFFFFFFA. That's a big enough number that it's unreasonable to type without scientific notation :)
Re: (Score:3)
Not so unreasonable to copy and paste, though:
18,446,744,073,709,551,610
Re:Just be happy they weren't using 64-bit integer (Score:5, Funny)
That's a big enough subnet for everybody. /IPv6 humor
Re: (Score:2)
IPV6 is 128bits. So 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses.
Re: (Score:2)
Oh you were talking about the subnet portion. Fair enough, that is a mere 64bit.
SNAFU..... (Score:4, Insightful)
Re: (Score:3, Insightful)
Re: (Score:2, Redundant)
It's not a word, it's an acronym for "situation normal, all fucked up." Seems appropriate to me.
Re: (Score:3)
Wrong. It is a word whose first reference was an acronym, though used from the start as a word.
m-w defines it: a situation marked by errors or confusion : muddle; also : an error causing such a situation <a scheduling snafu>
Remember kids, etymology is fun and educational but it should not be used as a guide for the definition of a word. Instead... use the definition as the definition. Etymology's value is historical and linguistic, not communicative.
Re: (Score:1)
Re: (Score:2)
Agreed. I think the acro-word they're looking for is FUBAR. [wikipedia.org]
Although the authorities believe the CAN fix it. So "Beyond all repair" may not be literally true.
Mismatched types in caller/callee: Re:SNAFU..... (Score:4, Insightful)
That seems like the perfect description of what happened, either in terms of bad coding without type checking or input validation or in terms of the stock exchanges so frequently doing stupid things these days.
.
I think most likely it's a case of mismatched types between the calling function and how the function itself defines the calling variables. Errors that occured (possibly) (is there a link to the description/report that shows how this really happened?):
.
1 -- No Sanity Checking at Broker's end of transaction request: no validation of input at the customer or broker's computer, thus allowing a negative number entry for amount of shares to sell by the broker. aka Trusting the user to not input stupid values into a field.
2 -- Poor division of actionsactually not spliiting BUY and SELL into two different transaction categories and letting the sign of the number be the indicator as to the intent to buy or sell
3 -- Allowing wild extrema and outliers to affect trading: it's crazy to allow BID/buy orders at (average sale price)\dividedby(large positive integer) or to allow ASK/sell orders at (average sale price)\times(large positive integer). It's crazy for algorithms or humans to interpret any buy or sell price requests that are more than 50% deviated from the current running average price to be considered as anything other than either an anomaly or a deliberate attempt to fuck things up.
4 -- No sanity checking at the Stock Exchange board computer:no bounds checking on the board computer that accepts the buy/sell from the brokers. seriously, shouldn't there have been at least two places this poor interpretation could have been caught?
5 -- Unit Error / Representation Error: like letting a spacecraft go lost or kablooey by thinking the units are Imperial instead of Metric/Systeme_Internationale, maybe the order entry system represents the number X as signed long integer value, and the order-taker system (who knows what it's really called?) at the exchange interprets the number X as unsigned long integer value.
Now that number (5) error seems likely to me, as I have been learning C programmng and note that since it does not do type checking, it's possible to call a function with a variable that is holding a signed long integer, but the program is written with a
unsigned int functionname(unsigned long c1) {
\\... code goes here
}
\\... more intervening stuff
signed long int yabbadabbadoo = -6;
signed long int resultinganswer = 0;
resultinganswer=functionname(yabbadabbadoo);
so the same bit-representation is seen as two things. Akin to using the same words to mean two different things.
Re: does not do type checking (Score:3)
C does indeed do type checking; the issue here is that there are a number of implicit conversions (coercions) defined by the language.
You can enable warnings in many compilers that will flag potential problems caused by such coercions (for example, '-Wconversion' in gcc).
Re: (Score:2)
Speed at the cost of accuracy (Score:1, Insightful)
This is what happens when you want million transactions a second. You have to forgo input validation on your trading systems. Do these people ever learn?
Re: (Score:1)
Do you have any evidence that this bug was caused by input validation being skipped to enable high-frequency transactions? No? Didn't think so.
Re: (Score:2)
Re: (Score:3)
Re: (Score:2)
Not so local (Score:3, Informative)
The stockholm stock exchange is part of the NASDAQ-OMX group ( http://www.nasdaqomx.com/aboutus/whatisnasdaq/ [nasdaqomx.com] ) . Do they use the same software?
Good Point Here (Score:2)
Re:Good Point Here (Score:5, Funny)
This is why you always use dynamic storage like a link list when you potentially have to deal with numbers bigger then the address bus width.
Naah just use a FLOAT. After all, nothing bad could ever happen when doing financial calcs with FLOATs, right?
(note to sarcasm impaired... ahh on 1.9999999nd thought forget about it)
Re: (Score:2)
Re:Good Point Here (Score:5, Insightful)
A linked list of digits? Seems a little much given that there's data types meant to handle really big numbers.
At a minimum someone should be bounds/sanity checking their inputs before it goes anywhere past the user interface -- you have to assume your users will type all sorts of random stuff into your fields.
Then again, I am often surprised when testing new software that when I do something completely random I often see issues.
I remember a developer saying to me once "but nobody is ever going to do that" -- the reality is, unless you actively prevent it, sooner or later they will; and in the case of many users, it's more like within the first 5 minutes. They don't know or care what you think is 'normal' inputs -- they're going to do what they do no matter what.
Re: (Score:2)
Re: (Score:2)
Is this a troll? Not even Lisp implements bignums this way...
Re: (Score:2)
oopsie... (Score:5, Informative)
...someone forgot that putting an int into a function that expects a UINT32 is not a good idea....
Re: (Score:2, Insightful)
If I was writing an exchange system, I'd use something like Ada, where there are well tested add-ons that let you prove the accuracy and integrity of the algorithms.
In C, I almost never use signed integers. It's rare that I ever need negative values. If I'm subtracting, in the vast, vast majority of situations I expect to end up with a positive number. If the result would prove negative, something is broken. Using unsigned integers with modulo arithmetic I at least get a value in the correct domain. I only
Curious how they did that ... (Score:5, Interesting)
Since I doubt you can buy -6 shares, and likely nobody had access to $69 trillion USD (including the US government)... this sounds like it was done by someone who knew it would cause problems with the system.
I don't know about most of you, but I couldn't initiate a trade for that kind of money. How could someone even do this without having some good knowledge of how the system works?
You'd really have to assume there should be some pretty obvious checks and balances in there that either weren't, or didn't trigger.
Re:Curious how they did that ... (Score:5, Funny)
The RIAA will have the money to do that once Napster pays up... and have $3 trillion left over
Re: (Score:1)
It's called a trading algorithm bug. It's not malicious intent since you'd never know how stocks change after a trade like this, so the obvious conclusion is that someone fucked up when coding their algo and as it traded it went into a stack overflow of some sort and we got this trade for -6 units, which became 4 294 967 290 units.
Re: (Score:2)
They were trading Futures contracts, and so trading -6 contracts is routine (it's called "shorting" or "going short"). Since a Futures contract is a promise to buy/sell at some point in the future you don't have to own the underlying stock/commodity/whatever at the time you go short.
Also, from the summary: "each valued at approximately 16,000 USD, giving a neat total of almost 69 trillion USD" is misleading. Futures are traded on margin so the total the total amount of cash they would have had to put up is
Re: (Score:2)
I'm sorry, but if the US GDP was 15.09 Trillion dollars in 2011 (according to google) -- there is no meaningful scenario in which a stock trade could have a potential loss (or cost) of 69 Trillion USD.
You
Re: (Score:1)
I don't disagree with you.
I was trying to point out that this being a trade on a futures contract, not a stock, the summary was wrong in saying the total value of the trade was 69 trillion USD. When I said this is the "maximum they could lose" this is a theoretical upper bound which - as you rightly point out - could never be reached in reality.
In any case all this is predicated on this being a genuine and intentional order which was filled and honoured by the exchange. I never claimed it was. It seems pret
Re: (Score:3)
Re: (Score:2)
> "I don't believe you" value though.
Don't I know it.
Once when I was setting up a very small mail server once (think: about a dozen users), I looked at the "max number of recipients per message" variable, thought about how many distinct recipients it might potentially be reasonable to have for a single (non-mailing-list) message, and set the value to five. It was overkill, of course...
Those of you who have ever run a mail server know what happened nex
Re:Curious how they did that ... (Score:5, Informative)
Since I doubt you can buy -6 shares,
I'm willing to bet (if only I lived in a free country where I could go on Intrade to place the bet, but I digress) that someone has a UTF-8 input field with input sanitizing that only looks for one of the bazillion "minus/dash like" glyphs and a UTF-8 to int input routine that understands all or at least most of the "minus/dash like" glyphs. Happened to me once. Of course I didn't crash a world wide financial exchange, or you would have heard about it...
"Similar looking" yet different UTF-8 glyphs are one of the most exciting parts of the standard. "glyph to concept" mapping is not 1:1 any more like the old 7 bit ASCII days.
Re:Curious how they did that ... (Score:5, Funny)
How about this scenario:
"I can put in trades for any amount with this terminal"
"Any amount? What happens if you put in a negative trade?"
"It should kick out an error like this watch... I will place negative 6."
"Hey it took it! Lol I bet you just bought 6 shares!"
"Lets see it looks like it just....oh shit".
Re: (Score:2)
Account balance = $100
-6 * $16,000 $100
Transaction approved
Re: (Score:2)
Since I doubt you can buy -6 shares, .
It's a future - so yes - For derivatives, for every long trade there has to be a short side. Technically it’s “Selling to Open” but I have seen systems treat it as a buying a negative quantity.
Re: (Score:2)
Buying and selling are treated as separate cases on the 20 or so exchanges I have experience with.
The one area where negatives ARE used is in multi-legged instruments such as calendar spreads, but that's in the price not the quantity.
Re: (Score:2)
For exchanges I would hope so.
Brokerage systems that interface with the exchange – that is a different story. Like I said, I have seen systems which make the sloppy shortcut of coding “Sell to open” as negative buys.
Re: (Score:2)
I'd suspect it was triggered by a bug at a trading company with a seat on the exchange.
Some exchange protocols are in binary. The exchange may have validated only one side, assuming qtys would always be positive.
Re: (Score:1)
Since I doubt you can buy -6 shares...
Not literally, but you can sell 6 shares, or you can take the "short" side of a swap, future or other derivative transaction. These are conventionally represented as negative quantities. (The math works the same, so often you actually do write it as buying -6 contracts.) And the trade in question here is futures, not plain stock, where there's both a long and short side. Way more likely this was someone who intended to go short 6 contracts and entered -6, or a bug that dropped a negative "short" quantity i
Actually you can. And it was futures anyway. (Score:2)
Here they were talking of futures contracts not shares, you can buy or sell as many as you want, it's totally symmetrical. And that $69T was just referring to the notional, which misleading since you don't pay the notional when you en
Stop annulling these trades. (Score:5, Insightful)
The way to prevent this kind of mistaken (or even malicious) trade is to stop protecting the trader by canceling the trade as soon as the mistake is realized. If you issue a trade order, you should be liable for paying for it. If you can't, normal bankruptcy laws should apply.
Re: (Score:3)
Not if the order or quote makes no sense or somehow isn't valid.
In this case it actually caused ongoing problems with the exchange. Probably caused an overflow in the book handling logic in the matching engine.
Erroneous trades that result from bad behaviour in the exchange software should be rolled back, as they are not the fault of the trading parties.
If we were simply talking about the order being overfilled, then I'd agree with you.
Re: (Score:3)
The way to prevent this kind of mistaken (or even malicious) trade is to stop protecting the trader by canceling the trade as soon as the mistake is realized. If you issue a trade order, you should be liable for paying for it. If you can't, normal bankruptcy laws should apply.
First of all, it's not clear exactly what the trade order even meant. At worst, an offer to buy -6 futures should have been interpreted as an offer to sell 6 futures at the stated price--not as an (underflow-generated) bid for 4 billion futures. Who, exactly, do you hold liable for failing to sanity-check their inputs--the trader, his company, the exchange, their various software subcontractors who themselves may have been bought, sold, and restructured long since...?
Second, insisting that the trade ha
Re: (Score:2)
The way to prevent this kind of mistaken (or even malicious) trade is to stop protecting the trader by canceling the trade as soon as the mistake is realized. If you issue a trade order, you should be liable for paying for it. If you can't, normal bankruptcy laws should apply.
"OK, you owe me $69 trillion. I'm prepared to settle at $69 billion, that's my final offer."
Re: (Score:2)
The most obvious fix is that negative trades should not be allowed. Even better would be a type system which expresses va
Re: (Score:1)
No, that's not how exchanges work. If you put in a buy order for 0xFFFFFFFA shares, and I put in a sell order for a million shares, your order is partially fulfilled. (Assuming the prices match). It would be far too impractical to match all offers by both price and volume.
The exception is a take-over bid in which the potential buyer may make a conditional offer for a majority, and decline to buy less.
New math (Score:4, Funny)
Well, at least now we know how RIAA calculates its damages; They must have hired the same developer...
Re: (Score:1)
Must be a hoax (Score:3)
According to most of the folks posting in another thread about computer-driven cars, programming errors rarely make it out in to the world.
Is there was an issue, it must be user error. Programmers aren't supposed to make mistakes!
<snark/>
Re: (Score:3)
According to most of the folks posting in another thread about computer-driven cars, programming errors rarely make it out in to the world.
Is there was an issue, it must be user error. Programmers aren't supposed to make mistakes!
<snark/>
Nobody ever said that. What we do say is that known programming errors get fixed, known human issues do not.
While coming back from lunch today I saw somebody go through a stop sign at 40 mph and t-boning another car. Luckily everyone walked away (go modern cars and their crumple zones), and while I'm sure that particular driver will be more careful in the future, other human drivers are going to be making the same mistake forever.
A programming error causes something like this and the fix for it will be on
Re: (Score:2)
Nobody ever said that. What we do say is that known programming errors get fixed, known human issues do not.
While coming back from lunch today I saw somebody go through a stop sign at 40 mph and t-boning another car. Luckily everyone walked away (go modern cars and their crumple zones), and while I'm sure that particular driver will be more careful in the future, other human drivers are going to be making the same mistake forever.
A programming error causes something like this and the fix for it will be on an update for every single other car out there. It will never happen again. Other mistakes will happen, sure, but that one is fixed forever.
*facepalm*
1) Not every known programming error gets fixed prior to release.
2) Even if 1 were not true, it's the unknown errors that will get you.
Stock exchanges have been electronic for quite some. And they process quite a large number of transactions. I did some back of envelope googling. The average trading volume of the NYSE is 700 million. Figure they're open 200 days per year, electronic trading been around maybe 20 years, maybe NYSE is 25% of the world trading (yes, I know the volume of trading th
Re: (Score:2)
Er, that's more that 1 trading system. Plus this wasn't a bug in a US equities exchange.
Also, GP was saying a bug in a piece of software only needs to get fixed once, he never said that was before release.
64-bit (Score:2)
Was this .... (Score:2)
Monster Orders upholstered Exchange (Score:2)
I love automated translation.
Re: (Score:2)
I just figured "upholstered" was slang over there, like "plastered" in the US. Love it. A great day for words over here -- first escape goat [slashdot.org], now this. :-)
I did something like that once... (Score:1)
Dial up BBS with time limits; but you could gamble an amount of time for a 1 in 3 chance of getting double the time...
So I gambled -50,000 minutes.
And lost.
Which gave me 100,000 minutes.
Which overflowed the 16 bit counter.
Which crashed the BBS.
Which dumped me into a remote shell.
Which let me read the unencrypted password file.
-6? Not always... (Score:2)
In two's complement, sure. But this is Slashdot, pedantry is allowed, even encouraged.
Are you guys ( and girl ) sure this was a mistake? (Score:5, Interesting)
Just wrote a 2500 pg paper on flash trading (Score:2, Interesting)
For an ethics class. The only real solution is to ban it outright. These algorithms can never be fully tested because they interact with algorithms from other institutions which can lead to death spirals as algorithms cause feedback loops; bouncing trades off of one another until someone pulls the plug. And at automated speeds, that can be long after your company goes bankrupt.
From the sounds of the translated page, this was just a one-shot jacked up algorithm working in isolation which is still a proble
Re:Just wrote a 2500 pg paper on flash trading (Score:5, Funny)
.
Dude, you must be tired. 2500 pages? Or did you really mean 2500 words? Or was this a deliberate attempt to add to the humor by using the wrong units with the number? Or an amusing way to show how easily errors can slip by humans? Or just a result of tired-ness after typing and proof-reading that 2500 page essay?
Re: (Score:2)
lol didn't even see that. 2500 WORD!!!!!
Re: (Score:1)
It's not like in (academic) finance and economics they ignore the overall net benefit of trading rules to society. In fact, this is usually all that is considered.
Re: (Score:2)
You're assuming that the professor has a doctorate in ethics. Ethical issues of flash trading off the top of my head:
* Flash trading gives companies with instantaneous access to the market an unfair advantage.
* Flash trading violates the "spirit" of stock markets by allowing flash traders to exploit price swings not related to market fundamentals. The purpose of stock markets is to place capital in the hands of industry, not game the system.
* Flash trading favors extremely well funded organizations that h
Re: (Score:1)
Economists are already addressing issues of fairness, maximizing welfare, etc.
Furthermore, you are making some wrong assumptions. E.g. you say that "The purpose of stock markets is to place capital in
Re: (Score:2)
How is this an ethical matter? Or more precisely, how are people studying ethics qualified to speak about what is really a matter of finance or economics?
It's not like in (academic) finance and economics they ignore the overall net benefit of trading rules to society. In fact, this is usually all that is considered.
Finance and economics are not divorced from ethics. And the finance industry's self-policing of its own practices and ethics hasn't worked out too well. Nationalise the lot of the bastards.
The stock exchange is supposed to be about providing finance for companies, not generating ourobos-like activity for its own sake. If shares in Company A are traded back and forth in their millions over a millisecond and the share value goes up or down by 5%, this has precisely no connection to the actual value of C
Re: (Score:2)
Looking good, Billy Ray! (Score:1)
Ripple effects are pretty scary. Good thing trading can be halted to let problems subside.
Immutable arbitrary-precision integers (Score:2)
Nowadays, with the speed of CPUs, any financial application should use immutable arbitrary-precision integers (or floats). I worked for many banks and it was funny how either they found out by themselves before I got there or when I I had to tell them about it. Either way, they had to modify existing applications.
There is no limit to the number one can express that way, put apart memory constraints. Just restraint input to some number equals to the estimated number of atoms in the universe and you should be
Re: (Score:2)
I would like to add: That's what bc does.
http://slashdot.org/comments.pl?sid=3229329&cid=41872165 [slashdot.org]
Back in the mists of time... (Score:2)
Dial up BBS with time limits; but you could gamble an amount of time for a 1 in 3 chance of getting double the time...
So I gambled -50,000 minutes.
And lost.
Which gave me 100,000 minutes.
Which overflowed the 16 bit counter.
Which crashed the BBS.
Which dumped me into a remote shell.
Which let me read the unencrypted password file.
That kinda thing happens when you write your own BBS software...
Re: (Score:1)
You can't win, I'm older and have better Karma.
Ah, for the good ol' days... (Score:2)
It is with some smugness that I think back to the good old days, when this kind of things were always written in COBOL - it's clunky and wonky and not at all funky, but it does have one advantage:
http://en.wikipedia.org/wiki/Binary-coded_decimal [wikipedia.org]
In COBOL this is built in at the level of syntax and very, very easy to use, and you don't end up with binary overrun.
Hah, they don't make 'em like they used to. (I've just become a granddad, so I have the right to say this sort of thing).
This has happened before (Score:2)