# What happens when you buy a stock

> A process map exported from forks.world (https://forks.world). Author: Brian. Source: https://forks.world/p/cmv21nt4d0020l206h8e0gqm2
> It describes who does what, in what order, and with which technology. Read the plain-language sections first; the JSON at the end is the exact, complete data.

## Summary

- 10 steps across 1 layer
- Persona: You
- Technology / systems: Your broker, Stock exchange, Clearing house

## How to read this file

- A process is made of **layers**. The main layer is the top level; any step of kind `subprocess` opens a detail layer with its own lanes and steps.
- **Lanes** are either persona (people/roles) or technology (systems). Each step belongs to one lane; `using` lists tools a person uses for that step.
- Step kinds: `start`, `task`, `decision` (its arrows carry the answer as a label), `subprocess`, `end`.

## What happens when you buy a stock

Lanes:
- You: person / role (id `you`)
- Your broker: technology / system (id `broker`)
- Stock exchange: technology / system (id `exch`)
- Clearing house: technology / system (id `clear`)

Steps, in the order they run:

1. **Press buy on your app** [start; You; id `t1`]
   - then Checks you have the cash
2. **Checks you have the cash** [task; Your broker; id `t2`]
   - then Sends the order to an exchange or a market maker
3. **Sends the order to an exchange or a market maker** [task; Your broker; id `t3`]
   - then Matches it to someone who wants to sell at your price
4. **Matches it to someone who wants to sell at your price** [task; Stock exchange; id `t4`]
   - then Did the order find a match?
5. **Did the order find a match?** [decision; Stock exchange; id `t5`]
   - if "Yes" go to The trade is confirmed to both sides; if "No" go to It waits in the order book until the price moves
6. **The trade is confirmed to both sides** [task; Clearing house; id `t6`]
   - then Money and shares change hands a day later
7. **Money and shares change hands a day later** [task; Clearing house; id `t7`]
   - then The shares show in your account
8. **The shares show in your account** [task; You; id `t8`]
   - then The price moves with the news and with everyone else's orders
9. **The price moves with the news and with everyone else's orders** [subprocess; You; id `t9`], links to the published process "How the Fed's interest-rate decision ripples through your life" (https://forks.world/p/cmv0kplgj002fjn0652cqcctk; full text at https://forks.world/api/public/cmv0kplgj002fjn0652cqcctk/export)
   - (no next step recorded)
10. **It waits in the order book until the price moves** [task; Stock exchange; id `t5a`]
   - then Did the order find a match?

```mermaid
flowchart LR
  subgraph l_you["You"]
    n_t1(["Press buy on your app"])
    n_t8["The shares show in your account"]
    n_t9[["The price moves with the news and with everyone else's orders"]]
  end
  subgraph l_broker["Your broker"]
    n_t2["Checks you have the cash"]
    n_t3["Sends the order to an exchange or a market maker"]
  end
  subgraph l_exch["Stock exchange"]
    n_t4["Matches it to someone who wants to sell at your price"]
    n_t5{"Did the order find a match?"}
    n_t5a["It waits in the order book until the price moves"]
  end
  subgraph l_clear["Clearing house"]
    n_t6["The trade is confirmed to both sides"]
    n_t7["Money and shares change hands a day later"]
  end
  n_t1 --> n_t2
  n_t2 --> n_t3
  n_t3 --> n_t4
  n_t4 --> n_t5
  n_t5 -->|"Yes"| n_t6
  n_t5 -->|"No"| n_t5a
  n_t5a --> n_t5
  n_t6 --> n_t7
  n_t7 --> n_t8
  n_t8 --> n_t9
```

## Full data (JSON)

```json
{
  "title": "What happens when you buy a stock",
  "maps": {
    "m_root": {
      "id": "m_root",
      "lanes": [
        {
          "id": "you",
          "name": "You",
          "type": "person"
        },
        {
          "id": "broker",
          "name": "Your broker",
          "type": "system"
        },
        {
          "id": "exch",
          "name": "Stock exchange",
          "type": "system"
        },
        {
          "id": "clear",
          "name": "Clearing house",
          "type": "system"
        }
      ],
      "steps": [
        {
          "id": "t1",
          "kind": "start",
          "lane": "you",
          "next": [
            {
              "to": "t2"
            }
          ],
          "uses": [],
          "label": "Press buy on your app"
        },
        {
          "id": "t2",
          "kind": "task",
          "lane": "broker",
          "next": [
            {
              "to": "t3"
            }
          ],
          "uses": [],
          "label": "Checks you have the cash"
        },
        {
          "id": "t3",
          "kind": "task",
          "lane": "broker",
          "next": [
            {
              "to": "t4"
            }
          ],
          "uses": [],
          "label": "Sends the order to an exchange or a market maker"
        },
        {
          "id": "t4",
          "kind": "task",
          "lane": "exch",
          "next": [
            {
              "to": "t5"
            }
          ],
          "uses": [],
          "label": "Matches it to someone who wants to sell at your price"
        },
        {
          "id": "t5",
          "kind": "decision",
          "lane": "exch",
          "next": [
            {
              "to": "t6",
              "label": "Yes"
            },
            {
              "to": "t5a",
              "label": "No"
            }
          ],
          "uses": [],
          "label": "Did the order find a match?"
        },
        {
          "id": "t5a",
          "kind": "task",
          "lane": "exch",
          "next": [
            {
              "to": "t5"
            }
          ],
          "uses": [],
          "label": "It waits in the order book until the price moves"
        },
        {
          "id": "t6",
          "kind": "task",
          "lane": "clear",
          "next": [
            {
              "to": "t7"
            }
          ],
          "uses": [],
          "label": "The trade is confirmed to both sides"
        },
        {
          "id": "t7",
          "kind": "task",
          "lane": "clear",
          "next": [
            {
              "to": "t8"
            }
          ],
          "uses": [],
          "label": "Money and shares change hands a day later"
        },
        {
          "id": "t8",
          "kind": "task",
          "lane": "you",
          "next": [
            {
              "to": "t9"
            }
          ],
          "uses": [],
          "label": "The shares show in your account"
        },
        {
          "id": "t9",
          "kind": "subprocess",
          "lane": "you",
          "link": {
            "id": "cmv0kplgj002fjn0652cqcctk",
            "scope": "public",
            "title": "How the Fed's interest-rate decision ripples through your life"
          },
          "next": [],
          "uses": [],
          "label": "The price moves with the news and with everyone else's orders"
        }
      ],
      "title": "What happens when you buy a stock",
      "parent": null
    }
  }
}
```
