Skip to content

Python library to trade cryptocurrency on Liquid by FTX

License

Notifications You must be signed in to change notification settings

mitsutoshi/liquidpy

Repository files navigation

liquidpy

.github/workflows/tests.yml License: MIT

liquidpy is the Python library for trading cryptocurrency with the Liquid by Quoine.

if you need detail information about Liquid's API, please see Liquid official API document

Install

pip install git+https://github.com/mitsutoshi/liquidpy#egg=liquidpy

How to use

Create Liquid object. API_KEY and API_SECRET are required if you use private API.

from liquidpy.api import Liquid
liquid = Liquid(api_key='xxx', api_secret='xxx')

Public API

Get products

get_products calls /products.

products = liquid.get_products()
for p in products:
    print(p['product_id'])
    print(p['currency_pair_code'])

Get a product

get_products with product_id calls /products/{product_id}.

p = liquid.get_products(product_id=5)
print(p['product_id'])          # 5
print(p['currency_pair_code'])  # BTCJPY

Private API 🔑

Private API reuqires to authenticate. If you call it without authentication, exception will be thrown.

Get accounts balance

get_accounts_balnace calls /accounts/balance.

accounts_balance = liquid.get_accounts_balnace()
for b in accounts_balance:
    print(b['currency'])
    print(b['balance'])

Get own orders

orders = liquid.get_orders()
for o in orders:
    print(f"order_id: {o['id']}")

Create an order

Create a market type order.

from liquidpy.api import SIDE_BUY
res = liquid.create_order(product_id=5, side=SIDE_BUY, quantity=0.01)
print(f"order_id: {res['id']}")

Create a limit type order.

from liquidpy.api import SIDE_BUY
res = liquid.create_order(product_id=5, side=SIDE_BUY, quantity=0.01, price=1000000)
print(f"order_id: {res['id']}")

Cancel an order

Cancel an order of id=1234.

liquid.cancel_order(id=1234)

Testing

Tests are in ./tests directory. Tests won't create new orders.

Run tests

Run all tests.

pipenv run tests

Run all tests with verbose option.

pipenv run testsv