Skip to main content

Domain-Driven Technical Indicators: A Journey from Booleans to Value Objects

· 5 min read
Max Kaido
Architect

In our recent work on the Mercury TA service, we encountered an interesting challenge with our Ichimoku Cloud indicator implementation. The issue arose from using primitive boolean values to represent complex market states, leading to ambiguous and sometimes incorrect interpretations. This post outlines our three-step solution to create a more robust and maintainable technical analysis API.

The Holy War: Git History Preservation vs The Evil of Squashing

· 3 min read
Max Kaido
Architect

In the ancient scrolls of software development, there exists a tale of two opposing forces: the Noble Order of Git History Preservers and the Dark Legion of Commit Squashers. Today, we delve into this epic saga that continues to shape the destiny of codebases across the realms.

The Dark Arts of Squashing

In the shadows lurk those who practice the dark art of squashing commits. They tempt developers with promises of a "clean history" and "simplified logs." But at what cost? Every squashed commit is a story lost to the void, a context erased from existence, a debugging trail gone cold.

The Birth of Dike: A Tale of Practical Justice

· 3 min read
Max Kaido
Architect

Today marks a significant milestone in Mercury Bot's evolution with the release of version 1.15.3, introducing Dike - our new market ranking system named after the Greek goddess of justice and fair judgment. This release represents not just a technical improvement, but a journey from theoretical perfection to practical wisdom.

The Three Paths to Order

The Path to Practical Justice

Our journey to perfect market rankings has been a tale of architectural evolution through three distinct approaches:

  1. Kairos - Immutable QuickSort: Our first attempt embraced immutability with QuickSort. Like the god of perfect moments, each comparison created a pristine snapshot of truth. The approach was theoretically elegant - each state change produced a new, immutable copy, ensuring perfect consistency. However, the cost of creating and maintaining these immutable states for each comparison became overwhelming. The divine scrolls of our Redis store filled with countless versions of truth.

  2. Hermes - Event Sourced QuickSort: Learning from Kairos, we turned to Hermes's wisdom of recording history. Instead of storing states, we recorded each comparison as an event. This event-sourcing approach promised perfect traceability - every decision was a chapter in our story. Yet as our tournaments grew, reconstructing the current state from this historical narrative became increasingly complex. The events, though perfectly preserved, created a tapestry too intricate to unravel efficiently.

NestJS Dependency Injection Pitfalls: A Tale of Duplicate Providers

· 2 min read
Max Kaido
Architect

The Scenario

Today, I encountered a classic dependency injection issue while integrating a new tournament system with artifacts tracking in our Mercury Bot project. The error was subtle but instructive:

[Nest] 2991604  - 02/03/2025, 6:01:58 PM   ERROR [ExceptionHandler] Cannot read properties of undefined (reading 'get')
TypeError: Cannot read properties of undefined (reading 'get')

The Root Cause

Kairos: The God of Perfect Moments in Market Ranking

· 2 min read
Max Kaido
Architect

In the bustling digital marketplace of cryptocurrency trading, where millions of decisions are made in microseconds, there exists an algorithm named after one of the most enigmatic Greek deities - Kairos, the god of the perfect moment.

The Myth

Kairos was depicted as a young man with a distinctive forelock of hair at his forehead, but completely bald at the back. The symbolism was clear: you must grasp opportunity at the precise moment it presents itself, for once it passes, even the swiftest hand cannot catch it.

He carried a pair of scales, delicately balanced on a razor's edge - a reminder that decisions must be made with precision, yet swiftly. The ancient Greeks said that Kairos moved with such speed that he could dance on this razor without being cut.

Sorting Prompts Evolution - Finding the Perfect Balance

· 9 min read
Max Kaido
Architect

In our quest to improve market comparison accuracy, we've experimented with different versions of sorting prompts. This analysis compares their effectiveness and helps identify the optimal approach.

Test Setup

  • Markets: BTCUSDT vs ETHUSDT
  • Timeframe: 4h
  • Core Indicators: RSI, MACD, Bollinger Bands, Volume, ADX, Volatility, Ichimoku
  • Models Tested: LLAMA3.2:3B, GEMMA2:2B, DEEPSEEK:R1:1.5B

Types Organization in TypeScript Projects: Mercury Bot Case Study

· 2 min read
Max Kaido
Architect

Types are the backbone of any TypeScript project, but as the codebase grows, they can become scattered and hard to maintain. Here's a practical guide on organizing types, with a real-world example from Mercury Bot.

General Approaches to Type Organization

1. Domain-Driven Type Organization

Keep types close to their domain logic, organized by feature. This approach makes it easy to find related types and maintains a clear connection between types and their usage.

src/
├── market-ranking/
│ ├── types/
│ │ ├── state.types.ts
│ │ ├── config.types.ts
│ │ └── index.ts