Training class on using Crypto APIs


Are there any training classes on what is expected to use the APIs?

I have background in programming - that is not an issue.

Although I have just started to learn how to trade, my TA skills have been progressing rather nicely.

The problem I am facing is with the mechanics of trade execution. I create a BUY with ~one of~ the STOP_LIMIT options and I get an error stating (and I am paraphrasing) “the order could not be created because it would execute immediately”

There is nothing to note how the calculation is made. Nothing that says WHY it will not open the order.

I have had issues with other types as well (ex: when my intention is to execute a “take profit” at a higher level, the “order” acts more like a “market order”, etc.)

Again, is there ANYTHING AT ALL out there that notes how this code is ~supposed~ to work? IMHO the messages are not clear.


@cadmufasa, I am unfamiliar with the API but familiar with trading jargon etc.

I see your question was unanswered, so figured I would offer a little input which you can maybe use to get yourself farther along. I may have misunderstood your question. If so, I apologize.

I believe your misunderstanding has to do with the intention of a buy_stop order.
One handy trick to remember this is “STOP” is used to stop losses, not gains. So, if you are long, a stop loss will be a sell order BELOW where the market is. If you are short, a buy stop, will be above where the market is. “stopping” the bleeding.

So, you are trying to enter a buy_stop order and your “stop” price is being entered below the market. If that is the case, then the system will think, “oh no,” the market has risen above his stop price and he wants to “stop” the losses so we need to buy immediately.

I’m hoping that is sufficiently helpful. If you get that, then the next piece of the puzzle is the “limit” this has to do with the concept of “limiting” the market’s insanity. You just told the system, to buy the asset at any price above my stop order (in the case of a buy stop, or to sell at any price below my stop order). Well what if it is weird market and gaps down/up. It would be nice to “limit” the price that the buy/sell order is able to execute at. So, to use your example, you may want to buy if BTC crosses above 9407 but you are not willing to pay a penny higher than 9410 for example. If the price goes immediately through 9410 and other’s orders were in front of you, you won’t buy until it drops back below 9410.

Your order had a limit price below the buy stop which is actually fine, but kind of unorthodox. One way I taught myself to remember it for the regulatory exams was that BSL was on an upward ascending escalator and SSL was on a descending escalator. By that I mean, Current price < Buy_Stop price < Buy_Stop_Limit Price. and vice versa, Current Price > Sell_stop_price < Sell_stop_limit price.

Again, I don’t think you had a coding problem, just regular old order misunderstanding. Hopefully this was helpful.

1 Like

Thanks Eric for this nice explanation. :slight_smile:

1 Like

Thanks this is a good explanation-

this maybe helpful to understanding the error. :slight_smile:

Thanks, I am understanding that the order would trigger immediately - but - I do not see how this can be the case.

Get the current price:

{‘status’: 0, ‘data’: [{‘bid’: 9426.79, ‘ask’: 9426.99, ‘spread’: 0.1999999999989086, ‘ibuy’: 9426.89, ‘isell’: 9426.69}], ‘count’: 1}

these are the values I have:
stop price price 9407.96 stop_price (INPUT) 9389.18 stop loss 9370.4 EXIT price (INPUT)9858.64 symbol BTC/USDT amount 0.0015

so, I am thinking it looks like this:

   PART 1:

   params  = { 'stopPrice': stop_price , 'timeInForce':'GTC'  }
   output  = createOrder(symbol, 'STOP_LOSS_LIMIT', amount=amount, side="buy", \
                    price=price, params=params)

   **** Price      = 9407.96
   **** Stop Price = 9389.18

   current price -----------------------> 9426.79

   price to execute buy ----------------> 9407.96

   stopPrice ---------------------------> 9389.18

   I thought the following was to happen in order for this to be valid.

   1.  The Price would have to retrace to "Stop Price"

   2.  The price would then reverse and then an actual BUY would take palce at 9407.96

   Since BOTH StopPrice and "price to execute to buy" are BELOW the current price, I do not get why
   I am getting the error:

   ccxt.base.errors.InvalidOrder: binance Order would trigger immediately.