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

The C# API connector return an error #184

Closed
itriad opened this issue Jul 24, 2018 · 9 comments
Closed

The C# API connector return an error #184

itriad opened this issue Jul 24, 2018 · 9 comments

Comments

@itriad
Copy link

itriad commented Jul 24, 2018

Hello,
The C# API connector have an issue:
{"error":{"message":"Nonce must be a valid number and below 2^53. You sent: 9012932817249180.","name":"HTTPError"}}

I already change my API key and no Typo

Thanks for any help

@itriad itriad closed this as completed Jul 24, 2018
@itriad
Copy link
Author

itriad commented Jul 24, 2018

The method GetNonce() have an issue (maybe)
private long GetNonce() { DateTime yearBegin = new DateTime(1990, 1, 1); return DateTime.UtcNow.Ticks - yearBegin.Ticks; }

@itriad itriad reopened this Jul 24, 2018
@itriad
Copy link
Author

itriad commented Jul 24, 2018

if someone from bitmex can update this OFFICIAL api connector

@DotNetFiver
Copy link

I'm having the same problem, just downloaded latest version too

@DotNetFiver
Copy link

This worked for me:

        DateTime yearBegin = new DateTime(1970, 1, 1);
        long nowticks = DateTime.UtcNow.Ticks + 60000;
        long dawnoftimeticks= yearBegin.Ticks;
        long non = (nowticks - dawnoftimeticks)/10000;
        return non;

Although I only just started with my Bitrex account but when I run the swample code to retrieve orders I get [] which is better than the error I did get :-)

@DotNetFiver
Copy link

  • Bitmex... oops

@itriad
Copy link
Author

itriad commented Jul 25, 2018

this work also thanks:

@itriad
Copy link
Author

itriad commented Jul 25, 2018

`
private long GetUnixTimeStamp()
{
long timestamp = (long)((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds);

        return (timestamp);
    }

then
if (auth)
{
// string nonce = GetNonce().ToString();
string expires = (GetUnixTimeStamp() + 60).ToString();

            //string message = method + url + nonce + postData;

            string message = method + url + expires + postData;


            byte[] signatureBytes = hmacsha256(Encoding.UTF8.GetBytes(apiSecret), Encoding.UTF8.GetBytes(message));
            string signatureString = ByteArrayToString(signatureBytes);

            // webRequest.Headers.Add("api-nonce", nonce);
            webRequest.Headers.Add("api-expires", expires);
            webRequest.Headers.Add("api-key", apiKey);
            webRequest.Headers.Add("api-signature", signatureString);
        }

`

@ryanfox
Copy link
Contributor

ryanfox commented Jul 25, 2018

This should be fixed in master.

LTangaF pushed a commit to LTangaF/api-connectors that referenced this issue Dec 5, 2018
@Juxanli
Copy link

Juxanli commented Dec 22, 2018

Newtonsoft.Json.JsonSerializationException: "Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[BitMEX.Position]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.

Path 'error', line 1, position 9."

public List GetOpenPositions(string symbol)
{
var param = new Dictionary<string, string>();
string res = Query("GET", "/position", param, true);
return JsonConvert.DeserializeObject<List>(res).Where(a => a.Symbol == symbol && a.IsOpen == true).OrderByDescending(a => a.TimeStamp).ToList();
}

pls help me

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

4 participants