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

Invalid Arguments when placing an order #3

Closed
cr0wburn opened this issue Sep 28, 2019 · 14 comments
Closed

Invalid Arguments when placing an order #3

cr0wburn opened this issue Sep 28, 2019 · 14 comments

Comments

@cr0wburn
Copy link

When i'm placing an order using this function:


       static void CreateOrder_SellBTC(decimal sellprice, decimal btc_sellamount)
        {
            KrakenClientOptions APIoptions = new KrakenClientOptions();
            APIoptions.ApiCredentials = new ApiCredentials(ticker_timer.krakenKey, ticker_timer.krakenSecret);
            KrakenClient ApiClient = new KrakenClient(APIoptions);

            string market = "XXBTZEUR";
            var sell = Kraken.Net.Objects.OrderSide.Sell;
            var ordertype = Kraken.Net.Objects.OrderType.Limit;
            uint? orderID = null;
            decimal? secondary_price = null;
            decimal? leverage = null;
            DateTime? start_time = null;
            DateTime? expire_time = null;
            bool? validate_only = null; 

            var placeorder = ApiClient.PlaceOrder(market, sell, ordertype, btc_sellamount, orderID, sellprice, secondary_price, leverage, start_time, expire_time, validate_only);
        }

I'm getting

{3: Server error: EGeneral:Invalid arguments:type}

as an error.

I'm not sure what to change, i'm not sure if it's a bug or i'm in the wrong.

Thanks in advance, and loving your API wrapper.

@cr0wburn
Copy link
Author

I think this error is because Starttime and expire time are DateTimes, but kraken actually handles UnixTicks only. Which is a 'long' variable:

To convert:
DateTime foo = DateTime.UtcNow;
long unixTime = ((DateTimeOffset)foo).ToUnixTimeSeconds();

Could you see if this is the problem with ordering ?

@JKorf
Copy link
Owner

JKorf commented Oct 14, 2019

Hi, sorry for the delay. I'm not sure what the issue is, can you try turning on Debug logging?
(APIoptions.LogVerbosity = LogVerbosity.Debug)

The start/expire time are converted to seconds in the implementation, so that's not the problem.

@JKorf JKorf mentioned this issue Oct 14, 2019
@cr0wburn
Copy link
Author

The response after setting verbose debug is:

2019/10/14 21:17:28:767 | Debug | Creating request for https://api.kraken.com/0/private/AddOrder
2019/10/14 21:17:28:880 | Debug | Sending POST signed request to https://api.kraken.com/0/private/AddOrder with request body nonce=637066774487699293&pair=XXBTZEUR&type="sell"&ordertype="limit"&volume=0,11&price=20000&validate=False
2019/10/14 21:17:29:087 | Debug | Data returned: {"error":["EGeneral:Invalid arguments:type"]}
2019/10/14 21:17:29:087 | Warning | Local object has property `Result` but was not found in received object of type `KrakenResult`1`
2019/10/14 21:17:29:103 | Debug | Returned data: {
  "error": [
    "EGeneral:Invalid arguments:type"
  ]
}

@JKorf
Copy link
Owner

JKorf commented Oct 15, 2019

Hi, thanks for the info. I've found the issue, extra quotes we're added during serialization. I've fixed it in version 0.0.4, should be available in a few minutes.

@cr0wburn
Copy link
Author

I'll check it out.
Thanks for being awesome!

@cr0wburn
Copy link
Author

There is a new error:

2019/10/15 17:26:10:684 | Debug | Creating request for https://api.kraken.com/0/private/AddOrder
2019/10/15 17:26:10:781 | Debug | Sending POST signed request to https://api.kraken.com/0/private/AddOrder with request body nonce=637067499706853397&pair=XXBTZEUR&type=sell&ordertype=limit&volume=0,11&price=20000&validate=False
2019/10/15 17:26:10:988 | Debug | Data returned: {"error":["EGeneral:Invalid arguments:volume"]}
2019/10/15 17:26:10:995 | Warning | Local object has property `Result` but was not found in received object of type `KrakenResult`1`
2019/10/15 17:26:10:999 | Debug | Returned data: {
  "error": [
    "EGeneral:Invalid arguments:volume"
  ]
}

I think it's because the decimal point is translated into a comma.
The ordervolume is 0.11 and in the serialization i see 0,11

cheers

@JKorf
Copy link
Owner

JKorf commented Oct 23, 2019

Hi, sorry it took a little while, was busy with new releases. I've pushed version 1.0.0 for Kraken, it should resolve your issues.
(Also tested with decimal numbers this time where previously I tested with whole ints so I didn't see this issue..)

@cr0wburn
Copy link
Author

Thanks for fixing it :)

@cr0wburn
Copy link
Author

cr0wburn commented Oct 23, 2019

It still does not look right, but it's getting there
When setting validate only to false, you still get only a validate back.
This is the log:

2019/10/23 20:55:23:190 | Debug | Client configuration: LogVerbosity: Debug, Writers: 1, Credentials: Set, BaseAddress: https://api.kraken.com, Proxy: -, RateLimiters: 0, RateLimitBehaviour: Wait, RequestTimeout: 00:00:30
2019/10/23 20:55:23:216 | Debug | Creating request for https://api.kraken.com/0/private/AddOrder
2019/10/23 20:55:23:225 | Debug | Sending POST signed request to https://api.kraken.com/0/private/AddOrder with request body nonce=637174536232174782&pair=XXBTZEUR&type=sell&ordertype=limit&volume=0.01&price=18000&validate=False

I do not create an order at Kraken, and no OrderID is returned. So i think it's a "dummy" order.

Note that Success is set to true, and ResponceStatusCode is OK.

@JKorf
Copy link
Owner

JKorf commented Oct 23, 2019

Hm when validate isn't specified it should work though right? Seems when validate=False is send it still counts as a test order, but if you omit it it posts a real order.

@cr0wburn
Copy link
Author

When i set validate to null then i see:

2019/10/23 21:57:50:588 | Debug | Client configuration: LogVerbosity: Debug, Writers: 1, Credentials: Set, BaseAddress: https://api.kraken.com, Proxy: -, RateLimiters: 0, RateLimitBehaviour: Wait, RequestTimeout: 00:00:30
2019/10/23 21:57:50:618 | Debug | Creating request for https://api.kraken.com/0/private/AddOrder
2019/10/23 21:57:50:632 | Debug | Sending POST signed request to https://api.kraken.com/0/private/AddOrder with request body nonce=637074574706198389&pair=XXBTZEUR&type=sell&ordertype=limit&volume=0.01&price=18000

And the respsonse is:

"Server error: EAPI:Invalid nonce"
  Success  false 
  ResponseStatusCode | OK | System.Net.HttpStatusCode?

So that doesn't look good

@JKorf
Copy link
Owner

JKorf commented Oct 23, 2019

Invalid nonce, thats odd. The nonce should be an ever increasing number. Kraken.Net uses the current time as reference so it's always higher than the last. Have you maybe once send a higher nonce using your own code or another library maybe? If you've send a higher nonce before, the lower once generated from Kraken.Net won't work anymore.

@cr0wburn
Copy link
Author

cr0wburn commented Nov 1, 2019

I didn't have time earlier to check out if it works.
But after installing the latest version, ordering works fine!
Thanks for the work.

Also did you know, that Kraken.com now supports websocket for ordering ?
anyway, cheers.

@JKorf
Copy link
Owner

JKorf commented Nov 1, 2019

Great
Yeh, I got an email about that, will implement that soon as well :)

@JKorf JKorf closed this as completed Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants