Package: delta-rest-client
Python Rest Client for Delta ApiDelta Exchange is a crypto derivatives exchange where you can trade bitcoin, ethereum, ripple futures upto 100x leverage. This package is a wrapper around rest apis of Delta Exchange.
User Guide -https://www.delta.exchange/user-guideAPI Documentation -https://docs.delta.exchangePlease read theChangelogbefore using this package.Get startedCreate an account onhttps://testnet.delta.exchange/signupInstall the package:pip install delta-rest-clientFollow the below snippet to trade on testnet:from delta_rest_client import DeltaRestClient
delta_client = DeltaRestClient(
  base_url='https://testnet-api.delta.exchange',
  api_key='',
  api_secret=''
)Get json list of available contracts to trade from given url and note down the product_id and asset_id, as it will be used in most of the api calls.
production -https://api.delta.exchangetestnet -https://testnet-api.delta.exchangeMethodsGet AssetsGet list of assets supported on Delta.response = delta_client.get_assets()Get Product DetailGet product detail of current product.See sample responseproduct = delta_client.get_product(product_id) # Current Instrument
settling_asset = product['settling_asset'] # Currency in which the pnl will be realisedNameTypeDescriptionRequiredproduct_idintegerid of producttrueGet Ticker DataSee sample responseresponse = delta_client.get_ticker(symbol)NameTypeDescriptionRequiredsymbolstringproduct symboltrueGet OrderbookGet level-2 orderbook of the product.See sample responseresponse = delta_client.get_l2_orderbook(product_id)NameTypeDescriptionRequiredproduct_idintegerid of producttrueOpen OrdersGet open orders.
Authorization required.See sample responseorders = delta_client.get_live_orders()Place OrderCreate a new market order or limit order.
Authorization required.See sample responseorder_response = delta_client.place_stop_order(
        product_id=product_id,
        size=10,
        side='sell',
				limit_price='7800',
        order_type=OrderType.LIMIT,
     		time_in_force=TimeInForce.FOK
    )NameTypeDescriptionRequiredproduct_idintid of producttruesizeintorder sizetruesidestringbuy or selltruelimit_pricestringorder price (ignored if market order)falseorder_typestringlimit or marketfalse (LIMIT by default)time_in_forcestringIOC or GTC or FOKfalse (GTC by default)post_onlystringtrue or falsefalse (false by default)Place Stop OrderAdd stop loss or trailing stop loss.
Authorization required.See sample response# Trailing Stop loss
order_response = delta_client.place_stop_order(
        product_id=product_id,
        size=10,
        side='sell',
				limit_price='7800',
        order_type=OrderType.LIMIT,
        trail_amount='20',
        isTrailingStopLoss=True
    )

# Stop loss
order_response = delta_client.place_stop_order(
        product_id=product_id,
        size=10,
        side='sell',
        order_type=OrderType.MARKET,
        stop_price='8010.5',
    )NameTypeDescriptionRequiredproduct_idintid of producttruesizeintorder sizetruesidestringbuy or selltruestop_pricestringprice at which order will be triggeredfalse(required if stop_loss)trail_amountstringtrail pricefalse(required if trailing_stop_loss)limit_pricestringorder price (ignored if market order)falseorder_typestringlimit or marketfalse (LIMIT by default)time_in_forcestringIOC or GTC or FOKfalse (GTC by default)isTrailingStopLossstringtrue or falsefalse (false by default)Cancel OrderDelete open order.
Authorization required.See sample responsecancel_response = delta_client.cancel_order(product_id, order_id)NameTypeDescriptionRequiredproduct_idintid of producttrueorder_idintorder idtrueBatch Create OrdersCreate multiple limit orders. Max number of order is 5.
Authorization required.See sample responseresponse = delta_client.batch_create(product_id, orders)NameTypeDescriptionRequiredorderarrayarray of orderstrueBatch Cancel OrdersCancel multiple open orders. Max number of order is 5.
Authorization required.See sample responseresponse = delta_client.batch_cancel(product_id, orders)NameTypeDescriptionRequiredorderarrayarray of orderstrueChange Order LeverageChange leverage for new orders.
Authorization required.See sample responseresponse = delta_client.set_leverage(product_id, leverage)NameTypeDescriptionRequiredproduct_idintegerid of producttrueleveragestringleverage valuetrueOpen PositionCurrent open position of product.
Authorization required.See sample responseresponse = delta_client.get_position(product_id)NameTypeDescriptionRequiredproduct_idintegerid of producttrueChange Leverage PositionsChange leverage for open position by adding or removing margin to an open position.
Authorization required.See sample responseresponse = delta_client.change_position_margin(product_id, margin)NameTypeDescriptionRequiredproduct_idintegerid of producttruemarginstringnew margintrueGet Wallet BalancesGet user's balance.
Authorization required.See sample responseresponse = delta_client.get_balances(asset_id)NameTypeDescriptionRequiredasset_idintegerid of assettrueOrder Historyquery = { "product_id": 27 }
response = delta_client.order_history(query, page_size=100)
old_orders = response['result']
after_cursor_for_next_page = response["meta"]["after"]
more_orders = delta_client.order_history(query, page_size=100, after=after_cursor_for_next_page)NameTypeDescriptionRequiredpage_sizeintegerpage sizefalseFillsGet fill history of your ordersquery = { "contract_types": "futures,interest_rate_swaps" }
response = delta_client.fills(query, page_size=100)

fills = response['result']
after_cursor_for_next_page = response["meta"]["after"]
more_fills = delta_client.fills(query, page_size=100, after=after_cursor_for_next_page)NameTypeDescriptionRequiredpage_sizeintegerpage sizefalse