Slashdot Mirror


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."

35 of 136 comments (clear)

  1. Sven and Ole Found a Trading App by eldavojohn · · Score: 5, Funny

    Sven: Hey der Ole, check out dis new app I got on my phone here.
    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 ... 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.

    --
    My work here is dung.
    1. Re:Sven and Ole Found a Trading App by sl4shd0rk · · Score: 2, 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.

      --
      Join the Slashcott! Feb 10 thru Feb 17!
    2. Re:Sven and Ole Found a Trading App by Anonymous Coward · · 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.

    3. Re:Sven and Ole Found a Trading App by Kozz · · Score: 2

      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.? :)

      --
      I only post comments when someone on the internet is wrong.
    4. Re:Sven and Ole Found a Trading App by Grog6 · · Score: 2

      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. :)

      --
      Truth isn't Truth - Guliani
    5. Re:Sven and Ole Found a Trading App by tehcyder · · Score: 2

      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.

      --
      To have a right to do a thing is not at all the same as to be right in doing it
  2. Just be happy they weren't using 64-bit integers by Anonymous Coward · · Score: 2, Funny

    Imagine it 0xFFFFFFFFFFFFFFFA. That's a big enough number that it's unreasonable to type without scientific notation :)

  3. SNAFU..... by m.shenhav · · Score: 4, Insightful

    ..... the word is being abused here.

    1. Re:SNAFU..... by Anonymous Coward · · Score: 3, Insightful

      What, you think the markets aren't normally AFU?

    2. Re:SNAFU..... by Aighearach · · Score: 2

      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.

  4. Not so local by j1976 · · Score: 3, Informative

    The stockholm stock exchange is part of the NASDAQ-OMX group ( http://www.nasdaqomx.com/aboutus/whatisnasdaq/ ) . Do they use the same software?

  5. oopsie... by maz2331 · · Score: 4, Informative

    ...someone forgot that putting an int into a function that expects a UINT32 is not a good idea....

    1. Re:oopsie... by Anonymous Coward · · 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 ever have to check for sane upper bounds, not upper _and_ lower bounds. It's half as much work, and half as much to go wrong.

  6. Curious how they did that ... by gstoddart · · Score: 4, 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.

    --
    Lost at C:>. Found at C.
    1. Re:Curious how they did that ... by SJHillman · · Score: 4, Funny

      The RIAA will have the money to do that once Napster pays up... and have $3 trillion left over

    2. Re:Curious how they did that ... by timeOday · · Score: 2

      It is always painful coding an arbitrary maximum "I don't believe" you value though. Evidently somebody declined to do so :)

    3. Re:Curious how they did that ... by vlm · · Score: 4, 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.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    4. Re:Curious how they did that ... by TheCarp · · Score: 4, 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".

      --
      "I opened my eyes, and everything went dark again"
    5. Re:Curious how they did that ... by jonadab · · Score: 2

      > It is always painful coding an arbitrary maximum
      > "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 next. Within a day of deploying the thing I'd raised the limit at least three times. At that point the new limit lasted for a few months, but then...

      What, seriously? You really have a legitimate work-related need to send exactly the same message word-for-word to more than fifty addresses at once, for real?

      Yeah. More than fifty individually hand-typed addresses, even.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    6. Re:Curious how they did that ... by MattBecker82 · · 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 orders of magnitude less. 69 trillion USD is simply the maximum they could lose.

  7. Stop annulling these trades. by Anonymous Coward · · 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.

    1. Re:Stop annulling these trades. by tolkienfan · · Score: 2

      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.

    2. Re:Stop annulling these trades. by Idarubicin · · 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.

      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 happened and then forcing the trader into bankruptcy (and associated bankruptcy protection) is likely to punish the 'innocent' participants in the market more than anyone else.

      --
      ~Idarubicin
  8. Re:Good Point Here by vlm · · 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)

    --
    "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
  9. Re:Speed at the cost of accuracy by skovnymfe · · Score: 2

    Why bother? If something gets fucked up, Mr. Street just rolls back all the bad, and gives us another chance. No problem.

  10. Re:Just be happy they weren't using 64-bit integer by omnichad · · Score: 2

    Not so unreasonable to copy and paste, though:
    18,446,744,073,709,551,610

  11. Re:Good Point Here by gstoddart · · Score: 4, Insightful

    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.

    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.
  12. New math by girlintraining · · Score: 3, Funny

    Well, at least now we know how RIAA calculates its damages; They must have hired the same developer...

    --
    #fuckbeta #iamslashdot #dicemustdie
  13. Must be a hoax by mcmonkey · · Score: 2

    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/>

    1. Re:Must be a hoax by LateArthurDent · · Score: 2

      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 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.

  14. Are you guys ( and girl ) sure this was a mistake? by vikingpower · · Score: 4, Interesting

    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
  15. Re:Just be happy they weren't using 64-bit integer by NatasRevol · · Score: 4, Funny

    That's a big enough subnet for everybody. /IPv6 humor

    --
    There are two types of people in the world: Those who crave closure
  16. Mismatched types in caller/callee: Re:SNAFU..... by girlinatrainingbra · · Score: 3, Insightful

    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.

  17. Re:Just wrote a 2500 pg paper on flash trading by girlinatrainingbra · · Score: 4, Funny

    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?
    ;>)

  18. Re: does not do type checking by neonsignal · · Score: 2

    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).