The short answer is.....
You(party A) and party B have a contract.
You want to eliminate the risk that Party B goes bankrupt and can no longer pay you.
You go to party C who will take small payments from you each month/quarter and in return they will pay you if party B goes bankrupt.
Now the important things to note are:
1) The amount you pay party C is based on how you and party C analyze the bankruptcy risk of party B.
2) The amount that party C pays you when the CDS is triggered doesn't necessarily have to have any relation to your original contract with party B. ie party B might be making a one time payment of $1 million to you but nothing stops you from taking out $10 million in CDS protection on party B.
3) The trigger for a CDS may not necessarily be the failure of party B to pay, ikt might be related to their credit rating, ownership changes, or really any term you can negotiate.
4) you can write a CDS when you aren't even involved in the original party A to party B transaction. This is what happened in teh big short where Michael Burry had no involvement in the Mortgage back securities, but had several banks writhe him a CDS that payed out if the original mortgage backed security had a certain percentage of its mortgages fail.
This is where things really went off the rails as companies like AIG wrote the CDS protection for a whole lot more MBS(Mortgage backed securities) than they could possibly ever cover, because their models predicted that there really wasn't any way they could fail in the manner they did. Suddenly a single MBS could have 100x its value in CDS default protection written on it. This leverage is how the 2008 bailout got so big.
What I have just done is to create more exposure than the underlying MBS. The MBS is still only $100 million, but the total outstanding contracts on the pool (MBS + CDS) is now much larger.
What you are talking about is related to offsetting contracts, which is different.
AIG was left holding the bag for most of these. They are one of the few who did not offset like you are saying.
Which just goes to show important the offsets actually are in practice.
I buy a house at a higher-than-usual price for the area, expecting its value to increase because of some development that is occurring nearby—an automotive manufacturer has recently agreed to build a plant about 10 minutes away, creating around 2000 jobs in the area.
However, the deal still needs to be approved by the Feds. If I wait until the approval, the house might cost even more to buy and potentially make my investment unprofitable (or not profitable enough). But if the plant is not approved, my house will likely not gain enough in value and I will have paid too much.
To insure against the Feds not approving the plant, I can by a CDS against that risk. I will lose a small amount of profit in my eventual sale of the house to pay for the CDS, but will also prevent a large (profit) loss in the event that the plant is not approved.
Note: In this example, I do not have any direct interest in the (future) plant, or the auto manufacturer, and I obviously do not control the actions of Federal regulators. Nevertheless, I am exposed to risks (and benefits!) taken by them as a homeowner in the area, and a CDS can be used to insure against those risks at minimal cost.
Admittedly, this is fairly sophisticated for an individual homeowner, but this kind of thing is routine for financial professionals. CDS is a kind of insurance, and it's totally legitimate, even though you are usually not insuring something you have a direct interest in.
Of course, this is just my own personal subjective consideration. Not related to the official definitions of these terms at all.
You can insure against possible negative outcomes of someone else's contracts.
e.g.) Party A and Party B sign a contract that Party B will pay Party A $X by some date. Party A has seperately agreed to pay you $0.9X shortly afterward.
You are a savvy businessperson and realize that Party A will not have $0.9X to pay you if the Party B fails to make their payment.
Party B is on the rocks after a nasty reorg, and you think the probability they fail to pay is significantly greater than 0.
You want to protect your business against this event. To do so, you purchase a Credit Default Swap from Party C for $0.05X that ensures the full $0.9X payment.
While Michael Barry was "speculating" using CDS's, you could also argue that he was "insuring" his firm against a housing crash, which did tank most investment vehicles.
Christian Bale's character's hedge fund wanted to make a big bet that mortgage backed securities would fail.
So he shopped the banks for those that would take that bet.
The ones that agreed to take the bet, he paid them a negotiated monthly amount (basically rent) to keep the bet in effect. If he stopped paying rent, the bet was off.
The banks thought it would never happen and it was free money coming in. Since they thought the risk was 0% it was free money coming in.
... basically, the banks thought he was crazy, but would take his money to keep the bet going.
In the movie, Bale's fund gradually loses money paying "rent" on this bet / option / contract. Things get dicey when conditions that should result in the bet paying off get covered up by the banks and government, and the investors in his fund get pissed they aren't getting any return on their money as promised.
It's like you are arguing that life insurance is a bet.
So the guy in the movie got the bank to write him an insurance policy on the mortgages (really mortgage derivatives) that other people held. When those mortgages failed, the policy paid out.
Let's say you have a little sister. It's been a little while since she screamed about her stuffed frog, but you think she is going to do it again soon. You come to me and say that I can have one of the cookies out of your snack every day if I agree to give you a whole bag of cookies next time your sister screams about the frog.