Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:51bitquant Ai hedge fund crypto DataNode call

From Leeroopedia
Knowledge Sources
Domains Data_Acquisition, Graph_Architecture
Last Updated 2026-10-28 14:00 GMT

Overview

Concrete tool for fetching per-ticker OHLCV data for a single timeframe and writing it into the LangGraph state provided by the `DataNode` class.

Description

DataNode is a BaseNode subclass instantiated with a single `Interval`. Its `__call__` reads `tickers` and `end_date` from `state["data"]`, then for each ticker calls the module-level `BinanceDataProvider.get_history_klines_with_end_time` (adding 500ms to `end_date`) and stores the resulting DataFrame into `data[f"{ticker}_{timeframe}"]`. The merged state flows downstream via the `deep_merge_dicts` reducer.

Usage

One `DataNode` per interval is added to the DAG by `Workflow.create_workflow`. You do not call it directly; it executes as part of the compiled graph. Use it as a reference when building custom data-fetching nodes.

Code Reference

Source Location

Signature

from src.utils import BinanceDataProvider, Interval

data_provider = BinanceDataProvider()

class DataNode(BaseNode):
    def __init__(self, interval: Interval = Interval.DAY_1):
        self.interval = interval

    def __call__(self, state: AgentState) -> Dict[str, Any]:
        data = state.get('data', {})
        timeframe: str = self.interval.value
        tickers = data.get('tickers', [])
        end_time = data.get('end_date', datetime.now()) + timedelta(milliseconds=500)
        for ticker in tickers:
            df = data_provider.get_history_klines_with_end_time(symbol=ticker, timeframe=timeframe, end_time=end_time)
            if df is not None and not df.empty:
                data[f"{ticker}_{timeframe}"] = df
        return state

Import

from src.graph.data_node import DataNode

I/O Contract

Inputs

Name Type Required Description
state AgentState Yes LangGraph state; reads `data["tickers"]` and `data["end_date"]`
self.interval Interval Yes Timeframe set at construction

Outputs

Name Type Description
return Dict[str, Any] Returns `state` with `data[f"{ticker}_{timeframe}"]` populated per ticker

Usage Examples

As Wired in the DAG

# Workflow.create_workflow adds one DataNode per interval
for interval in intervals:
    node_name = f"{interval.value}_node"
    workflow.add_node(node_name, DataNode(interval))
    workflow.add_edge("start_node", node_name)
    workflow.add_edge(node_name, "merge_data_node")

Direct Invocation (debugging)

from datetime import datetime
from src.graph.data_node import DataNode
from src.utils.constants import Interval

node = DataNode(Interval.HOUR_1)
state = {
    "data": {"tickers": ["BTCUSDT", "ETHUSDT"], "end_date": datetime.now(), "analyst_signals": {}},
    "metadata": {},
}
result = node(state)
print(result["data"]["BTCUSDT_1h"].tail())

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment