Skip to content
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

Kraken: Support for createMarketOrderWithCost using "viqc" flag #22521

Closed
1 task done
mjwvb opened this issue May 16, 2024 · 18 comments
Closed
1 task done

Kraken: Support for createMarketOrderWithCost using "viqc" flag #22521

mjwvb opened this issue May 16, 2024 · 18 comments
Assignees

Comments

@mjwvb
Copy link

mjwvb commented May 16, 2024

Preliminary Checks

  • I have already searched for existing issues and confirmed that this issue is not a duplicate

Is your feature request related to a problem? Please describe

In CCXT there's currently no support for createMarketOrderWithCost for Kraken, although there's support for it in the Kraken API.

Describe the solution you'd like

According to the API docs there seems to be support for a "olflag" named "viqc": "order volume expressed in quote currency. This is supported only for market orders."

See the api docs for addOrder: https://docs.kraken.com/rest/#tag/Spot-Trading/operation/addOrder

I could be wrong, but it sounds like that's what we need to implement market orders with cost / quote size, so we could implement the following functions:

createMarketOrderWithCost() / createMarketBuyOrderWithCost / createMarketSellOrderWithCost

Describe alternatives you've considered

No response

@carlosmiei carlosmiei self-assigned this May 16, 2024
@carlosmiei
Copy link
Collaborator

Hello @mjwvb, thanks for bringing our attention to this; we will implement it as soon as possible!

@carlosmiei
Copy link
Collaborator

@mjwvb Actually I'm testing it and this is only supported for market-buy orders

} 
RequestBody:
 nonce=1715879486467&pair=LTCUSDT&type=sell&ordertype=market&volume=10&oflags=viqc 

handleRestResponse:
 kraken POST https://api.kraken.com/0/private/AddOrder 200 OK 
ResponseHeaders:

ResponseBody:
 {"error":["EGeneral:Invalid arguments:viqc"]} 

with market sell, throws this error

@carlosmiei
Copy link
Collaborator

hum, market buy also throws an error 🤔

RequestBody:
 nonce=1715880275284&pair=LTCUSDT&type=buy&ordertype=market&volume=5&oflags=viqc 

handleRestResponse:
 kraken POST https://api.kraken.com/0/private/AddOrder 200 OK 

ResponseBody:
 {"error":["EGeneral:Invalid arguments:volume"]} 

@carlosmiei
Copy link
Collaborator

@mjwvb apparently only works with USD markets and not USDT 🤔

RequestBody:
 nonce=1715880738343&pair=XLTCZUSD&type=buy&ordertype=market&volume=5&oflags=viqc 

handleRestResponse:
 kraken POST https://api.kraken.com/0/private/AddOrder 200 OK 
ResponseHeaders:

ResponseBody:
 {"error":[],"result":{"txid":["OCSKHT-X2QO7-T4WV3L"],"descr":{"order":"buy 5.00000000 LTCUSD @ market"}}} 

@mjwvb
Copy link
Author

mjwvb commented May 16, 2024

@carlosmiei That's very unfortunate. Apparently there's also another version of the docs which says:
viqc: order volume expressed in quote currency. This option is supported only for buy market orders. Also not available on margin orders. See:
https://docs.kraken.com/api/docs/rest-api/add-order

Interesting how there's two types of api docs?
https://docs.kraken.com/rest/#tag/Spot-Trading/operation/addOrder

It seems that /api/ is officially linked, and that /rest/ can only be found on google. Oh well...

Still weird how it not works for the USDT pair though... Anyway thanks for checking and putting in all the effort! I should have checked the API a bit more, but was a little bit on a rush. So sorry for that :)

@carlosmiei
Copy link
Collaborator

@mjwvb Yeah the docs and the API are very confusing in this regard. Nonetheless, we will implement the createMarketBuyOrderWithCost for the USD market pairs (also very strange not supporting USDT markets)

@mjwvb
Copy link
Author

mjwvb commented May 16, 2024

@carlosmiei Alright! According to the docs you should also exclude margin orders, but cannot confirm right now.

Also now that you're into the oflags, I saw in the code that when using postOnly on limit orders, the oflags params is always forced set to "post" instead of appending any existing oflags. It means you cannot provide your own oflags in combination with the native postOnly. See:

request['oflags'] = 'post';

@carlosmiei
Copy link
Collaborator

@mjwvb Yes you're right, I will update it to take that into consideration.

@mjwvb
Copy link
Author

mjwvb commented May 17, 2024

Thanks! I'll be testing it out in the near future.

By the way, I think USDT markets actually are supported but the minimum order size of LTC/USDT is 10 USDT, and you provided 5 USDT. At least that's what the kraken UI is telling me: "Cannot be smaller than 10 USDT"

@carlosmiei
Copy link
Collaborator

@mjwvb omg you're right 😅, that was the problem, thanks once again! will be updated shortly

 nonce=1715951571837&pair=LTCUSDT&type=buy&ordertype=market&volume=10&oflags=viqc 

handleRestResponse:
 kraken POST https://api.kraken.com/0/private/AddOrder 200 OK 

ResponseBody:
 {"error":[],"result":{"txid":["OVKIAP-DEGPW-MMZK4F"],"descr":{"order":"buy 10.00000000 LTCUSDT @ market"}}} 

@mjwvb
Copy link
Author

mjwvb commented May 17, 2024

@carlosmiei haha, Kraken has ridiculous minimum sizes though...

@carlosmiei
Copy link
Collaborator

@mjwvb we just released a new version with the fixes, can you please update your ccxt version and try again?

@carlosmiei
Copy link
Collaborator

@mjwvb turns out we have a small issue with the pipeline so we didn't release yet

@mjwvb
Copy link
Author

mjwvb commented May 18, 2024

Am I right the release is still pending? Npm can't find 4.3.26

@carlosmiei
Copy link
Collaborator

@mjwvb Yes the pipeline is not stable yet, unfortunately, but we're trying to fix it right now

@carlosmiei
Copy link
Collaborator

@mjwvb We just released a nee version, 4.3.27, please let us know if anything

@mjwvb
Copy link
Author

mjwvb commented May 18, 2024

@carlosmiei using 4.3.27 now and it seems to be working perfectly. Thank you once again!

@carlosmiei
Copy link
Collaborator

@mjwvb No problem!
Will close this issue, let us know if anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants