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.
  4. 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.

Installation

  1. Optionally create (python -m venv venv) and activate (venv\Scripts\activate) a virtual environment.
  2. Run
pip install woopy

Test your installation by running the following script:

import woopy
import os

woo_key = os.getenv("WOO_API_KEY", "my-woo-key")
woo_secret = os.getenv("WOO_API_SECRET", "my-woo-secret")
woo_app_id = os.getenv("WOO_APPLICATION_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 see a stream of messages containing trade information and private information on your position.

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 receive(), 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 receive() 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.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

woopy-1.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: woopy-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 47e8dd47388ce78673f5f8800d6afa4b2e03ee070e7ad332f9d1d782e36daa23
MD5 fc3c383df4a23081f29023c0375878d0
BLAKE2b-256 8ca366785bd9c15923fbbefad00703b49383a4e42ddcaaa99d2ccf844b0d3ad7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: woopy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f216820fd2457016d1daaaa40008cb1b3206dcf04c32e62689c74dca651d608
MD5 c7187e08e00b25585be58b3b95579c8f
BLAKE2b-256 6c257faa80e1b90629c67423f0b188d6da1d1e5ae0a6847737d1d6745ea17a58

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