For (2), there are zero-fee brokers (e.g. those mentioned by downvoteme1 earlier) that you can use, so you don't have to keep feeding the broker.
Well, everything has a non 0 chance but you can code certain conditions that have to be met before an order goes through.
IMO, you would have to have significant capital to even end up in a situation where a bug causes lots of loss.
Here is an example of something you might be thinking of.
https://www.henricodolfing.com/2019/06/project-failure-case-...
> Not get lose all their money to some company's API fees
It's not too bad these days. A lot of brokers offer "zero-fees" which really just means you only have to pay the SEC ones which aren't too bad.
Which leads in to 2. The idea is that you are aiming for algorithms that take into account the API fees. If you didn't account for that in the price of business, than this is the same as not accounting for taxes in how you pay for things. That is, you did it wrong.