Haehnchen / crypto-trading-bot

Cryptocurrency trading bot in javascript for Bitfinex, Bitmex, Binance, Bybit ... (public edition)
MIT License
3.1k stars 979 forks source link

coinbase_pro.js --> Stop Order Error #293

Open rooks88 opened 2 years ago

rooks88 commented 2 years ago

Hi there, I got this error msg: Coinbase Pro: order create error: ["HTTP 400 Error: Invalid order_type stop

As I read in the api doc, there ist no stop order in CB Pro. See: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postorders

Furthermore there are stop-loss and stop-entry flags, which are not included in the submittet order-post.

I'm wondering if the marked part in the coinbase_pro.js could easily be redirected to to another type....

let orderType; switch (ordType) { case 'limit': orderType = ExchangeOrder.TYPE_LIMIT; break; case 'stop': orderType = ExchangeOrder.TYPE_STOP; break; case 'market': orderType = ExchangeOrder.TYPE_MARKET; break; case 'stoplimit': orderType = ExchangeOrder.TYPE_STOP_LIMIT; break; default: orderType = ExchangeOrder.TYPE_UNKNOWN; break; }

... or if it's just necessary to cut out this marked part, as there are just no stop orders in CB Pro:

let orderType; const originOrderType = order.getType(); if (!originOrderType || originOrderType === 'limit') { orderType = 'limit'; } else if (originOrderType === 'stop') { orderType = 'stop'; } else if (originOrderType === 'market') { orderType = 'market'; }

But on the other hand, there is a reason for the bot to choose the stop-order-type. If there are no stop-orders, the possibility of choosing stop-orders should be deleted from the choosing-type-process in the code, as simple manipulation as mentioned above would lead to a possible WIN or LOSS which would be connected to the chosen stop-order afterwards.

I am not quite sure how to handle this, maybe I am mistaking my problem from the very beginning.

I'm appreaciating any answer. Thanks!

Cheerio

Robin

rooks88 commented 2 years ago

As I read further through the web I'm gettin the impression the coinbase Pro stop order is simply different in syntax:

authenticatedClient.sell( { type: "limit", product_id: "BTC-USD", size: "0.005", price: "10100", // the limit price stop: "entry", // currently undocumented stop_price: "10000", // currently undocumented });

I found this example which indicates the type is staying "limit", but there is a choice of "stop-types" entry/loss and a stop_price which needs to be passed to fulfill the order requierements. Any ideas about that?

Thanks & cheers!