Git Product home page Git Product logo

binance.api.csharp.client's Introduction

Jose's GitHub stats

binance.api.csharp.client's People

Contributors

ebirito avatar hero3616 avatar morpheums avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binance.api.csharp.client's Issues

ambiguous between the following methods or properties

When i am trying to run this project, I am getting this error for all 3 bold functions. Any help please ?

For this file: BinanceClient.cs

For this line of code:

var args = $"symbol={symbol.ToUpper()}&interval={interval.GetDescription()}"
+ (startTime.HasValue ? $"&startTime={startTime.Value.GetUnixTimeStamp()}" : "")
+ (endTime.HasValue ? $"&endTime={endTime.Value.GetUnixTimeStamp()}" : "")
+ $"&limit={limit}";

Severity Code Description Project File Line Suppression State
Error CS0121 The call is ambiguous between the following methods or properties: 'Binance.API.Csharp.Client.Utils.ExtensionMethods.GetDescription(System.Enum)' and 'Binance.API.Csharp.Client.Utils.ExtensionMethods.GetDescription(System.Enum)' Binance.API.Csharp.Client C:\app\Bin\Binance.API.Csharp.Client-master\Binance.API.Csharp.Client\BinanceClient.cs 174 Active

PostNewOrder with OrderType.LIMIT return 400 error

Hi,
Did you test if EndPoints.NewOrder is working?
As long as I am using EndPoints.NewOrderTest, i can make a new place order, but after switch back real new order endpoint "/api/v3/order" i am keep getting 400 error,

Detail error message: One or more errors occurred. (Response status code does not indicate success: 400 (Bad Request).)

Request looks like:
/api/v3/order?symbol=EOSETH&side=BUY&type=LIMIT&quantity=1&timeInForce=GTC&price=100&recvWindow=5000&timestamp=1515267623189&signature=DE632680056FFDD09DAD6CA87544C485865BE10526A2089F66581E1FDF34C084

Api doesnt seem to work in forms app for me

I have tried using the api in console application. Everything worked fine. However, when I tried using any of the methods in winforms app, by calling the method on button.onclick, the form freezes and is unresponsive.
I am using my api and secret but of course I am not posting them here.

`using Binance.API.Csharp.Client;
using Binance.API.Csharp.Client.Models.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace binappp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ApiClient apiClient = new ApiClient("api", "secret");
            BinanceClient binanceClient = new BinanceClient(apiClient);
            binanceClient.PostNewOrder("btciota", (decimal)1, (decimal)0.0000008, OrderSide.BUY, OrderType.MARKET);
        }
    }
}

`

Console application crashes on client.GetAccountInformation(3500)

Hi all,
I'm new to C# and I'm trying to understand how to use this library for my own purpose. I've managed to acquire pairs prices for several hours and I've wrote them to a file and other things.

I'm having problems with the following line:

accountInformation = await client.GetAccountInformation(3500);

My console application, let say a simplified version of the example in the package, crashes.

However seems that the connection works fine, and the line:

await client.TestConnectivity();

doesn't give any problems.

Any ideas?

Issue with placing market orders

Placing market orders was working fine until yesterday. I use the following standard command:

var sellMarketOrder = binanceClient.PostNewOrder("xxxbtc", 1000, 0, OrderSide.SELL, OrderType.MARKET).Result;

However, this has now suddenly stopped working and throwing an exception: "one or more errors occurred".

I wonder if Jose or anyone can throw any light as to why this wrapper has stopped functioning as expected. Other aspects of the API seem to be operational (var tickerPrices = binanceClient.GetAllPrices().Result), but market BUY and SELL have stopped.

I wonder if there's been any change on the Binance end, which maybe having an impact and this change has not been reflected in the wrapper.

Then again, if that was the case, I'd imagine we'd be seeing a lot more complaints here.

400 Bad Request

Hello Everyone,

I have am receiving a 400 "bad request" regardless what I do.
I can see that the code goes thru from my class all the way to ApiClient.cs and the request is being built correctly from what I can tell:

