Goldman Sachs on Tuesday posted earnings that easily beat Wall Street expectations, but shares declined on a sharp decline in bond trading.

The Wall Street giant saw profit of $3.95 per share in the second quarter, compared with expectations of $3.39 and $3.72 a year earlier, according to analysts surveyed by Thomson Reuters. Goldman also beat on the top line, with revenue of $7.89 billion, against expectations of $7.52 billion and $7.93 billion a year ago. Shares were off nearly 1 percent in early trading.

The bank's investment and lending operation — an area that has drawn criticism from some analysts for its lack of clarity — saw a 42 percent annualized gain to $1.58 billion.

Here's a side-by-side comparison of Goldman's results and Wall Street's estimates:

EPS: $3.95 vs. $3.39 expected by analysts polled by Thomson Reuters.

Revenue $7.89 billion vs. $7.521 billion expected by Reuters.

Compensation expense: $3.23 billion vs. $3.11 billion expected by FactSet.

Noncompensation expense: $2.15 billion vs. $2.11 billion expected.

Earlier Tuesday, Bank of America reported earnings and revenue that topped expectations.

"A mixed operating environment persisted into the second quarter as conditions continued to support underwriting and M&A, while constraining certain market-making activity," Goldman CEO Lloyd C. Blankfein said in a statement. "Against that backdrop, we produced revenue growth and

improved profitability for the first half of 2017, reflecting both the diversity and strength of our global businesses."

As has been the case across Wall Street, trading activity took a beating.

Fixed income, currency and commodities tumbled 40 percent from the second quarter of 2016, which the company attributed to "a challenging environment characterized by low levels of volatility, low client activity and generally difficult market-making conditions." Net revenues in FICC came to $1.16 billion.

Goldman "has a lot of explaining to do and the FICC business looks set for a detailed review during the summer," analysts at Atlantic Equities said in a note.

Equities showed some strength, however, rising 8 percent to $1.89 billion. Trading overall fell 17 percent to $3.05 billion.

"You look at Goldman who have traditionally made money on volatility quarter after quarter and they've been struggling," said Christopher Whalen, head of Whalen Global Advisors. "These banks are fully valued, so to see them trading off when they kind of have these small beats on earnings and revenue is not a surprise. … These are commodities now. You get a dividend, you take a nap."

The company declared a dividend of 75 cents a share, which was unchanged from the previous quarter.

Investment banking revenue dropped 3 percent year over year to $1.73 billion, though the number was 2 percent higher from the first quarter.

Net income applicable to common shareholders was nearly flat at $1.63 billion.

Goldman's shares have badly underperformed this year. The stock is off 4.2 percent and has been the third-biggest drag on the Dow industrials. By comparison, the KBW Nasdaq bank index is up 4.8 percent for 2017.

Its chief rival in investment banking is Morgan Stanley, which reports Wednesday.