Skip to main content

A python framework that can be used to create, test and deploy trading algorithms.

Project description

Dijkies

Dijkies is a Python framework for creating, testing, and deploying algorithmic trading strategies in a clean, modular, and exchange-agnostic way.

The core idea behind Dijkies is to separate trading logic from execution and infrastructure, allowing the same strategy code to be reused for:

  • Historical backtesting
  • Paper trading
  • Live trading

Philosophy

In Dijkies, a strategy is responsible only for making decisions — when to buy, when to sell, and how much. Everything else, such as order execution, fee calculation, balance management, and exchange communication, is handled by dedicated components.

This separation ensures that strategies remain:

  • Easy to reason about
  • Easy to test
  • Easy to reuse across environments

A strategy written once can be backtested on historical data and later deployed to a real exchange without modification.

How It Works

At a high level, Dijkies operates as follows:

  1. Market data (candles) is fetched from an exchange or data provider
  2. A rolling window of historical data is passed to a strategy
  3. The strategy analyzes the data and generates buy/sell signals
  4. Orders are placed through a standardized execution interface
  5. Account state is updated accordingly
  6. Results are collected (during backtesting) or executed live

Key Design Principles

  • Strategy–Executor separation Trading logic is completely decoupled from execution logic.

  • Single interface for backtesting and live trading Switching between backtesting and live trading requires no strategy changes.

  • Explicit state management All balances and positions are tracked in a transparent State object.

  • Minimal assumptions Dijkies does not enforce indicators, timeframes, or asset types.

  • Composable and extensible New exchanges, execution models, and risk layers can be added easily.

Who Is This For?

Dijkies is designed for:

  • Developers building algorithmic trading systems
  • Quantitative traders who want full control over strategy logic
  • Anyone who wants to move from backtesting to production without rewriting code

What Dijkies Is Not

  • A no-code trading bot
  • A black-box strategy optimizer
  • A fully managed trading platform

Dijkies provides the building blocks, not the trading edge.


Quick Start

This quick start shows how to define a strategy, fetch market data, and run a backtest in just a few steps.

1. Define a Strategy

A strategy is a class that inherits from Strategy and implements the execute method. It receives a rolling dataframe of candles and decides when to place orders.

# create strategy

from dijkies.executors import ExchangeAssetClient
from dijkies.strategy import Strategy

from ta.momentum import RSIIndicator
from pandas.core.frame import DataFrame as PandasDataFrame

from dijkies.executors import BacktestExchangeAssetClient, State

from dijkies.data_pipeline import DataPipeline, NoDataPipeline


class RSIStrategy(Strategy):
    analysis_dataframe_size_in_minutes = 60*24*30

    def __init__(
        self,
        executor: ExchangeAssetClient,
        lower_threshold: float,
        higher_threshold: float,
    ) -> None:
        self.lower_threshold = lower_threshold
        self.higher_threshold = higher_threshold
        super().__init__(executor)

    def execute(self, candle_df: PandasDataFrame) -> None:
        candle_df["momentum_rsi"] = RSIIndicator(candle_df.close).rsi()

        previous_candle = candle_df.iloc[-2]
        current_candle = candle_df.iloc[-1]

        is_buy_signal = (
            previous_candle.momentum_rsi > self.lower_threshold
            and current_candle.momentum_rsi < self.lower_threshold
        )

        if is_buy_signal:
            self.executor.place_market_buy_order(
                self.executor.state.base,
                self.executor.state.quote_available,
            )

        is_sell_signal = (
            previous_candle.momentum_rsi < self.higher_threshold
            and current_candle.momentum_rsi > self.higher_threshold
        )

        if is_sell_signal:
            self.executor.place_market_sell_order(
                self.executor.state.base,
                self.executor.state.base_available,
            )

    def get_data_pipeline(self) -> DataPipeline:
        """
        Implement this metho
        """
        return NoDataPipeline()

2. fetch data for your backtest

Market data is provided as a pandas DataFrame containing OHLCV candles.

from dijkies.exchange_market_api import BitvavoMarketAPI

bitvavo_market_api = BitvavoMarketAPI()