Did try the original www.binance.com same thing..
{https://api.binance.com/api/v3/account?recvWindow=5000&timestamp=1521743921941&signature=C9D3A45A7FD741308621F23753F13141BD5721C581EDEFBBDC0AE2D4979AACDA}

nonetheless I get a 400 error.

Can you please let me know what am I doing wrong?

This is the code I have used in my own class

    static string youtrapikey = "My key";  
    static string YourApiSecret = "My Secret";  

    private static ApiClient apiClient = new ApiClient(youtrapikey, YourApiSecret);
    private static BinanceClient binanceClient = new BinanceClient(apiClient, false);

    private void cmd_run_Click(object sender, EventArgs e)
    {       
           var accountInfo = binanceClient.GetAccountInfo().Result;
}

Thank you,

websocket chartdata listening is stopping after a while!!

hi im trying to listen chartdata prices for specific pair with the function below but after some time later for example 1 day, new prices is not coming out. the function doenst give any exception or error it just stops working or maybe its still working but new prices is not coming anymore.(maybe server blocks my ip) do you know what may be the problem or do you have nay solution ? thank you. i wanna listen prices forever.

` private void KlineHandler(KlineMessage messageData)
{
var klineData = messageData;
}

public void TestKlineEndpoint()
{
    binanceClient.ListenKlineEndpoint("ethbtc", TimeInterval.Minutes_1, KlineHandler);
}

`

Error posting new limit order on decimal price

Hi!,

Is there a bug in the ammount of decimal places one can place in the price of a limit order?

If I put a price like the following it works fine (Price= 0.1):

image

But if I post a price like 0.01 it throws an error (error number 404).

image

Thanks!

Timestamp for this request was 1000ms ahead of the server's time

I used the API for a while and it worked perfectly. I didn't change anything over night, but the next day I had this error:

Exception thrown: 'System.Exception' in System.Private.CoreLib.dll ("Api Error Code: -1021 Message: Timestamp for this request was 1000ms ahead of the server's time.") Exception thrown: 'System.Exception' in System.Private.CoreLib.dll ("Api Error Code: -1021 Message: Timestamp for this request was 1000ms ahead of the server's time.")

It looks like it's a problem within the API. Is anyone else having this too right now? Might Binance be offline or something like that?

Timestamp for this request was 1000ms ahead of the server's time.

I sent a request to get account info using the following code:

    public async Task<string> BalanceRequest(string apikey, string apisecret, string exchange)
    {

        var apiClient = new ApiClient(apikey, apisecret);
        var binanceClient = new BinanceClient(apiClient);
        var binance = await binanceClient.GetAccountInfo();   <-- line 29         
        return binance.Balances.Count().ToString();
    }

And i am getting exception:
Api Error Code: -1021 Message: Timestamp for this request was 1000ms ahead of the server's time.

Stop-Limit Orders?

Is there any way to do Stop-Limit orders using this API (as I didn't see any), and if not, are there any plans for this to be added?

Trading rules URL is returning 404

Need to validate an order before posting the order.
However, the trading rules json is not available as endpoint shared is returning 404.

Show the results

Hello, I am starting with API. A simple question, but not for me :)
For the exemple:

var serverTime = binanceClient.GetServerTime().Result;

How I can see in console the result of this request?

Thank you.

Erro 1013

Message: Filter failure: LOT_SIZE
what this message means?
i verified the minimum of that symbol to post the value.

Order OCO

I would like to use OCO orders.

I tried to implement but it didn't work.

If anyone succeeds it would be really cool.

404 not found

var apiClient = new ApiClient("API-Key", "API-Secret");
var binanceClient = new BinanceClient(apiClient); <------

I get the following error on the second line.

HttpRequestException: Response status code does not indicate success: 404 (Not Found).

Place Market Order Issue

Place Market order functionality always break out and throw an exception "at least 1 error occurred".
any help please

Exchange Info

How to get the exchange info ? ie rate limit info?

Hangs at the Method Call

Hello,

I followed all the instructions and reached the point to use the methods and it doesn't seem to return anything rather gets stuck at the method call statement. Can you please advice on what is missing?

Example: It is stuck here...
var candlestick = binanceClient.GetCandleSticks("ethbtc", TimeInterval.Minutes_15).Result;

after run code page go to loop

Hi to all
We installed this package.
After run code page go to loop.

    var apiClient = new ApiClient("qnQ1Y*****", "w7Fo******");
    var binanceClient = new BinanceClient(apiClient);
    var accountInfo = binanceClient.GetAccountInfo().Result;
    Response.Write(accountInfo.BuyerCommission);

No result no response.
Help please

Example

Methods are simple to understand and use by themselves, but to stick them together might be a challenge for someone as shit at coding as I am. Would you mind providing simple one page file of console app, just calling most common methods, just to show the way how do cycle them without using some bullshit like 'while(true)'. Something like Marfusios'es example for his websocket connection to Bitfinex would be greatly appreciated.

WebSocket doesn't appear to connect

Nice work! I've been able to connect end-to-end and am able to use this nicely written library.

However, I seem to be having issues with the ConnectToWebSocket() -- I don't get any messages events in

binanceClient.ListenDepthEndpoint("CNDETH", DepthMessageHandler);
and
binanceClient.ListenKlineEndpoint("CNDETH", Binance.API.Csharp.Client.Models.Enums.TimeInterval.Minutes_1, KlineHandler);

In ApiClient.cs, ConnectToWebSocket() method seems to call ws.Connect(); ok, but no messages are coming in -- seems to be just dead air. (OnError and OnClose callbacks are never fired)

As a test, I added an OnOpen() and it does get called when ws.Connect(); is executed in ApiClient.cs
ws.OnOpen+= (sender, e) => { Console.Write("Opened!"); };

Are the listener methods broken or am I not calling it correctly?
Below is my sample console app Main() code: Keys/Private not shown, just the body:

do
    {
      while (!Console.KeyAvailable)
        {
         if (!started)
           {
               Console.Write("listening...");
                 started = true;
                 //binanceClient.ListenDepthEndpoint("CNDETH", depthMessageHandler);
                 // binanceClient.ListenKlineEndpoint("CNDETH", Binance.API.Csharp.Client.Models.Enums.TimeInterval.Minutes_1, KlineHandler);
                    }
                    // Thread.Sleep(2000);
                }
            } while (Console.ReadKey(true).Key != ConsoleKey.Escape);

Handlers

private static void KlineHandler(KlineMessage messageData)
{
       Console.Write("Got KLINE Message!");
        Console.Write($"High: {messageData.KlineInfo.High} Low: {messageData.KlineInfo.Low}");
}

 private static void DepthMessageHandler(DepthMessage messageData)
  {
       Console.Write("Got Message!");
        if (messageData.UpdateId >= DepthMessages.UpdateId)
        {
           DepthMessages = messageData;
         }
        foreach(var m in DepthMessages.Bids)
         {
             Console.Write($"{m.Price}:{m.Quantity}");
         }
 }

Any suggestions?

Why there's no error list here?

I'm getting this:

System.AggregateException was unhandled
  HResult=-2146233088
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
       at System.Threading.Tasks.Task`1.get_Result()
       at Binance.API.Csharp.Client.BinanceClient.LoadTradingRules()
       at Binance.API.Csharp.Client.BinanceClient..ctor(IApiClient apiClient, Boolean loadTradingRules)
       at ... .Program.StartUp() in c:\...\Program.cs:line 95
       at ... .Program.Main(String[] args) in c:\...\Program.cs:line 36
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2146233088
       Message=Api Error Code: 0 Message: 
       Source=Binance.API.Csharp.Client
       StackTrace:
            at Binance.API.Csharp.Client.ApiClient.<CallAsync>d__1`1.MoveNext()
       InnerException: 

At
var binanceClient =new BinanceClient(apiClient,true);

GetParsedCandlestick decimal problem

This method returns candle values but decimal values. For example "xrpbtc" daily candle closing value returning "6948" but real value "0.00006948" and "ethbtc" returning "3172" but real value "0.03171153".
Do you have any solution? Should i download code and edit this part for using myself?

Newtonsoft.Json.JsonReaderException: JSON integer too large for Int32

Hi There,

Trying to place LIMIT order and getting this exception:

Newtonsoft.Json.JsonReaderException: 'JSON integer 2284305452 is too large or small for an Int32. Path 'orderId', line 1, position 40.'

after running this line:

var buyLimitOrder = await binanceClient.PostNewOrder("BTCUSDT", 0.01m, 8000m, Binance.API.Csharp.Client.Models.Enums.OrderSide.BUY, Binance.API.Csharp.Client.Models.Enums.OrderType.LIMIT);

I am not sure but should the orderId parameter be LONG rather than Int? This error makes trading BTCUSDT pair impossible. Other pairs are ok as order IDs are not so high yet...

BuyerIsMaker is aways true

AggregateTradeMessage is returning BuyerIsMaker aways true. Anyone with this problem?
I'm trying to make a sort of tape reading analysis...

BinanceClient.GetCandleSticks missing Start/End Times

The API working fantastic, but there are a few optional calls that I would like to utilize from the factory GetKline API call. The factory API call for GetKline allows you to specify the start and end time of a request, which would be a great feature to be added into the code as an optional parameter.

Thanks!

NewOrder - return BadRequest - Error 400

I'm doing tests.

Everything works correctly, except NewOrder method

It returns "Bad Request" (400)

Has this happened to you? Does anybody know what is it due to?

Can not open project

I am new member. When I download sourcecode and open project, but error happen. I using VS profesional 2017.
untitled

Located bug in ListenUserDataEndpoint

The switch statement doesn't work because eventData.e isn't being cast to a string.

I ran through the code in debug mode and was able to confirm changing this:
switch (eventData.e)
to this:
switch ((string)eventData.e)
made the switch statement properly evaluate and the event handlers will now fire.

MIN_NOTIONAL Error on Post new order (MARKET)

when I try to post new order on market sometimes I've got MIN_NOTIONAL error.
according to my researches, it's because of the Binance trading rules, but I didn't find a way to handle it.

my website is a cryptocurrency shop and when a customer buys for example Bitcoin, I post new BUY BTCUSDT order (Market)

var taskResult = Task.Run(() => binanceClient.PostNewOrder("BTCUSDT", quantity, 0m, OrderSide.BUY, OrderType.MARKET));

Trouble with ListenTradeEndpoint

I have integrated the Binance.API.Csharp.Client and can get the following listener to work

binanceClient.ListenTradeEndpoint("ethbtc", AggregateTradesHandler3)

So it works in principle.

However, when I try to implement user data it does not initialize:

binanceClient.ListenUserDataEndpoint(AccountHandler, TradesHandler, OrdersHandler);
(I copied the code + the three callback functions from the documentation.)

It fails silently on this line. I can step through it and can see the line where it loses control.

It gets to the following function

public async Task CallAsync(ApiMethod method, string endpoint, bool isSigned = false, string parameters = null)

and does not make it through this line.

var response = await _httpClient.SendAsync(request).ConfigureAwait(false);

I downloaded the API a few days ago and have not made any changes to the wrapper code.

Any ideas as to how to approach this? Does this part of the api work for others?

Thanks

Error code 1021 Timestamp

I get the following error when running most modules, where can I change the recvWindow property to get this working?

Exception: Api Error Code: -1021 Message: Timestamp for this request was 1000ms ahead of the server's time.

Issue with binanceClient.GetOrder Price shows as 0.00000000

When I create an order and then retrieve the details using 'GetOrder', I can get all the details from the order but the buy price always shows as 0.00000000, the order has FILLED so it is not that it is waiting to place or anything as it is a market buy. I'd really appreciate any help with this as it's driving me mad...

CPU Pegged when running as a GUI

Thank you for writing this client! I am able to connect when I use the console; however, when I use a Win Forms or WPF, it seems to stall and lock the CPU. Any ideas?

image
image

Unable to read data from the transport connection

I am using the Websockets. After a while of running, I get the below error.

Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.

error -1100 on posting Order with decimal prices

using the code

var sellOrder = await client.PostNewOrder("trxbtc", 100m, 0.00000500m, OrderSide.SELL,OrderType.LIMIT);
the api is send the error :
"Api Error Code: -1100 Message: Illegal characters found in parameter 'price'; legal range is '^([0-9]{1,20})(\.[0-9]{1,20})?$'."

If i use int number the same code works fine
ex : var sellOrder = await client.PostNewOrder("trxbtc", 100m, 1m, OrderSide.SELL,OrderType.LIMIT);

Error passing single symbol into 24H Price Change

Hi,

Sorry i might be doing something wrong. But when i pass a single symbol i get the following error.
It works fine if i pass nothing ( as in returns the 24hour price for all symbols)

System.AggregateException
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
at StockMonitor.Apis.BinanceAPI.Get24HourChangeInfo(String symbol)

Inner Exception 1:
JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable`1[Binance.API.Csharp.Client.Models.Market.PriceChangeInfo]' 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 'symbol', line 1, position 10.

Getting 401 (Unauthorized) on GetAccountInfo

Hi,

I am getting HttpRequestException: Response status code does not indicate success: 401 (Unauthorized)
when using the GetAccountInfo() function, Other functions like GetAllPrices() works. 
what am i doing wrong?  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.