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.4.32-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cybotrade-1.4.32-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (14.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

cybotrade-1.4.32-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cybotrade-1.4.32-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (14.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

File details

Details for the file cybotrade-1.4.32-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cybotrade-1.4.32-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18dc3aab8aa14e714dc717dffc1ff5ab6b9ca13677db904173eea8ae9d28c327
MD5 4f82ab97e2d26b99ca7cd0db2a6cfc23
BLAKE2b-256 3d59334126bbcaacda01e2502055c182fe5c23fcdcc5b46912af07ab213dfa75

See more details on using hashes here.

File details

Details for the file cybotrade-1.4.32-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cybotrade-1.4.32-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9bad01b88704a2b72101340f5cb1d6e163f09238ebbf3f7de59b7e745cd68106
MD5 edd11a7df07700c962ff97db4e858809
BLAKE2b-256 a847ae35ba35302978454925e6d890c1390f37a927d7db8ab77c063ae07b82a1

See more details on using hashes here.

File details

Details for the file cybotrade-1.4.32-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cybotrade-1.4.32-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c071d3c33f058d0a9bb2934b1ac212731c78c9193181b0113753fcafd01ffe02
MD5 74f3555b07d38754f8263a4139aa08e9
BLAKE2b-256 025354bfcace18dcb7a731b257680d1a69ef49da382e4d4141f0690ae9d9511e

See more details on using hashes here.

File details

Details for the file cybotrade-1.4.32-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cybotrade-1.4.32-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a2399e2ebf7cc02a696e3b6818035dc19a34be202e8c0721bf7d14d668c6372d
MD5 64a818fda679d00f9e9c53808117673f
BLAKE2b-256 9426028974936dfcb8fc54edba74599fbed38936a91904ef5a910ab9f07c4586

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