R. Martin Chavez, one of Goldman Sachs’s most senior executives, will retire from the firm at the end of the year, the latest in a string of departures since the appointment of a new chief executive last year.

Mr. Chavez, a 19-year veteran of the firm, was co-head of its securities division and, before that, its chief financial officer. A technology maven and onetime energy trader, he had been regarded as a candidate to one day become chief executive. Mr. Chavez, one of the few openly gay men in a top job on Wall Street, was also a leader in the firm’s efforts to build a more diverse and inclusive work force.

Now, the 55-year-old executive said he planned to relax for a few months before moving to Los Angeles with his family and teaching a course at Stanford’s Graduate School of Business in the spring called “How Software Ate Finance.”

“I don’t do sitting around doing nothing very well,” he said in an interview on Tuesday.

Over the past year, Mr. Chavez has led an overhaul of Goldman’s trading technology, part of an effort to help the firm better serve corporate clients. It was an outgrowth of a long-running push he had made to integrate computer engineers more deeply into Goldman’s business, and, subsequently, to share the software they built directly with clients. That effort, known as Marquee, is well underway, as is a second platform called Atlas, which will streamline the trading of stocks for large institutional investors.