-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
okex cancel order url not correct #336
Comments
Hi, @86chenjie ! Are you sure about that? I mean: |
Oh, I see... that is the future/spot conflict. Got it, will fix now! |
Ok, this is fixed as v.1.9.174+. Please update and try it again. We will be happy if you report back, as always. Also, note that I made the second (symbol) param mandatory for OK*, so now you can use a shorter form of it: result = await ex.cancelOrder(result.id, ccxtSymbol) // just pass the symbol directly Thx again for your help! |
@kroitor works. thanks |
@kroitor btw https://www.okex.com/rest_api.html let result = await ex.privatePostBatchTrade({
symbol: ccxtSymbol,
orders_data: `[{price:${g.depth.bidPrice * 0.98},amount:${amount},type:'buy'},{price:${g.depth.askPrice * 1.02},amount:${amount},type:'sell'}]`
})
how to use this api? |
@86chenjie try adding let result = await ex.privatePostBatchTrade({
symbol: ccxtSymbol,
orders_data: ex.json ([{price:${g.depth.bidPrice * 0.98},amount:${amount},type:'buy'},{price:${g.depth.askPrice * 1.02},amount:${amount},type:'sell'}]),
}) Let me know if it helps or not. Really appreciate your feedback! ) P.S. For readability, paste code and verbose output in text enclosed with 3 backticks (```) for all text information, like so: ```JavaScript // ← this line adds js syntax color highlighting for readability ``` |
@kroitor are you sure? [{price:3,amount:5,type:'sell'},{price:3,amount:3,type:'buy'}] |
@86chenjie yes, in the same docs they say that it should be a JSON string (means JSON-encoded, though, I agree, they are not very clear in their docs). |
So, yes, I'm sure, you can add the |
not work |
@86chenjie ok, i'll debug it more and will get back to you as soon as possible with a solution to that. |
thanks 👍 |
I think I see where the problem is... Can you try this: // version 1
let result = await ex.privatePostBatchTrade({
symbol: ex.marketId (ccxtSymbol), // ← custom API needs manual conversion symbol → market id
orders_data: '[{price:${g.depth.bidPrice * 0.98},amount:${amount},type:'buy'},{price:${g.depth.askPrice * 1.02},amount:${amount},type:'sell'}]',
}) If it doesn't help, please try it the second time with // version 2
let result = await ex.privatePostBatchTrade({
symbol: ex.marketId (ccxtSymbol), // ← custom API needs manual conversion symbol → market id
orders_data: ex.json([
{price:${g.depth.bidPrice * 0.98},amount:${amount},type:'buy'},
{price:${g.depth.askPrice * 1.02},amount:${amount},type:'sell'}
]),
}) We would be happy if you actually try both versions anyway... If that doesn't help either, I'll debug it further... |
let result = await ex.privatePostBatchTrade({
// symbol: ccxtSymbol,
symbol: ex.marketId (ccxtSymbol),
orders_data: `[{price:${g.depth.bidPrice * 0.98},amount:${amount},type:'buy'},{price:${g.depth.askPrice * 1.02},amount:${amount},type:'sell'}]`
// orders_data: ex.json(obj)
}) var obj = [
{
price: g.depth.bidPrice * 0.98,
amount: amount
},
{
price: g.depth.askPrice * 1.02,
amount: amount
}
]
let result = await ex.privatePostBatchTrade({
// symbol: ccxtSymbol,
symbol: ex.marketId (ccxtSymbol),
// orders_data: `[{price:${g.depth.bidPrice * 0.98},amount:${amount},type:'buy'},{price:${g.depth.askPrice * 1.02},amount:${amount},type:'sell'}]`
orders_data: ex.json(obj)
}) both not work |
@86chenjie can you show the verbose output of the version 1 once again? |
Nope, never mind, verbose output not needed. |
|
@86chenjie ok, looks like I found the problem now... Can you please update ccxt to 1.9.177+ and retry code snippet version 1 once more? Sorry for bothering you with this. Looks like OKEX doesn't like urlencoded-strings... But it should work now. If it doesn't, I'll go on with fixing this nasty bug... |
@kroitor version 1 code works. 👍 |
@86chenjie ok, please let me know if you experience any other difficulties with it. Thx a lot for your collaboration! |
@kroitor i have a question not related to ccxt: i'm curious about how this 'side' is determined. |
@86chenjie hi! Are you familiar with the concept of "maker and taker" ? You're absolutely right, for each trade there should be 1 buy order and 1 sell order, and those 2 orders should match each other. But when 2 orders are matched only one trade is created for each matched pair of orders. It goes like this: let's say, we put an order for buying and that order does not match any other order in the orderbook to be closed or "filled" immediately. The created order is placed into the orderbook then, and that order is hanging there until someone decides to create an opposite matching order. That "waiting" order is called a "market-maker" order, because it "makes" or "builds" the market by adding the volume of your offer (order) to the orderbook → you kinda "provide" liquidity to the market by placing an order that will be hanging there. The market accumulates more "ordered" volume overall, so each of our hanging orders are "market-making" orders. When you are market-making, you add to the total market liquidity. But the "trade" (or "a fill") is created when someone creates a second matching order. Let's say another person places an order to sell the same volume as we were buying previously. The matching engine of the exchange can see both matching orders and the second order is considered to be a "market-taker" order. The second order closes or "fills" the first one and both of them are removed from the orderbook when the trade is created. So, the second order is taking the liquidity away from the orderbook, leaving less offered volume there. This is why it's called "a taker". Now, because the trade is created when the second order is placed, the side of the trade is the side of that second order that does the fill, that is the taker in the example above. So, if we placed a buying market-maker order, the side of the trade will be side of the second market-taker sell order, or just "sell". In other words, the side of each trade is the taker side. Moreover, each maker order can be filled with one or more taker orders, effectively producing a row of taker-sell trades, which have the "sell" side. Most of exchange engines will consider that a "sell" trade, but there may be wild matching engines out there, which do it another way. The buy is equivalent, but opposite – someone should be maker-selling, and some other one should be taker-buying. And the trades are on the "buy" side then. I hope it answers your question. |
P.S. Market-maker trading fees are usually much lower than market-taker fees. So it's more profitable to be a maker. Some exchanges don't even take a fee from the maker. And some low-volatile exchanges are even ready to pay you a rebate or "a reward" for market-making. You get some part of the fee added to your balance when you are a maker (they pay you for providing the liquidity). |
@kroitor thanks for your detailed explanation. totally make sense. 👍 |
result = await ex.cancelOrder(result.id, null, {symbol: ccxtSymbol})
2017-10-18 15:07:44.513: okex POST https://www.okex.com/api/v1/future_cancel.do
4|crypto-m | Request:
4|crypto-m | { 'User-Agent': 'ccxt/1.9.149 (+https://github.com/ccxt-dev/ccxt) Node.js/8.6.0 (JavaScript)',
4|crypto-m | 'Content-Type': 'application/x-www-form-urlencoded' } api_key=aa8740d4-fb38-4ca3-a1fc-2c7a3daca79c&order_id=24532896&symbol=LTC%2FBTC&sign=C0C5CB42ADE5501CB37DFF47DD254B6F
should send to URL https://www.okex.com/api/v1/cancel_order.do
The text was updated successfully, but these errors were encountered: