Skip to main content

This library contains Cybotrade's core runtime, integrations with Exchanges API, historical and live market data collector and wrap them into a simple, easy-to-use Python SDK.

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


Release history Release notifications | RSS feed

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

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

cybotrade-1.5.1a1-cp312-none-win_amd64.whl (13.6 MB view details)

Uploaded CPython 3.12Windows x86-64

cybotrade-1.5.1a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cybotrade-1.5.1a1-cp311-none-win_amd64.whl (13.6 MB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file cybotrade-1.5.1a1-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for cybotrade-1.5.1a1-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 307cd0628c78dcf2a0f894a4e1a76a46d9b4e25b66d906dd95473a1055ae1d3c
MD5 62f27c0180c0f0656f9b740540cc77c9
BLAKE2b-256 346b1f3b7d096522c3c13f5f337f81fdb4306abf1fbb116ba175b90b6d7305b4

See more details on using hashes here.

File details

Details for the file cybotrade-1.5.1a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cybotrade-1.5.1a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0935e871abbe9bbed3e8a5e75a35ec924256ef6a107abfa7669a7268f84a156a
MD5 5d71618ae695812709f5f5b0e01c542b
BLAKE2b-256 121c186413d262f08bcfbc6b4be7b9ff7a7126357fb96919a23e4719322c0773

See more details on using hashes here.

File details

Details for the file cybotrade-1.5.1a1-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for cybotrade-1.5.1a1-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 2783a3c8f7b105e1668b723412a4a3ae21b677f57e01a98145646f20d794ae37
MD5 6903459ca5dc6080b0cf5bf1c11850b6
BLAKE2b-256 5609edb9805d54a4f1dc07c66ee398e32c7725f75b52886b8484fdbfbad519a1

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