Skip to main content

A minimal Python API for WooTrade

Project description

Woopy

Woopy is a minimal Python API for trading on WooTrade. It is a Python interface for the WooTrade API. Woopy is an alternative to python-wootrade, which is computationally intensive and appears unstable at Windows platforms. This has been the mean reason for the development of Woopy.

One of the reasons for the instability of python-wootrade is the unnecessary code complexity, which makes is hard to debug. It seems that python-wootrade is a stripped down version of python-binance. The source code of python-binance is equally complicated.

Woopy avoids all unnecessary complications, which leaves a simple module that is easy to maintain. Woopy has only two dependencies, namely requests and websockets.

Prerequisites

  1. First of all, you need an account at WooTrade.
  2. Next, you need to register your application by creating an API Key and Secret, which can be found at Account > Subaccounts and API.
  3. Then, you fetch your Application ID, wich can be found at Account > Subaccounts and API.

Installation

Optionally create (python -m venv venv) and activate (venv\Scripts\activate) a virtual environment. Then, run

pip install woopy

Test your installation by running the following script (with your credentials)

import woopy

woo_key = "my-woo-key"
woo_secret = "my-woo-secret"
woo_app_id = "my-app-id"

symbol = 'SPOT_BTC_USDT'

topics = {
    f'wss://wss.woo.org/ws/stream/{woo_app_id}': [f'{symbol}@trade'],
    f'wss://wss.woo.org/v2/ws/private/stream/{woo_app_id}': ['positioninfo']
}

for msg in woopy.receive(topics, woo_key, woo_secret):
    print(msg)

You should then see a stream of messages containing trade information and private information on your position.

It is preferrable to store the Application ID, API Key and API Secret as environment variables, rather than storing them as plaintext in your source code. This prevents accidental disclosure of your credentials. You can retreive an environment variable via os.getenv('name-of-variable').

Concepts

There are two ways to communicate with WooTrade, namely via HTTP requests and via websockets.

HTTP

The HTTP requests are rather straightforward and can be called via get(), post(), and delete(). The required arguments can be found in the WooTrade API reference.

Websockets

The websockets interface is implemented as an iterable recv_all(), which requires a dictionary of topics as one of its arguments. The keys of this dictionary are public and private endpoints of WooTrade. The values of this dictionary are their respective topics, as specified by the WooTrade API reference.

The recv_all() iterator handles all connection errors and automatically reconnects to the disconnected websocket. Such disconnects can be caused by an interrupted internet connection, or just when WooTrade decides that the session was long enough.

For simplicity, Woopy assumes static topics, i.e., all topics are known from the start.

Happy trading!

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

woopy-1.0.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

woopy-1.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file woopy-1.0.3.tar.gz.

File metadata

  • Download URL: woopy-1.0.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.1

File hashes

Hashes for woopy-1.0.3.tar.gz
Algorithm Hash digest
SHA256 bd44656a3e86eb209316afd22d656a0bccf62d9ac82c191ab1766bfeafc6b1c3
MD5 cf62f1916d1cd81117eabad1dedf975d
BLAKE2b-256 8abb023a77952bf9e057414182950545f50a945600d96790a21e181dcb20c93b

See more details on using hashes here.

File details

Details for the file woopy-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: woopy-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.1

File hashes

Hashes for woopy-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 40618165d8ed4c80399cf2e45bdba6f73234a72de7da152e090acabe01e1c765
MD5 3a50d23f8e92de270a7bcf38a018b6a9
BLAKE2b-256 ae2b22608c98d31498f38530ef427b07fa93c1f4a5941d2ecc50f3fcefdeff58

See more details on using hashes here.

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