Martin Scorsese brings the same verve and glitz he’s so often lavished on gangster stories to another sort of casino in “The Wolf of Wall Street,” based on the career of notorious stock boiler-room guru Jordan Belfort. The movie weaves its tale of financial excess with a degree of cinematic pizzazz that rivals Belfort’s own showmanship in his chosen sphere; at times you might imagine you’re back in the phantasmagorical world of Baz Lurhmann’s Jay Gatsby. But though it goes on too long and comes across the finish line a little winded, Scorsese’s picture is a mostly exciting ride on the Wall Street wild side—so long as you don’t expect a moral at the end beyond “don’t get caught.”

Terence Winter’s script is based on the memoir by Belfort, who, after a brief stint in an established Wall Street firm (Rothschild, actually) in the 1980s, finds himself out of a job after Black Monday hits on October 19, 1987. Fortunately for his bankroll, he answers a classified ad for a trader, and at a strip-mall joint run by seedy Dwayne (Spike Jonze) quickly discovers the remunerative joys of pushing worthless penny stocks on gullible investors, grabbing large commissions while his hapless clients lose a bundle. That leads him to found Stratton Oakmont, a brokerage with an imposing name and—ultimately—posh offices that takes the same noxious practices to a far higher level, resulting in huge windfalls for Belfort and his cronies and not so much for their victims.

Among the gonzo groupies Belfort brings on board with him the most notable is Donnie Azoff (Jonah Hill), a goofball with an ambitious streak who latches onto to Jordan over lunch one day and never lets go. Together they watch their operation grow astronomically in terms of both staff and profits, adding a slick lawyer (Jon Favreau) and financial overseer (Belfort’s own dad Max, played with consummate exasperation over the outfit’s horrendous expenditures by Rob Reiner) to the mix of phone salesmen following Belfort’s hand-crafted pitch to the letter. Belfort regales his staff with messianic speeches encouraging them to set their sights ever higher, as well as after-hours diversions in which hookers and drugs play prominent roles. But nobody indulges himself more than Jordan himself, who loads up on every imaginable hallucinogen at the drop of a hat and trades in his plain-Jane wife Teresa (Cristin Milioti) for a hotter model, his bombshell mistress Naomi (Margot Robbie), after whom he names his magnificent new yacht.

Of course this is a rise-and-fall story, and Belfort’s nemesis comes in the form of straight-arrow FBI investigator Patrick Denham (Kyle Chandler), whom Jordan first foolishly tries to bribe, which only makes matters worse. Eventually Jordan decides to stash his cash in a Swiss account, which initiates a complicated series of maneuvers involving not only local couriers but an eager-to-please but decidedly shady banker (Jean Dujardin) but also Naomi’s veddy proper British aunt Emma (Joanna Lumley). In the end, however, it’s that European connection that will give the feds what they need to force Belfort to turn state’s evidence or accept an awful lot of jail time. Given the sort of guy he is, his choice is close to inevitable, and it should come as a surprise to nobody that his ultimate punishment is absurdly light, even though heavier than that meted out to higher-flying types who made a mint a decade later even as the economy crashed. And given his chutzpah, it somehow seems appropriate that in his post-Wall Street career one of his businesses has been as a motivational speaker.

“The Wolf of Wall Street” moves like a house afire, thanks not only to the spitfire performances of DiCaprio and Hill but to Rodrigo Prieto’s virtuoso camerawork, Thelma Schoonmaker’s pulse-pounding editing and a background score filled with classics chosen by Robbie Robertson. DiCaprio also narrates the picture in over-the-top style, adding to the sense of nervous energy. The effect is more successful in the movie’s first half, the early scenes of which are especially invigorated by a wacky cameo by Matthew McConaughey—still looking a bit emaciated from the loss of weight he endured for “Dallas Buyers Club”—as Jordan’s Rothschild mentor. By contrast the later reels are less engaging, despite a big set-piece involving a ship-in-a-storm rescue at sea, although there is one marvelously absurd sequence, ending in a kitchen brawl between the totally zonked-out Belfort and Azoff, in which DiCaprio demonstrates a talent for physical slapstick that would make him an ideal candidate to play Plastic Man if anyone ever decided to bring that super-hero to the screen.

It could be argued, of course, that the letdown of the picture’s second ninety minutes (it runs just a tad under three hours in toto) is appropriate, since Belfort’s downfall should bring home the moral that those who do wrong will suffer for it. But “The Wolf of Wall Street” doesn’t really turn into a cautionary tale. Chandler’s principled FBI agent remains a subway-riding drudge struggling to make ends meet (it doesn’t help that the actor brings little joy to the role), and there’s really no sense in DiCaprio’s final scenes that his character regrets anything except getting caught and having his high-octane lifestyle curtailed. Scorsese might intend for us to be repelled by what he does, but it’s difficult to find much indication of that in the film’s gleeful cataloguing of his grotesque malfeasance: though the film doesn’t glorify his career, it does encourage us to enjoy watching him con his way into his palatial mansion and expensive car and wallow in his other pleasures without worrying about the saps whose lives he destroys in the process. If anything, the moral seems to be simply that this is the way capitalism works, at least in its most extreme form, and most of us poor souls are just the folks on the other end of Stratton Oakmont’s phone lines, waiting to be taken.

So from the standpoint of message, Scorsese’s film is actually pretty depressing. But one can sit back and relish the cinematic vibrancy with which he and DiCaprio have brought this sorry example of Wall Street excess to vivid life on screen.