Well, I've asked myself and HN similar questions, and don't really have an answer yet, so I'll offer a few disconnect thoughts that I hope provide something valuable, because this is a legitimately stressful and uncommon position to be in.

Preface: If you have considered counseling or asking your doctor about ADHD, then here's what you might expect. In my case, I eventually went down this path because I had returned to University Applied Computer Science because I was in this same low period and needed a change; I wanted to challenge my imposter syndrome and see if I could push myself through the curriculum.

After succeeding at nearly all of my data structures and algorithms assignments, persuasive essays, and anything remotely engaging, I suffered a few set backs, failing one of the 2 easiest courses I'd taken, bombing my DS+A exams, and basically getting nowhere. The Data Structures exam was all writing Java Abstract Data Types and LinkedLists etc.. by hand on paper over 3 hours, and I got bored of doing that halfway through, no increased blood pressure, no sweat, it just didn't provoke an urgency in me.

I'd also slept through the midterm, and failed one of the Geo labs that required me to draw many graphs each week by hand on paper. I failed in situations that other people would consider high-pressure (passing an exam) but nailed every practically interesting or applicable assignment, and this was in my late twenties. So I went to see the nurse practitioner, we talked, she gave me a series of family questionnaires regarding mental health to see what there was a history of, and offered a prescription for Concerta 27mg (extended release Ritalin). Since then, it's helped in a subtle way to reconnect me with a tenacity for getting things done that I think had been burnt out of me, but also helped me realize that I really did probably need this my whole life. It was scary, but the effect has been marginally helpful.

-- end preface --

I've been considering getting out of dev entirely, but I don't have a good feeling for which direction to go yet, if at all. Maybe a small investment in trade school, or maybe focusing on freelance, I have no idea whether I'd succeed at either and it's tough to in-debt myself more when money already isn't coming in. You mentioned getting out of the banking job early on, but that's something I've been considering as a boring and stable job for a while, even as a teller, that would allow me to pursue my hobbies more, but really I'm open to almost anything at this point. I'm still drawn to programming though, so I'm still focusing on that, and elaborate on below.

I'm trying to be critical of what I'm good at and what I'm not good at, and I feel like I lack efficiency and depth in the few areas that are hiring, and so I'm trying to work my way back up or rebuild my proficiency from first principles.

For example, I consider myself a frontend developer, but my last few roles have all been jumping into an existing complex projects and making incremental improvement or refactors, with no significant responsibility. Among some weak points are my knowledge of low-level software engineering, building SaaS products from scratch and scaling them, using AWS or Azure, and I've let my backend experience stagnate. To address these, I've been working through Nand2Tetris (highly recommended), and building up some basic projects from scratch using Django, Nuxt.js, Next.js, Postgres, and Tailwind, so I can at least speak more confidently about them and expand my job search for when the tides turn.

It's important to cultivate a good sense of self during these periods. If you can, get out into the mountains, or into nature, alone, and spend some time thinking on it. Independent from that, if you're not in good physical shape, just start showing up to the gym 3 times a week for about an hour each time. These are some of the non-tech ways I stay mentally engaged and are all things people find easiest to make excuses about when they're working that 9-5, because they just don't have the time. Well... you and I have the time, so we should use it, and once you get going, it creates a positive feedback cycle that's hard to break when you do land something. Socialize, spend direct 1-on-1 time with people and build trust.