Ccxt: HitBTC market buy/sell order fails

Created on 12 Oct 2017  路  3Comments  路  Source: ccxt/ccxt

Hi,

here is my code:

import ccxt
hitbtc = ccxt.hitbtc({
    "apiKey": "key",
    "secret": "secret",
    "verbose": True,
})
print(hitbtc.create_market_sell_order('BTC/USD', 0.01))

ccxt fails...

PS Key & nonce is fine, I can pull balance data, for example.

Most helpful comment

@Fcl69 ok, but, please, be aware, that there's a little more to it:

  1. HitBTC has a timeInForce order parameter, that is a setting that controls the execution of the order (how HitBTC should treat and fill the order):
GTC (Good-Til-Canceled): the order will stay open or partially closed until filled or canceled by user
IOC (Immediate-Or-Cancel): the order will either fill immediately or will be canceled automatically
FOK (Fill-Or-Kill): the order will either be filled entirely or will expire
DAY (Day): the order will either be filled in 24 hours or will expire
GTD (Good Till Date):聽the order will expire on specific date
  1. The default execution type for limit orders in HitBTC and ccxt is GTC.

  2. For market orders HitBTC allows IOC or FOK only. The default in HitBTC and ccxt is FOK.
    If you need IOC execution, then you should pass that as an extra param with your order, like so:

hitbtc.create_market_sell_order('BTC/USD', 0.01) # default
hitbtc.create_market_sell_order('BTC/USD', 0.01, { 'timeInForce': 'FOK' }) # default
hitbtc.create_market_buy_order('BTC/USD', 0.01, { 'timeInForce': 'IOC' })

hitbtc.create_limit_sell_order('BTC/USD', 0.01) # default
hitbtc.create_limit_sell_order('BTC/USD', 0.01, { 'timeInForce': 'GTC' }) # default
hitbtc.create_limit_buy_order('BTC/USD', 0.01, { 'timeInForce': 'IOC' })

Let us know if you have any questions or difficulties left. Thx!

All 3 comments

Hi, @Fcl69!
I've uploaded a slightly edited version of it... can you please try it again and report? It should work now.
Cheers!

It did work! Thank you!

@Fcl69 ok, but, please, be aware, that there's a little more to it:

  1. HitBTC has a timeInForce order parameter, that is a setting that controls the execution of the order (how HitBTC should treat and fill the order):
GTC (Good-Til-Canceled): the order will stay open or partially closed until filled or canceled by user
IOC (Immediate-Or-Cancel): the order will either fill immediately or will be canceled automatically
FOK (Fill-Or-Kill): the order will either be filled entirely or will expire
DAY (Day): the order will either be filled in 24 hours or will expire
GTD (Good Till Date):聽the order will expire on specific date
  1. The default execution type for limit orders in HitBTC and ccxt is GTC.

  2. For market orders HitBTC allows IOC or FOK only. The default in HitBTC and ccxt is FOK.
    If you need IOC execution, then you should pass that as an extra param with your order, like so:

hitbtc.create_market_sell_order('BTC/USD', 0.01) # default
hitbtc.create_market_sell_order('BTC/USD', 0.01, { 'timeInForce': 'FOK' }) # default
hitbtc.create_market_buy_order('BTC/USD', 0.01, { 'timeInForce': 'IOC' })

hitbtc.create_limit_sell_order('BTC/USD', 0.01) # default
hitbtc.create_limit_sell_order('BTC/USD', 0.01, { 'timeInForce': 'GTC' }) # default
hitbtc.create_limit_buy_order('BTC/USD', 0.01, { 'timeInForce': 'IOC' })

Let us know if you have any questions or difficulties left. Thx!

Was this page helpful?
0 / 5 - 0 ratings