Swedish Stock Exchange Hit By Programming Snafu
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: Hey der Ole, check out dis new app I got on my phone here. ... some underflow involved der? With de app, ja? Ah gosh gee, Sven, I'm sorry, I'll pay ya back after I settle up with da liquor store first, of course.
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
My work here is dung.
Imagine it 0xFFFFFFFFFFFFFFFA. That's a big enough number that it's unreasonable to type without scientific notation :)
..... the word is being abused here.
The stockholm stock exchange is part of the NASDAQ-OMX group ( http://www.nasdaqomx.com/aboutus/whatisnasdaq/ ) . Do they use the same software?
...someone forgot that putting an int into a function that expects a UINT32 is not a good idea....
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.
Lost at C:>. Found at C.
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.
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)
"Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
Why bother? If something gets fucked up, Mr. Street just rolls back all the bad, and gives us another chance. No problem.
Not so unreasonable to copy and paste, though:
18,446,744,073,709,551,610
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.
Lost at C:>. Found at C.
Well, at least now we know how RIAA calculates its damages; They must have hired the same developer...
#fuckbeta #iamslashdot #dicemustdie
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/>
It did, after all, influence trading. What if this stunt was disguised as an - admittedly stupid - mistake, but in fact wasn't one ?
Religous speak to God. Insane are spoken to by God. When all shut up, one can finally hear Shostakovich in peace
That's a big enough subnet for everybody. /IPv6 humor
There are two types of people in the world: Those who crave closure
SNAFU = Situation Normal: All Fucked Up.
;>)
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:Just wrote a 2500 pg [page?] paper on flash trading
;>)
.
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?
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).