Wall Street thinks Washington’s gridlock could be easing. Stocks gained, driven by budding optimism among traders that bickering politicians can reach an agreement on the budget and on increasing the government’s borrowing limit soon. ‘‘Call it ‘modest optimism,’ ’’ said one executive at LEK Securities. The stock market rose for just the third time in 12 days. Despite Friday’s gains, the trend for the last three weeks in the market has been lower. The Dow is down nearly 4 percent since it hit a record high on Sept. 18. Also Friday, Lockheed Martin said it would furlough 3,000 workers starting Monday due to the shutdown.