berkshire-hathaway/
capital-allocation
Search or jump to... /
Code Issues 0 Pull requests 1 Actions Security and quality Insights

Modernize capital allocation #42

Open gregabel wants to merge 2 commits into main feat/ai-margin-crypto-float-earnings-checks

This is a fictional code review with invented pseudocode and a few borrowed public remarks. Sources are below.

Greg Abel gregabel opened this PR · 3 hours ago

Modernizes capital allocation with AI, diversifies insurance float into crypto, and automates quarterly reporting. Also adds three subsidiaries.

charliemunger reviewed 2 hours ago Changes requested View review
src/modules/FloatFromInsuranceBusinesses.ts
Comment on lines +3 to +16
type CashFloatAllocation = {  treasuryBillsAmount: number;  bitcoinAmount: number;  ethereumAmount: number;};export class FloatFromInsuranceBusinesses {  getOptimalCashFloatAllocation(cashFloatAmount: number): CashFloatAllocation {    return { treasuryBillsAmount: cashFloatAmount };    const cryptoAllocation: number = cashFloatAmount * 0.02;    return {      treasuryBillsAmount: cashFloatAmount - cryptoAllocation,      // Allocating more to Bitcoin because it's the digital gold.      // Reevaluate after the next financial crisis.      bitcoinAmount: cryptoAllocation * 0.6,      ethereumAmount: cryptoAllocation * 0.4,    };  }}
Charlie Munger charliemunger commented 2 hours ago

If you mix raisins with turds, they're still turds.[1] A 2% allocation to crypto doesn't make the other 98% smarter. It makes the whole portfolio stupid.

Warren Buffett warrenbuffett replied 2 hours ago

Hey @gregabel, Bitcoin is probably rat poison squared.[2] Let's revert this change, please.

warrenbuffett reviewed 2 hours ago Changes requested View review
src/config/subsidiaries.ts
Comment on lines +42 to +44
export const SUBSIDIARIES = [  "Acme Brick Company",
Expand 36 unchanged linesCollapse 36 unchanged lines
  "Ben Bridge Jeweler",  "Benjamin Moore & Co.",  "Berkshire Hathaway Automotive",  "Berkshire Hathaway Energy",  "BNSF",  "Borsheims",  "Brooks",  "Business Wire",  "Clayton Homes",  "CORT",  "CTB",  "Dairy Queen",  "Duracell",  "Fechheimer",  "FlightSafety",  "Forest River",  "Fruit of the Loom",  "GEICO",  "General Re",  "Helzberg Diamonds",  "HomeServices of America",  "Johns Manville",  "Jordan's Furniture",  "Justin Brands",  "Larson-Juhl",  "Lubrizol",  "Marmon Holdings",  "McLane Company",  "MedPro Group",  "MiTek",  "Nebraska Furniture Mart",  "NetJets",  "Oriental Trading Company",  "Pampered Chef",  "Precision Castparts",  "See's Candies",
  "Shaw Industries",  "TTI",  "XTRA Corporation",
  "Alleghany Corporation", // acquired in 2022  "Jazwares", // acquired with Alleghany in 2022  "Pilot Travel Centers", // controlled in 2023; wholly owned in 2024
] as const;
Warren Buffett warrenbuffett commented 30 min ago

I love this codebase because even a ham sandwich could update it.[3] @gregabel, no offense. 🥪

Greg Abel gregabel replied 28 min ago

@warrenbuffett, none taken.

src/allocators/CapitalAllocator.ts
Comment on lines +17 to +17
export class CapitalAllocator {  isWithinMarginOfSafety(opportunity: Opportunity): boolean {    const { currentPrice, currentExpectedValue } = opportunity;    const marginOfSafety: number = 0.20; // require a 20% discount to expected value    const marginOfSafety: number = this.aiModel.calculateMarginOfSafety(opportunity);    if (currentExpectedValue <= 0) return false;    return currentPrice <= currentExpectedValue * (1 - marginOfSafety);  }}
Warren Buffett warrenbuffett commented 2 hours ago

You're replacing the known margin of safety with a model we can't explain.[4]

If AI models were the key to capital allocation, Wall Street would consist of GPUs.[5]

@charliemunger?

Charlie Munger charliemunger replied 2 hours ago

I have nothing to add.[6]

src/modules/subsidiariesModule.tsNew file
Comment on lines +1 to +14
export class SubsidiariesModule {  async onNewReportReceivedFromControlledSubsidiary(    report: EarningsReport,  ): Promise<void> {    if (await this.LLMService.flagReportFocusingOnEBITDA(report)) {      await this.emailService.notifySubsidiaryManagement(        `Please include depreciation and amortization in the reports.        EBITDA leaves out costs we care about.        Please report earnings after these costs.`,      );    }  }}
Warren Buffett warrenbuffett commented 1 hour ago

I like this. Now we don't need to watch their noses lengthen every quarter.[7]

Charlie Munger charliemunger replied 1 hour ago

[suggestion] Rename flagReportFocusingOnEBITDA to flagReportFocusingOnBullshitEarnings.[8]

src/workflows/QuarterlyWorkflow.tsNew file
Comment on lines +1 to +13
export class QuarterlyWorkflow {  async processSubsidiary(    subsidiary: Subsidiary,    allocateCash: boolean,    reviewEarnings: boolean,    sendEmail: boolean,    dryRun: boolean,  ): Promise<void> {    if (reviewEarnings && !dryRun) await this.review(subsidiary);    if (allocateCash && !dryRun) await this.allocate(subsidiary);    if (sendEmail) await this.notify(subsidiary, dryRun);  }}
Charlie Munger charliemunger commented 45 min ago
At the call site
await workflow.processSubsidiary(
  subsidiary, true, false, true, false,
);

@gregabel, four booleans. Sixteen combinations. A lollapalooza of ways to send the wrong email.[9] Please give these operations names.

A lot of success in software comes from knowing what you want to avoid: spaghetti code, unnecessary complexity, unclear domain boundaries.[10]

Greg Abel gregabel replied 42 min ago

@charliemunger, I hear you. But with all due respect, I believe this complexity is necessary because one configurable function supports every subsidiary without duplicating code.

Charlie Munger charliemunger replied 40 min ago

@gregabel, I’m right, and you’re smart, and sooner or later you’ll see I’m right.[11]

src/notifications/ManagementNotifier.tsNew file
Comment on lines +1 to +7
export class ManagementNotifier {  private readonly emailService = new EmailService();  async notify(message: string): Promise<void> {    await this.emailService.send(message);  }}
Charlie Munger charliemunger commented 20 min ago
Suggested change
interface ManagementEmailSender {
  send(message: string): Promise<void>;
}

export class ManagementNotifier {
  constructor(private readonly emailService: ManagementEmailSender) {}

  async notify(message: string): Promise<void> {
    await this.emailService.send(message);
  }
}

Invert, always invert.[12]

Review required

At least 2 approving reviews are required by reviewers with write access.

All checks have passed

2 successful checks

  • TypeScript compilation passed
  • Unit tests passed
leeeomaaax leeeomaaax commented Author

Why I made this

I made this for the fun of imagining an alternate universe where Warren and Charlie were software engineers participating in a code review.

I’ve picked up a lot of mental models from them that I use in life and in product/engineering work: managing complexity, opportunity cost, etc.

Especially in times of rapid change (read: AI), I find it useful to return to first principles and ideas that have stood the test of time.

I wrote about those ideas and principles in High Output Software Engineering. You can also check other things I’ve written here.


Sources

  1. Munger’s raisins-and-turds comment. (cnbc.com)
  2. Buffett said Bitcoin was “probably rat poison squared”. (cnbc.com)
  3. Buffett’s ambition for a business that even a ham sandwich could run.
  4. Warren on margin of safety.
  5. Original from Warren: “If history books were the key to riches, the Forbes 400 would consist of librarians.”
  6. The linked article reports 119 occurrences of Charlie’s “nothing to add” in Berkshire meeting transcripts. (inc.com)
  7. From Warren: "When CEOs or investment bankers tout pre-depreciation figures such as EBITDA as a valuation guide, watch their noses lengthen while they speak."
  8. From Charlie: "I think that, every time you see the word EBITDA [earnings before interest, taxes, depreciation, and amortization], you should substitute the words “bullshit earnings.”"
  9. From Charlie: "really big effects, lollapalooza effects, will often come only from large combinations of factors."
  10. From Charlie: "A lot of success in life and business comes from knowing what you want to avoid: early death, a bad marriage, etc."
  11. From Charlie: "I’m right, and you’re smart, and sooner or later you’ll see I’m right."
  12. From Charlie: "invert, always invert"
  13. Acquired: Berkshire Hathaway Part I, Part II, and Part III (acquired.fm) helped me remember Warren and Charlie's funniest mannerisms.