JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.03k stars 425 forks source link

how to i connect to Binance Future ? #291

Closed TarrahArshad closed 4 years ago

TarrahArshad commented 4 years ago

i need balance and position and order websocket subscription and price also

TarrahArshad commented 4 years ago

error http://snap.ashampoo.com/4U39eCfemmrwZRXItAs8BPGYQcLlakJ4aF3eIbivNzmimfrAge9HTgbFiMQIx1Fx

nikkozp commented 4 years ago

BinanceSocketClientOptions uses the new using Binance.Net.Objects.Spot. Check in your code

TarrahArshad commented 4 years ago

using Binance.Net.Objects.Spot

i added but stile error

TarrahArshad commented 4 years ago

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Binance.Net; using Binance.Net.Objects; using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Logging;

using System.IO; using Telerik.WinControls.UI; using BinanceBOT.Model; using System.Linq;

using Binance.Net.Objects.Spot; using Binance.Net.Objects.Futures;

namespace BinanceBot.Wizo { public partial class frmFutures : Telerik.WinControls.UI.RadForm { public frmFutures() { InitializeComponent(); }

    private async void frmFutures_Load(object sender, EventArgs e)
    {
        try
        {

            new BinanceBOT.Connector.BinanceApi(AppSettings.GetApiKey(), AppSettings.GetSecretKey());

            //  var successFuture = socketClientF.GetFuturesAccountBalance();

            BinanceFuturesSocketClient Ws = new BinanceFuturesSocketClient();
            BinanceFuturesClient Client = new BinanceFuturesClient(new BinanceFuturesClientOptions("https://testnet.binancefuture.com")
            {
                LogVerbosity = LogVerbosity.Debug,
                LogWriters = new List<TextWriter> { Console.Out }
            });

            Client.SetApiCredentials(AppSettings.GetApiKey(), AppSettings.GetSecretKey());
            Ws.SetApiCredentials(AppSettings.GetApiKey(), AppSettings.GetSecretKey());

            var listenKey = await Client.StartUserStreamAsync().ConfigureAwait(false);

            var bf = Client.GetFuturesAccountBalance();
           // lblFutureBalance.Text = string.Format("Future Balance ${0} - BND{1}", bf.Data.ToList()[0].Balance, bf.Data.ToList()[1].Balance);

            // label1.Text = Client.GetFuturesAccountBalance().Data;

            var Account = await Ws.SubscribeToUserDataUpdatesAsync(listenKey.Data,
                            Balance =>
                            {
                                //  label1.Text = Balance.WalletBalance.ToString();

                            },
                            Position =>
                            {
                                grvPosition.DataSource = Position;
                            },
                            Order =>
                            {
                                grvPosition.DataSource = Order;

                            },
                            ListenKeyExpired =>
                            {

                            }).ConfigureAwait(false);

        }
        catch (Exception ex)
        {
            // txtLogs.Text += $"\n ${ex.Message}";
        }
    }
}

}

nikkozp commented 4 years ago

you use testnetfor the client, and mainnetfor sockets. Use one thing

TarrahArshad commented 4 years ago

you use testnetfor the client, and mainnetfor sockets. Use one thing

its correct ?

            BinanceFuturesSocketClient Ws = new BinanceFuturesSocketClient(new BinanceFuturesSocketClientOptions("https://testnet.binancefuture.com") {
                LogVerbosity = LogVerbosity.Debug,
                LogWriters = new List<TextWriter> { Console.Out }
            });
nikkozp commented 4 years ago
public BinanceFuturesSocketClient Ws = new BinanceFuturesSocketClient(new BinanceFuturesSocketClientOptions("wss://stream.binancefuture.com/ws/")
        {
            BaseAddress = "wss://stream.binancefuture.com/ws/",
            BaseSocketCombinedAddress = "wss://stream.binancefuture.com/",
            LogVerbosity = LogVerbosity.Debug,
            LogWriters = new List<TextWriter> { Console.Out },
        });
TarrahArshad commented 4 years ago

new erro show http://snap.ashampoo.com/FDchPogvLSCdL2YirwejRKvlzZw69sSfwUmGDS4pg0ss1m1MD0wVKmcEhyCgLvlC

TarrahArshad commented 4 years ago

good now work fine and i recive positions and order and balance realtime one question when i recieve balance poistion and order is changed or no everytime i recive ?

nikkozp commented 4 years ago

You always get the balance first , then the position and orders. At Binance, this is done perfectly, unlike other exchanges. Based on my experience.

TarrahArshad commented 4 years ago

You always get the balance first , then the position and orders. At Binance, this is done perfectly, unlike other exchanges. Based on my experience.

great thank u i going to complete my project binance future UI is slow and i will implement myself platform for fast and easy trade stop losee take profite close or join to pump

TarrahArshad commented 4 years ago

hi i need know how to get realtime Trades , OrderBook , Depth , Chart , Market Price and price of all coin available in binance future in same time , and other data Funding/8h 24h changes , 24h high and 24h low and 25h volume and for calculator its have api we call or need we implement myself if yes where is formula for calc PNL ROE