candle_df = bitvavo_market_api.get_candles()

3. Set Up State and BacktestingExecutor

Market data is provided as a pandas DataFrame containing OHLCV candles.

from dijkies.executors import BacktestExchangeAssetClient, State

state = State(
    base="XRP",
    total_base=0,
    total_quote=1000,
)

executor = BacktestExchangeAssetClient(
    state=state,
    fee_limit_order=0.0015,
    fee_market_order=0.0025,
)

4. Run the Backtest

Use the Backtester to run the strategy over historical data.

from dijkies.backtest import Backtester

strategy = RSIStrategy(
    executor=executor,
    lower_threshold=35,
    higher_threshold=65,
)

results = strategy.backtest(
    candle_df=candle_df,
)

results.total_value_strategy.plot()
results.total_value_hodl.plot()

Deployment & Live Trading

Dijkies supports deploying strategies to live trading environments using the same strategy code that is used for backtesting. Deployment is built around a small set of composable components that handle persistence, credentials, execution switching, and bot lifecycle management.

At a high level, deployment works by:

  1. Persisting a configured strategy
  2. Attaching a live exchange executor
  3. Running the strategy via a Bot
  4. Managing lifecycle states such as active, paused, and stopped

Core Deployment Concepts

Strategy Persistence

Strategies are serialized and stored so they can be resumed, paused, or stopped without losing state.

This includes:

  • Strategy parameters
  • Internal indicators or buffers
  • Account state (balances, open orders, etc.)

Persistence is handled through a StrategyRepository.


Strategy Status

Each deployed strategy (bot) exists in one of the following states:

  • active — strategy is running normally
  • paused — strategy execution stopped due to an error
  • stopped — strategy has been intentionally stopped

Status transitions are managed automatically by the deployment system.


Executor Switching

One of Dijkies’ key design goals is that strategies do not know whether they are backtesting or live trading.

At deployment time, the executor is injected dynamically:

  • BacktestExchangeAssetClient for backtesting
  • BitvavoExchangeAssetClient for live trading

No strategy code changes are required.


Strategy Repository

The StrategyRepository abstraction defines how strategies are stored and retrieved.

class StrategyRepository(ABC):
    def store(...)
    def read(...)
    def change_status(...)

LocalStrategyRepository

The provided implementation stores strategies locally using pickle.

Directory Structure

root/ └── person_id/ └── exchange/ └── status/ └── bot_id.pkl

from pathlib import Path
from dijkies.bot import LocalStrategyRepository

repo = LocalStrategyRepository(Path("./strategies"))

# read

strategy = repo.read(
    person_id="ArnoldDijk",
    exchange="bitvavo",
    bot_id="rsi_bot",
    status="active"
)

# store

repo.store(
    strategy=strategy,
    person_id="ArnoldDijk",
    exchange="bitvavo",
    bot_id="berend_botje",
    status="active"
)

# change status

repo.change_status(
    person_id="ArnoldDijk",
    exchange="bitvavo",
    bot_id="berend_botje",
    from_status="active",
    to_status="stopped",
)

This makes it easy to:

  • Resume bots after restarts
  • Inspect stored strategies
  • Build higher-level orchestration around the filesystem

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dijkies-0.1.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dijkies-0.1.1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file dijkies-0.1.1.tar.gz.

File metadata

  • Download URL: dijkies-0.1.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dijkies-0.1.1.tar.gz
Algorithm Hash digest
SHA256 02af9e5260612c69aa511cc7aed057d117a355a6582eae719b73f4e308a00710
MD5 9fbb965345ba05fa1f5adc38efaa74b1
BLAKE2b-256 f8501d10d0fbfa751f8b2537066cb33866e6acde576d2cc74dd918e05064f52c

See more details on using hashes here.

File details

Details for the file dijkies-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dijkies-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dijkies-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6d32d1e93044b5570c443436f11831b6dd59c9caf2bd3d916d892628bf5b0dcf
MD5 0efa0fe3d6855fa1663444161efdaac6
BLAKE2b-256 8420ad90903df1b521091f93e3a86de96d2fdf24e381795c85ec868751067e1b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page