Measure, Interval, and Memory are the three adapters that support soft-delete semantics. Instead of physically removing documents, theirDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
remove*Data methods set a removed: true flag on the document. All subsequent reads for that key return null, and list operations skip soft-deleted entries entirely. This pattern ensures that deleted data is recoverable for debugging and that concurrent readers never observe a partially-deleted state.
Each of these adapters is also bucket-based: a bucket or bucketName constructor argument namespaces all keys within the adapter instance, allowing the same key to coexist across different strategy contexts.
Soft-Delete Semantics
Soft-deleted entries remain in MongoDB and can be recovered by querying the collection
directly with
{ removed: true }. They are never returned through the adapter API.Measure Adapter
The Measure adapter is designed for caching expensive external lookups such as LLM completions or API responses. Each cache entry is stored under a(bucket, key) pair. Reads return null for soft-deleted entries.
Constructor
A namespace for this set of measure entries, e.g.
"llm-cache" or "price-feed".readMeasureData
Fetches the measure payload for a key. Returnsnull if the entry does not exist or has been soft-deleted.
The cache key within this bucket.
MeasureData | null
writeMeasureData
Upserts a measure payload for a key. The_when parameter is accepted for interface compatibility but is not stored.
The payload to store.
The cache key within this bucket.
Accepted for interface compatibility; not persisted.
removeMeasureData
Soft-deletes a measure entry by settingremoved: true.
The key to soft-delete within this bucket.
listMeasureData
Yields all non-removed keys in this bucket as anAsyncGenerator<string>.
AsyncGenerator<string> — yields each active (non-removed) key in the bucket.
Interval Adapter
The Interval adapter stores once-per-interval markers — used to ensure that a strategy action (e.g., sending an alert or making an API call) happens at most once per bar or time window. It stores awhen: Date alongside the payload for interval boundary checking.
Constructor
A namespace for this set of interval entries.
readIntervalData
Fetches the interval payload for a key. Returnsnull if not found or soft-deleted.
The interval key within this bucket.
IntervalData | null
writeIntervalData
Upserts an interval payload for a key, storingwhen alongside the document.
The payload to store.
The interval key within this bucket.
The bar time at which this entry was written. Stored for interval boundary checks.
removeIntervalData
Soft-deletes an interval entry.The key to soft-delete within this bucket.
listIntervalData
Yields all non-removed keys in this bucket.AsyncGenerator<string> — yields each active key in the bucket.
Memory Adapter
The Memory adapter provides per-signal named memory slots, used by LLM-driven or stateful strategies to persist arbitrary data across bars. It has the richest API of the three, addinghasMemoryData for efficient existence checks, a dispose() no-op for lifecycle compatibility, and a list method that yields both keys and payloads.
Constructor
The unique signal ID that owns this memory bucket.
A namespace within the signal’s memory, e.g.
"context" or "history".readMemoryData
Fetches a memory entry bymemoryId. Returns null if not found or soft-deleted.
The identifier for this memory slot within the bucket.
MemoryData | null
hasMemoryData
Returnstrue if a non-removed entry exists for memoryId. More efficient than readMemoryData when only existence needs to be checked.
The identifier for the memory slot to check.
boolean
writeMemoryData
Upserts a memory payload for amemoryId, storing when alongside the document.
The payload to store.
The memory slot identifier.
The bar time at which this entry was written.
removeMemoryData
Soft-deletes a memory entry.The memory slot to soft-delete.
listMemoryData
Yields all non-removed memory entries as{ memoryId, data } pairs.
AsyncGenerator<{ memoryId: string; data: MemoryData }> — yields each active entry with its ID and payload.
dispose
A no-op lifecycle method required by theIPersistMemoryInstance interface.
Collection Summary
| Adapter | Collection | Context Key | Soft Delete | Extra Methods |
|---|---|---|---|---|
| Measure | measure-items | (bucket, entryKey) | Yes | listMeasureData |
| Interval | interval-items | (bucket, entryKey) | Yes | listIntervalData |
| Memory | memory-items | (signalId, bucketName, memoryId) | Yes | hasMemoryData, listMemoryData, dispose |