A Python interface for the Phemex API.


License
MIT
Install
pip install phemex==0.3.0

Documentation

Phemex: A Python API

Features

  • Initial, limited support of Phemex REST API
    • Public API:
    >>> from phemex import PhemexConnection
    >>> conn = PhemexConnection()
    >>> products = conn.get_products()
    • Authenticated connections:
    >>> from phemex import PhemexConnection, AuthCredentials
    >>> credentials = AuthCredentials(api_key, secret_key)
    >>> conn = PhemexConnection()
    >>> products = conn.get_products()
    • Placing orders:
    conn = PhemexConnection(credentials)
    
    # set up order helper classes
    order_placer = conn.get_order_placer()
    order_factory = order_placer.get_order_factory()
    
    # create a limit order
    limit = order_factory.create_limit_order(Side.SELL, 1, 10000.0, Contract('BTCUSD'))
    
    # create a market order for BTCUSD, "cross" (no leverage), sell / short
    order = order_factory.create_market_order(Side.SELL, 1, Contract('BTCUSD'))
    
    # build up a conditional that places the given market short sell order
    # when last trade price touches 8800
    conditional = ConditionalOrder(Condition.IF_TOUCHED, Trigger.LAST_PRICE, 10000.0, order)
    
    # place the orders
    limit_hnd = order_placer.submit(limit)
    cond_hnd = order_placer.submit(conditional)
    
    # cancel them
    limit_hnd.cancel()
    cond_hnd.cancel()

Installation

$ pip install phemex