Skip to main content

No project description provided

Project description

Cybotrade

This is the Client SDK for building automated trading strategies on Cybotrade. This library provides the core runtime, integration with Exchanges API, historical and live market data collector and wrap them into a simple, easy-to-use and easy-to-learn Python SDK as a foundation users' strategies.

Documentation

The documentation for the Cybotrade SDK can be found here.

Installation

pip install cybotrade

Usage

The following example shows how to create a simple strategy that buys 0.01 BTC when the price goes up and sells 0.01 BTC when the price goes down.

For a more advanced usage, please refer to the documentation.

from cybotrade.strategy import Strategy as BaseStrategy
from cybotrade.models import (
    OrderParams, 
    OrderSide,
    RuntimeMode,
    RuntimeConfig,
    Exchange,
)
from datetime import datetime, timedelta, timezone

import asyncio

class Strategy(BaseStrategy):
    async def on_candle_closed(self, strategy, topic, symbol, data_map):
        # Get the currently closed candles
        candles = data_map[topic] 

        if candles[-1].close > candles[-2].close:
            # Buy 0.01 BTC
            await strategy.open(
                side=OrderSide.Buy,
                take_profit=None,
                stop_loss=None,
                quantity=0.01,
                limit=None
            )
        else:
            # Sell 0.01 BTC
            await strategy.open(
                side=OrderSide.Sell,
                take_profit=None,
                stop_loss=None,
                quantity=0.01,
                limit=None
            )

async def main():
    runtime = await Runtime.connect(
        RuntimeConfig(
            mode=RuntimeMode.Backtest,
            exchange=Exchange.BybitLinear,
            datasource_topics=[],
            candle_topics=["candles-1h-BTC/USDT-bybit"],
            start_time=datetime.now(timezone.utc) - timedelta(minutes=10000),
            end_time=datetime.now(timezone.utc),
            api_key="YOUR_CYBOTRADE_API_KEY",
            api_secret="YOUR_CYBOTRAD_API_SECRET",
            data_count=100
        ),
        Strategy(),
    )

    await runtime.start()

asyncio.run(main())

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

cybotrade-1.4.9-cp312-none-win_amd64.whl (11.6 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

cybotrade-1.4.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.0 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

cybotrade-1.4.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

cybotrade-1.4.9-cp312-cp312-macosx_11_0_arm64.whl (9.7 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

cybotrade-1.4.9-cp312-cp312-macosx_10_12_x86_64.whl (10.3 MB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

cybotrade-1.4.9-cp311-none-win_amd64.whl (11.6 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

cybotrade-1.4.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.0 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

cybotrade-1.4.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

cybotrade-1.4.9-cp311-cp311-macosx_11_0_arm64.whl (9.7 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cybotrade-1.4.9-cp311-cp311-macosx_10_12_x86_64.whl (10.4 MB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

Supported by

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