Coder Social home page Coder Social logo

jkorf / coinex.net Goto Github PK

View Code? Open in Web Editor NEW
45.0 7.0 33.0 4.94 MB

A C# .netstandard client library for the CoinEx REST and Websocket Spot API focusing on clear usage and models

Home Page: https://jkorf.github.io/CoinEx.Net/

License: MIT License

C# 100.00%
coinex coinexchange cryptocurrency cryptocurrency-exchanges coinexnet dotnet exchange coinex-api coinex-automatic-trading coinex-bot

coinex.net's Introduction

.CoinEx.Net CoinEx.Net

.NET License

CoinEx.Net is a strongly typed client library for accessing the CoinEx REST and Websocket API.

Features

  • Response data is mapped to descriptive models
  • Input parameters and response values are mapped to discriptive enum values where possible
  • Automatic websocket (re)connection management
  • Client side order book implementation
  • Extensive logging
  • Support for different environments
  • Easy integration with other exchange client based on the CryptoExchange.Net base library

Supported Frameworks

The library is targeting both .NET Standard 2.0 and .NET Standard 2.1 for optimal compatibility

.NET implementation Version Support
.NET Core 2.0 and higher
.NET Framework 4.6.1 and higher
Mono 5.4 and higher
Xamarin.iOS 10.14 and higher
Xamarin.Android 8.0 and higher
UWP 10.0.16299 and higher
Unity 2018.1 and higher

Install the library

NuGet

NuGet version Nuget downloads

dotnet add package CoinEx.Net

GitHub packages

CoinEx.Net is available on GitHub packages. You'll need to add https://nuget.pkg.github.com/JKorf/index.json as a NuGet package source.

Download release

GitHub Release

The NuGet package files are added along side the source with the latest GitHub release which can found here.

How to use

REST Endpoints

// Get the ETH/USDT ticker via rest request
var restClient = new CoinExRestClient();
var tickerResult = await restClient.SpotApiV2.ExchangeData.GetTickersAsync(new [] { "ETHUSDT" });
var lastPrice = tickerResult.Data.LastPrice;

Websocket streams

// Subscribe to ETH/USDT ticker updates via the websocket API
var socketClient = new CoinExSocketClient();
var tickerSubscriptionResult = socketClient.SpotApiV2.SubscribeToTickerUpdatesAsync(new [] { "ETHUSDT" }, (update) =>
{
	var lastPrice = update.Data.First().LastPrice;
});

For information on the clients, dependency injection, response processing and more see the CoinEx.Net documentation, CryptoExchange.Net documentation, or have a look at the examples here or here.

CryptoExchange.Net

CoinEx.Net is based on the CryptoExchange.Net base library. Other exchange API implementations based on the CryptoExchange.Net base library are available and follow the same logic.

CryptoExchange.Net also allows for easy access to different exchange API's.

Exchange Repository Nuget
Binance JKorf/Binance.Net Nuget version
BingX JKorf/BingX.Net Nuget version
Bitfinex JKorf/Bitfinex.Net Nuget version
Bitget JKorf/Bitget.Net Nuget version
BitMart JKorf/BitMart.Net Nuget version
Bybit JKorf/Bybit.Net Nuget version
CoinGecko JKorf/CoinGecko.Net Nuget version
Gate.io JKorf/GateIo.Net Nuget version
Huobi/HTX JKorf/Huobi.Net Nuget version
Kraken JKorf/Kraken.Net Nuget version
Kucoin JKorf/Kucoin.Net Nuget version
Mexc JKorf/Mexc.Net Nuget version
OKX JKorf/OKX.Net Nuget version

Discord

Nuget version
A Discord server is available here. Feel free to join for discussion and/or questions around the CryptoExchange.Net and implementation libraries.

Supported functionality

Spot Api V1

API Supported Location
Market Data API restClient.SpotApi.ExchangeData
Account API restClient.SpotApi.Account
Trading API restClient.SpotApi.Trading
Websocket API socketClient.SpotApi

Futures Api V1

API Supported Location
* X

V2 Account

API Supported Location
Sub-Account X
Fee Rate restClient.SpotApiV2.ExchangeData
Set restClient.SpotApiV2.Account

V2 Asset

API Supported Location
Balance rest restClient.SpotApiV2.Account
Balance websocket socketClient.SpotApiV2
Loan & Repayment restClient.SpotApiV2.Account
Deposit & Withdrawal restClient.SpotApiV2.Account
Transfer restClient.SpotApiV2.Account
Aam restClient.SpotApiV2.Account

V2 Spot

API Supported Location
Ticker rest restClient.SpotApiV2.ExchangeData
Ticker websocket socketClient.SpotApiV2
Orders rest restClient.SpotApiV2.Trading
Orders websocket socketClient.SpotApiV2
Executions rest restClient.SpotApiV2.Trading
Executions websocket socketClient.SpotApiV2

V2 Futures

API Supported Location
Ticker rest restClient.SpotApiV2.ExchangeData
Ticker websocket socketClient.SpotApiV2
Orders rest restClient.SpotApiV2.Trading
Orders websocket socketClient.SpotApiV2
Executions rest restClient.SpotApiV2.Trading
Executions websocket socketClient.SpotApiV2
Position rest restClient.SpotApiV2.Trading
Position websocket socketClient.SpotApiV2

Support the project

I develop and maintain this package on my own for free in my spare time, any support is greatly appreciated.

Donate

Make a one time donation in a crypto currency of your choice. If you prefer to donate a currency not listed here please contact me.

Btc: bc1q277a5n54s2l2mzlu778ef7lpkwhjhyvghuv8qf
Eth: 0xcb1b63aCF9fef2755eBf4a0506250074496Ad5b7
USDT (TRX) TKigKeJPXZYyMVDgMyXxMf17MWYia92Rjd

Sponsor

Alternatively, sponsor me on Github using Github Sponsors.

Release notes

  • Version 7.5.0 - 07 Aug 2024

  • Version 7.4.0 - 27 Jul 2024

  • Version 7.3.0 - 16 Jul 2024

  • Version 7.2.1 - 02 Jul 2024

  • Version 7.2.0 - 23 Jun 2024

  • Version 7.1.0 - 11 Jun 2024

  • Version 7.0.5 - 07 May 2024

  • Version 7.0.4 - 01 May 2024

  • Version 7.0.3 - 28 Apr 2024

  • Version 7.0.2 - 23 Apr 2024

  • Version 7.0.1 - 18 Apr 2024

  • Version 7.0.0 - 06 Apr 2024

    • Added V2 Spot API implementation
    • Added Futures implementation
  • Version 6.2.2 - 03 Apr 2024

    • Added parameter for SubscribeToOrderBookUpdatesAsync for full or dif updates
    • Updated string comparision for improved performance
    • Removed pre-send symbol validation
  • Version 6.2.1 - 24 Mar 2024

  • Version 6.2.0 - 16 Mar 2024

  • Version 6.1.1 - 26 Feb 2024

    • Fixed order subscription with symbol parameters
  • Version 6.1.0 - 25 Feb 2024

    • Updated CryptoExchange.Net and implemented reworked websocket message handling. For release notes for the CryptoExchange.Net base library see: https://github.com/JKorf/CryptoExchange.Net?tab=readme-ov-file#release-notes
    • Fixed issue in DI registration causing http client to not be correctly injected
    • Made various parameters in CoinExSocketClient optional
    • Removed redundant CoinExRestClient constructor overload
    • Updated some namespaces
  • Version 6.0.6 - 03 Dec 2023

    • Updated CryptoExchange.Net
  • Version 6.0.5 - 14 Nov 2023

    • Fix for broker reference
  • Version 6.0.4 - 29 Oct 2023

    • Added broker reference option
  • Version 6.0.3 - 24 Oct 2023

    • Updated CryptoExchange.Net
  • Version 6.0.2 - 09 Oct 2023

    • Updated CryptoExchange.Net version
    • Added ISpotClient to DI injection
  • Version 6.0.1 - 25 Aug 2023

    • Updated CryptoExchange.Net
  • Version 6.0.0 - 25 Jun 2023

    • Updated CryptoExchange.Net to version 6.0.0
    • Renamed CoinExClient to CoinExRestClient
    • Renamed SpotStreams to SpotApi on the CoinExSocketClient
    • Updated endpoints to consistently use a base url without any path as basis to make switching environments/base urls clearer
    • Added ICoinExOrderBookFactory and implementation for creating order books
    • Updated dependency injection register method (AddCoinEx)
  • Version 5.1.2 - 18 Mar 2023

    • Updated CryptoExchange.Net
  • Version 5.1.1 - 14 Feb 2023

    • Updated CryptoExchange.Net
    • Fixed issue with request signing with parameters containing special characters
  • Version 5.1.0 - 17 Nov 2022

    • Updated CryptoExchange.Net
  • Version 5.0.15 - 18 Jul 2022

    • Updated CryptoExchange.Net
  • Version 5.0.14 - 16 Jul 2022

    • Updated CryptoExchange.Net
  • Version 5.0.13 - 10 Jul 2022

    • Updated CryptoExchange.Net
  • Version 5.0.12 - 12 Jun 2022

    • Updated CryptoExchange.Net
  • Version 5.0.11 - 24 May 2022

    • Updated CryptoExchange.Net
  • Version 5.0.10 - 22 May 2022

    • Updated CryptoExchange.Net
  • Version 5.0.9 - 08 May 2022

    • Updated CryptoExchange.Net
  • Version 5.0.8 - 01 May 2022

    • Updated CryptoExchange.Net which fixed an timing related issue in the websocket reconnection logic
    • Added seconds representation to KlineInterval enum
  • Version 5.0.7 - 14 Apr 2022

    • Updated CryptoExchange.Net
  • Version 5.0.6 - 14 Mar 2022

    • Fixed stopPrice serialization in PlaceOrderAsync
  • Version 5.0.5 - 10 Mar 2022

    • Updated CryptoExchange.Net
  • Version 5.0.4 - 08 Mar 2022

    • Updated CryptoExchange.Net
  • Version 5.0.3 - 01 Mar 2022

    • Updated CryptoExchange.Net improving the websocket reconnection robustness
  • Version 5.0.2 - 27 Feb 2022

    • Updated CryptoExchange.Net
  • Version 5.0.1 - 24 Feb 2022

    • Updated CryptoExchange.Net
  • Version 5.0.0 - 18 Feb 2022

    • Added Github.io page for documentation: https://jkorf.github.io/CoinEx.Net/

    • unit tests for parsing the returned JSON for each endpoint and subscription

    • Added AddCoinEx extension method on IServiceCollection for easy dependency injection

    • Added URL reference to API endpoint documentation for each endpoint

    • Added default rate limiter

    • Refactored different PlaceOrderAsync methods to a single PlaceOrderAsync method to be consistent across exchange implementations

    • Refactored client structure to be consistent across exchange implementations

    • Renamed various properties to be consistent across exchange implementations

    • Cleaned up project structure

    • Fixed various models

    • Updated CryptoExchange.Net, see https://github.com/JKorf/CryptoExchange.Net#release-notes

    • See https://jkorf.github.io/CoinEx.Net/MigrationGuide.html for additional notes for updating from V4 to V5

  • Version 4.2.4 - 03 Nov 2021

    • Updated CoinExAssetConfig model
    • Fixed typo in OrderOptionConverter
  • Version 4.2.3 - 08 Oct 2021

    • Updated CryptoExchange.Net to fix some socket issues
  • Version 4.2.2 - 06 Oct 2021

    • Updated CryptoExchange.Net, fixing socket issue when calling from .Net Framework
  • Version 4.2.1 - 05 Oct 2021

    • Added GetOpenStopOrdersAsync endpoint
    • Added CancelAllStopOrdersAsync endpoint
  • Version 4.2.0 - 29 Sep 2021

    • Fixed DELETE endpoints
    • Changed GetBalances parameter from params to IEnumerable
    • Updated CryptoExchange.Net
  • Version 4.1.2 - 22 Sep 2021

    • Fixed nonce provider when running multiple program instances
  • Version 4.1.1 - 21 Sep 2021

    • Fix for nonce provider not working correctly in combination with other exchanges
  • Version 4.1.0 - 20 Sep 2021

    • Added custom nonce provider support
    • Added PlaceStopMarketOrderAsync endpoint
    • Added missing SetApiCredentials method
    • Updated CryptoExchange.Net
  • Version 4.0.6 - 15 Sep 2021

    • Updated CryptoExchange.Net
  • Version 4.0.5 - 02 Sep 2021

    • Fix for disposing order book closing socket even if there are other connections
  • Version 4.0.4 - 26 Aug 2021

    • Updated CryptoExchange.Net
  • Version 4.0.3 - 26 Aug 2021

    • Added PlaceStopLimitOrderAsync endpoint
  • Version 4.0.2 - 24 Aug 2021

    • Updated CryptoExchange.Net, improving websocket and SymbolOrderBook performance
  • Version 4.0.1 - 13 Aug 2021

    • Fix for OperationCancelledException being thrown when closing a socket from a .net framework project
  • Version 4.0.0 - 12 Aug 2021

  • Version 4.0.0-beta3 - 09 Aug 2021

    • Renamed GetSymbolTradesAsync to GetTradesHistoryAsync
    • Renamed GetExecutedOrderDetailsAsync to GetOrderTradesAsync
    • Renamed GetOrderStatusAsync to GetOrderAsync
    • Renamed GetTradesAsync to GetUserTradesAsync
  • Version 4.0.0-beta2 - 26 Jul 2021

    • Updated CryptoExchange.Net
  • Version 4.0.0-beta1 - 09 Jul 2021

    • Added Async postfix for async methods
    • Updated CryptoExchange.Net
  • Version 3.3.0-beta10 - 15 Jun 2021

    • WithrawAsync fixed
  • Version 3.3.0-beta9 - 14 Jun 2021

    • Fixed typo in WithdrawAsync
  • Version 3.3.0-beta8 - 07 Jun 2021

    • Fixed GetWithdrawalHistory
    • Updated CryptoExchange.Net
  • Version 3.3.0-beta7 - 03 Jun 2021

    • Fixed order subscription (again)
  • Version 3.3.0-beta6 - 03 Jun 2021

    • Added ClientId to order update model
    • Fixed order subscription parameters
  • Version 3.3.0-beta5 - 02 Jun 2021

    • Added optional PlaceLimitOrderAsync parameters
    • Fix for WithdrawAsync
  • Version 3.3.0-beta4 - 02 Jun 2021

    • Added GetCurrencyRateAsync endpoint
    • Added GetAssetConfigAsync endpoint
    • Added GetDepositAddressAsync
  • Version 3.3.0-beta3 - 26 May 2021

    • Removed non-async calls
    • Updated to CryptoExchange.Net changes
  • Version 3.3.0-beta2 - 06 mei 2021

    • Updated CryptoExchange.Net
  • Version 3.3.0-beta1 - 30 apr 2021

    • Updated to CryptoExchange.Net 4.0.0-beta1, new websocket implementation
  • Version 3.2.6 - 04 mei 2021

    • Fix for trades subscription deserialization when extra array item is received
    • Fix parameter type in Withdraw method
  • Version 3.2.5 - 28 apr 2021

    • Fix trade deserialization without order id
    • Allow symbols starting with numeric character
    • Update CryptoExchange.Net
    • Fixed check in socket balance update
  • Version 3.2.4 - 19 apr 2021

    • Fixed Withdraw parameters
  • Version 3.2.3 - 19 apr 2021

    • Fixed SubscribeToOrderUpdates serialization
    • Updated CryptoExchange.Net
  • Version 3.2.2 - 30 mrt 2021

    • Updated CryptoExchange.Net
  • Version 3.2.1 - 01 mrt 2021

    • Added Nuget SymbolPackage
  • Version 3.2.0 - 01 mrt 2021

    • Added config for deterministic build
    • Updated CryptoExchange.Net
  • Version 3.1.2 - 22 jan 2021

    • Updated for ICommonKline
  • Version 3.1.1 - 14 jan 2021

    • Updated CryptoExchange.Net
  • Version 3.1.0 - 21 dec 2020

    • Update CryptoExchange.Net
    • Updated to latest IExchangeClient
  • Version 3.0.14 - 11 dec 2020

    • Updated CryptoExchange.Net
    • Implemented IExchangeClient
  • Version 3.0.13 - 19 nov 2020

    • Updated CryptoExchange.Net
  • Version 3.0.12 - 22 okt 2020

    • Fixed parsing of orders
  • Version 3.0.11 - 28 Aug 2020

    • Updated CrytpoExchange.Net
  • Version 3.0.10 - 12 Aug 2020

    • Updated CryptoExchange.Net
  • Version 3.0.9 - 21 Jun 2020

    • Updated CryptoExchange
  • Version 3.0.8 - 16 Jun 2020

    • Updated CryptoExchange.Net
  • Version 3.0.7 - 07 Jun 2020

    • Updated CryptoExchange
  • Version 3.0.6 - 03 Mar 2020

    • Updated CryptoExchange
  • Version 3.0.5 - 03 Mar 2020

    • Updated CryptoExchange
  • Version 3.0.4 - 27 Jan 2020

    • Updated CryptoExchange.Net
  • Version 3.0.3 - 12 Nov 2019

    • Added DepositHistory and GetMarketInfo endpoints
  • Version 3.0.2 - 23 Oct 2019

    • Fixed validation length symbols again
  • Version 3.0.1 - 23 Oct 2019

    • Fixed validation length symbols
  • Version 3.0.0 - 23 Oct 2019

    • See CryptoExchange.Net 3.0 release notes
    • Added input validation
    • Added CancellationToken support to all requests
    • Now using IEnumerable<> for collections
    • Renamed Market -> Symbol
    • Renamed MarketDepth -> OrderBook
    • Renamed Transaction -> Trade
  • Version 2.0.10 - 11 Sep 2019

    • Updated CryptoExchange.Net
  • Version 2.0.9 - 07 Aug 2019

    • Updated CryptoExchange.Net
  • Version 2.0.8 - 05 Aug 2019

    • Added xml for code docs
  • Version 2.0.7 - 09 jul 2019

    • Updated CoinExSymbolOrderBook
  • Version 2.0.6 - 14 may 2019

    • Added an order book implementation for easily keeping an updated order book
    • Added additional constructor to ApiCredentials to be able to read from file
  • Version 2.0.5 - 01 may 2019

    • Updated to latest CryptoExchange.Net
      • Adds response header to REST call result
      • Added rate limiter per API key
      • Unified socket client workings
  • Version 2.0.4 - 07 mar 2019

    • Updated to latest CryptoExchange.Net
  • Version 2.0.3 - 01 feb 2019

    • Updated to latest CryptoExchange.Net
  • Version 2.0.2 - 06 dec 2018

    • Fix for user-agent error on .Net framework
  • Version 2.0.1 - 06 dec 2018

    • Fixed freezes if called from the UI thread
  • Version 2.0.0 - 05 dec 2018

    • Updated to CryptoExchange.Net version 2
      • Libraries now use the same standard functionalities
      • Objects returned by socket subscriptions standardized across libraries
  • Version 1.0.0 - 21 sep 2018

    • Updated CryptoExchange.Net
  • Version 0.0.6 - 20 aug 2018

    • Fix for default api credentials getting disposed
  • Version 0.0.5 - 20 aug 2018

    • Updated CryptoExchange.Net for bug fix
  • Version 0.0.4 - 17 aug 2018

    • Added handling for incosistent data in socket update
    • Added additional logging
    • Small reconnection fixes
  • Version 0.0.3 - 16 aug 2018

    • Added client interfaces
    • Fixed minor Resharper warnings
  • Version 0.0.2 - 13 aug 2018

    • Upped CryptoExchange.Net to fix bug
  • Version 0.0.1 - 13 aug 2018

    • Initial release

coinex.net's People

Contributors

burakoner avatar d-ugarov avatar ericgarnier avatar galenbancroft avatar jkorf avatar jonnern avatar meysamrt avatar pcartwright81 avatar ridicoulous avatar shaliakbari 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

coinex.net's Issues

SubscribeToKlineUpdatesAsync return method not found.

SubscribeToKlineUpdatesAsync
I try to get 5 minutes candles, TwoHour or other candles via SubscribeToKlineUpdatesAsync but I get this response:

listResult.Data
{
data : null,
Error: {
code : 4,
data : null,
message: "method not found"
},
Success: False
}
please help me to fix this problem.

 using(var sockClient = new CoinExSocketClient())
  {
      var listResult = await sockClient.SubscribeToKlineUpdatesAsync("ADAUSDT", Objects.KlineInterval.TwoHour, (e )=> {

          Console.WriteLine(e.Data.FirstOrDefault().Close);
          
      
      });
      Console.WriteLine(listResult);


  }

Coinex Futures request

Hi Jan Korf, first of all I thank you for your labor, I am grateful for your efforts.I think it's time to add the futures feature.May I ask you to add futures to your package? I would like to give you a Cet token gift, because coinex is improving itself, and now there are tradingview charts on coinex. I don't know december you know, by the way, Coinex created the Coinex Smart Chain network .
by the way, I apologize for my bad English.

MarketOrder buy

Hi,
When I'm trying to make a market buy order the server keeps saying insuff funds. If I manually buy them and do a market sell i have no problem. the buy order just won't work. Limit orders works both ways

Also tried with other currencies like XMRBTC and it does the same.

thanks

image

image
image

Market sell of 0.21 LTCBTC
image

Confirmation
image

SubscribeToOrderUpdatesAsync error

Describe the bug
SubscribeToOrderUpdatesAsync returns invalid arguments (Error:1: invalid argument )

To Reproduce
var r=await socket.SubscribeToOrderUpdatesAsync(new[] { "DOGEUSDT" }, (updateType, data) =>
{
var actual = data;
});

Expected behavior
r.success must be true

Wrong orderbook entries returned for PGN/BTC

Prices for known Pairs like BTCUSDT or ETHBTC are correct but when I'm trying to fetch the orderbook for PGNBTC I'm not getting the Correct prices!

here is the best ask and bid price I'm getting it does not match with the prices I'm seeing on coinex orderbook right now!
Prices I'm getting from CoinExSymbolOrderBook for PGNBTC
0.000000010000 0.000000000000
Prices I'm seeing on exchange order book
0.0000000038 0.0000000035

These numbers should match the numbers I'm seeing on the exchange right?

var coinExSymbolOrderBook = new CoinExSymbolOrderBook("PGNBTC", new CoinExOrderBookOptions(){LogVerbosity = LogVerbosity.Debug});
            coinExSymbolOrderBook.OnBestOffersChanged += tuple => 
                Console.WriteLine("{0:0.000000000000} {1:0.000000000000}", coinExSymbolOrderBook.BestAsk.Price,coinExSymbolOrderBook.BestBid.Price);
            coinExSymbolOrderBook.Start();

Here is the simplified code I'm using!;

Here is the log I'm getting as you can see it only fetches 1 bid price and

2021/02/11 16:28:04:164 | CoinEx     | Debug | CoinEx order book PGNBTC starting
2021/02/11 16:28:04:169 | CoinEx     | Info | CoinEx order book PGNBTC status changed: Disconnected => Connecting
2021/02/11 16:28:06:375 | CoinEx     | Info | CoinEx order book PGNBTC status changed: Connecting => Syncing
2021/02/11 16:28:06:410 | CoinEx     | Debug | CoinEx order book PGNBTC data set: 1 bids, 20 asks. #637486450864063088
2021/02/11 16:28:06:414 | CoinEx     | Info | CoinEx order book PGNBTC status changed: Syncing => Synced
2021/02/11 16:28:07:191 | CoinEx     | Debug | CoinEx order book PGNBTC update processed #637486450871870154-637486450871870154

Strange behaviour of CoinExSymbolOrderBook

Firstly, thanks for such a great library!

I noticed that after some period of time, SymolOrderBook stop distributing data, at least it sends empty order book and after that - silence. Status is "Synced". Have check Coinex, but exchange sends data correctly, without outages.

Same problem with Kucoin symbol orderbook.

Thats short example

var orderbook = new CoinExSymbolOrderBook(symbol, new CoinExOrderBookOptions()); 
await orderBook.StartAsync().ConfigureAwait(false);
....
 var updateNumber = instance.OrderBook.LastSequenceNumber;
while (!Token.IsCancellationRequested)
            {
                    if (updateNumber != OrderBook.LastSequenceNumber)
                    {
                        OnOrderBook(orderBook); //Event
                        updateNumber = instance.OrderBook.LastSequenceNumber;
                    }
                    Thread.Sleep(100);
            }

Creating Authorization code

Short Form of my issue:
*) My software keep receiving this error message when I want to retrieve my account balance:

First lets try if information of the provider itself is valid or not?
According to
https://github.com/coinexcom/coinex_exchange_api/wiki/012security_authorization
we need a authorization code, which is an MD5 to sign in, let see the process.
1- Sort all parameter, As I have only one: tonce
2- Generate String to sign, which means add access_id at the beginning and secret_key at the end
so:
access_id=123&tonce=1590000000000&secret_key=12345
This shall go to an MD5 hashing process, assuming it would be AaBbCc
It has to be upper cased then this will go to header:
authorization:AABBCC

Note that in their sample "?" does not exists.
The BaseURL is: https://api.coinex.com/v1/
and the folder/directory path is: balance/info
Complete request to GET is:
https://api.coinex.com/v1/balance/info?access_id=123&tonce=1590000000000&secret_key=12345

But I receive error:
{"code":25,"data":{},"message":"Signature error."}

Now my confusion starts
maybe "?" shall be added, maybe complete URL shall be MD5ed, maybe not base url but folder should be added only, maybe GET command also should be included, maybe all of it shall be upper cased, maybe lower cased! all with and without "?"
maybe I put only tonce for MD5 and access_id with secret_key in header, and this list goes on with more probabilities.

I sent "some" request to them for help, no success, so I am asking help here too.
My ((Sample)) code:

AnsiString BaseURL="https://api.coinex.com/v1/";
AnsiString Folder ="balance/info";
AnsiString QueMark="?";
AnsiString MyStr="access_id=123&tonce=1590000000000&secret_key=12345"
AnsiString AuthorizationCode=Md5(
	//QueMark+ //that I try both ways
	MyStr);
RESTClient1->Params->AddHeader("authorization", AuthorizationCode);
RESTClient1->Params->AddHeader("User-Agent","Mozilla/...as what they said...");
RESTClient1->Accept="application/json";
RESTClient1->AcceptCharset="UTF-8";
RESTClient1->AcceptEncoding="*";
RESTClient1->ContentType="application/x-www-form-urlencoded"
RESTClient1->AllowCookies=true;//false??
RESTClient1->AutoCreateParams=true;//false??

RESTClient1->BaseURL=BaseURL+Folder+QueMark+MyStr;
RESTRequest1->Execute();
MemoResult->Lines->Text=RESTResponse1->Content;

Stop-Limit order

Hello ,

it seems stop-limit order type is not available in lib.

so I got the source and implement and also test it .

what is a right path to merge it into main lib ?

thanks

Wrong source_id parameter in place market order

Describe the bug
A clear and concise description of what the bug is.

--parameter source_id (number) misplaced with client_id (string)

To Reproduce
What endpoints and subscriptions are called.

--PlaceMarketOrderAsync
--/v1/order/market

Expected behavior
A clear and concise description of what you expected to happen.

--two different properties according to https://github.com/coinexcom/coinex_exchange_api/wiki/032market_order
client_id client_id is the custom id of order. Currently, it only supports uppercase and lowercase letters, numbers, hyphens and underlines, and it should be less than 32 bytes.
source_id user defines number and return

Debug logging
Add debug logging related to the issue. Enable Debug logging in the client options by settings LogVerbosity to Debug.

Error invalid parameter in SubscribeToOrderUpdates

Hi,
I have the following error when using the SubscribeToOrderUpdates method:
Error:invalid argument code:1
This is my code:
var symbols = new List();
symbols.Add("BTCUSDT");
var sub06 = ws.SubscribeToOrderUpdates(symbols, (updateType, data) => { });
if (!sub06.Success)
{
Console.WriteLine($"SubscribeToOrderUpdates Error:{sub06.Error.Message} code:{sub06.Error.Code}");
}
Thx.

asset_fee and fee_asset does not fill

Describe the bug
after market order executed asset_fee and fee_asset does not filled !

To Reproduce
Execute a market order

following image show details

image

Warning for trade update

When I subscribe to the trade information, I received this warning:

"[2021/05/01 12:27:54.368, (36, .)] INFO: 2021/05/01 12:27:54:368 | CoinEx | Warning | Received unexpected data format for trade update. Expected 2 objects, received 3. Data: [ONESUSDT,[\r\n {\r\n "id": 2275032287,\r\n "order_id": 45397170793,\r\n "client_id": "",\r\n "time": 1619872074.354161,\r\n "type": "sell",\r\n "amount": "12.72533333",\r\n "price": "1.0500"\r\n }\r\n],True]",

"[2021/05/01 12:27:54.974, (36, .)] INFO: 2021/05/01 12:27:54:974 | CoinEx | Warning | Received unexpected data format for trade update. Expected 2 objects, received 3. Data: [ONESUSDT,[\r\n {\r\n "id": 2275032292,\r\n "order_id": 45397170793,\r\n "client_id": "",\r\n "time": 1619872074.629507,\r\n "type": "sell",\r\n "amount": "8.55734985",\r\n "price": "1.0500"\r\n }\r\n],True]",

Someone add a True a the end?

Eric

websock error

Hi M. Korf,
just started using this api. Might find more bugs.

image

In buy code

Hello, when i want buy coin i must input 2 data , in example write 50,.. , i write my amount of coins i want buy and in next i write price of coin and both of them are decimal, i use varible in c# for bouth of them but when i want buy a coin and for example amount of coin is 654435.23244 this code dont working and i must use this number in code with m to working, please help me

Signature issue for char not letter nor digit

Hi JKorf,
first, thanks for all this super work.

I notice a small issue when I try to withdraw from coinex. I got a signature error message. This seems to be du to the presence of a : char in the destination address.

According to the CoinEx signature sample here (class CoinExClient),, line 27, the signature should be calculated over a big string containing the parameters. Their is no escape of the parameter values.

var body = string.Join("&", sortedArgs.Select(p => $"{p.Key}={p.Value}"));
//calc md5
var md5 = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(body));

But in your code, you use an Http Utility NameValueCollection, in ExtensionMethods.cs
NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(string.Empty);
...
uriBuilder.Query = nameValueCollection.ToString();

This code replace the : char by %3a
This make the signature to be wrong.

I think you can reproduce with any method that accept a not letter or digit parameter value.
HTH,
Eric

Nuget package

Hi,
Can you update the CoinExchange.Net to the current one on nuget?

thanks

Coinex order.subscribe argument error

Hello Jan,

Coinex Version 6.1.0 - 25 Feb 2024

In : CoinEx.Net.Objects.Sockets.Subscriptions.Orders
the class : internal class CoinExOrderSubscription
the method GetSubQuery(SocketConnection connection) builds a new object array around _symbols, therefore passing to the marketPlace Coinex an Array of Array as argument, instead of a simple array.

The log below illustrates this point :

[2024/02/26 18:07:42.201, (7, .)] INFO: 2024/02/26 18:07:42:201 | Trace | [Sckt 1] msg 6 - sending messsage: {"method":"order.subscribe","params":[["ZECUSDT"]],"id":5}
[2024/02/26 18:07:42.201, (7, .)] INFO: 2024/02/26 18:07:42:201 | Trace | [Sckt 1] msg 6 - Adding 58 bytes to send buffer
[2024/02/26 18:07:42.202, (10, .)] INFO: 2024/02/26 18:07:42:202 | Trace | [Sckt 1] msg 6 - sent 58 bytes
[2024/02/26 18:07:42.535, (14, .)] INFO: 2024/02/26 18:07:42:535 | Trace | [Sckt 1] received 78 bytes in single message
[2024/02/26 18:07:42.535, (14, .)] INFO: 2024/02/26 18:07:42:535 | Trace | [Sckt 1] 1 processor(s) matched to message with listener identifier 5
[2024/02/26 18:07:42.536, (10, .)] INFO: 2024/02/26 18:07:42:536 | Warning | [Sckt 1] failed to subscribe: [ServerError] 1: invalid argument

Kind Regards,
Philippe

Not all CoinEx APIs are implemented

Hi,

Thank you for your great libraries.

As CoinEx support team stated here the API documentation and specs are located at https://viabtc.github.io/coinex_api_en_doc/.
I figure it out that not all APIs are implemented yet, maybe it's because you are using an older version of document.

for example, there is an API for cancelling a stop order in CoinEx (here) which is not exists in the library.

Please, add Asset and Chain properties to CoinExAssetConfig class

The CoinExAssetConfig class miss the asset and chain properties useful for deposit and withdraw.
I suggest you to add:

    /// <summary>
    /// Asset code
    /// </summary>
    [JsonProperty("asset")]
    public string Asset { get; set; }

    /// <summary>
    /// Withdraw & Deposit asset chain
    /// </summary>
    [JsonProperty("chain")]
    public string Chain { get; set; }

Thanks a lot.

Andrea

withdraw error + format symbol

Hi.
I want withdraw with coinex nuget and I have some questions
1- Symbol format (syntax) in withdraw command. e.g : "DOGE-USDT" or "DOGE/USDT" or ...
2- in withdraw i getting error ;
var TransferfromCoinexRes = await clientCoinex.WithdrawAsync("DOGE/USDT", addr,true,1);
{25: Signature Incorrect }

3-In parameters of withdraw,There is no parameter based on the type of network.
4- withdraw in coinex site It asks me for the topt password, but here's what we need to do.
Explain that I whitelisted the address
good luck thank you

History object

Hi M. Korf,

I was playing again with your API and would it be possible to change the object for the history to include the same information as the trade result or maybe put just the fees. That's what I need. I've changed my version to include the missing elements in the history object.

no big deal but a suggestion.

thanks

how to use Futures with api

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
What endpoints and subscriptions are called.

Expected behavior
A clear and concise description of what you expected to happen.

Debug logging
Add debug logging related to the issue. Enable Debug logging in the client options by settings LogLevel to Debug.

GetDepositHistoryHistoryAsync Fails to decode du to has_next field (at least).

Hi @JKorf ,
I got an error during call to GetDepositHistoryHistoryAsync. It seems that the "has_next" field was not expected.
Maybe we must use a CoinExPagedResult<IEnumerable<CoinExDeposit>> or something similar?
The debug trace is below.

Eric

2021/05/23 11:41:10:952 | CoinEx | Debug | Client configuration: LogVerbosity: Debug, Writers: 2, Credentials: Set, BaseAddress: https://api.coinex.com/v1/, Proxy: -, RateLimiters: 0, RateLimitBehaviour: Wait, RequestTimeout: 00:00:30
2021/05/23 11:41:14:318 | CoinEx | Debug | [1] Creating request for https://api.coinex.com/v1/balance/coin/deposit
2021/05/23 11:41:14:333 | CoinEx | Debug | [1] Sending GET signed request to https://api.coinex.com/v1/balance/coin/deposit?access_id=5ZZZZZZZZZZZZZZZZZZZZZZZZZZZ&coin_type=ZEN&tonce=1621762874319
2021/05/23 11:41:14:813 | CoinEx | Debug | [1] Response received in 476ms: {"code": 0, "data": {"has_next": false, "curr_page": 1, "count": 1, "data": [{"coin_deposit_id": 6177984, "create_time": 1621630590, "amount": "4.1", "amount_display": "4.1", "actual_amount": "4.1", "actual_amount_display": "4.1", "confirmations": 20, "tx_id": "d09b829819f5bcd0de442b86f8381a52b4bd46a607c61729bae1e4e94d540b90", "tx_id_display": "d09b829819f5bcd0de442b86f8381a52b4bd46a607c61729bae1e4e94d540b90", "coin_address": "znYvvoaB383eCgAR8Fxpe6z9dXW8WBemvmr", "coin_address_display": "znYvvo****Bemvmr", "add_explorer": "https://explorer.zensystem.io/address/znYvvoaB383eCgAR8Fxpe6z9dXW8WBemvmr", "coin_type": "ZEN", "smart_contract_name": "", "transfer_method": "onchain", "status": "finish", "status_display": "finish", "remark": "", "explorer": "https://explorer.zensystem.io/tx/d09b829819f5bcd0de442b86f8381a52b4bd46a607c61729bae1e4e94d540b90"}], "total": 1, "total_page": 1}, "message": "Success"}
2021/05/23 11:41:14:831 | CoinEx | Error | [1] Deserialize JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable`1[CoinEx.Net.Objects.CoinExDeposit]' 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 'data.has_next', line 1, position 32.

System.ArgumentException 'User-Agent' header must be modified using the appropriate property or method.

Occurs with latest update on GetMarketStatesAsync

Parameter name: name
Source=System
StackTrace:
at System.Net.WebHeaderCollection.ThrowOnRestrictedHeader(String headerName)
at System.Net.WebHeaderCollection.Set(String name, String value)
at System.Collections.Specialized.NameValueCollection.set_Item(String name, String value)
at CoinEx.Net.CoinExClient.ConstructRequest(Uri uri, String method, Dictionary2 parameters, Boolean signed) at CryptoExchange.Net.RestClient.<ExecuteRequest>d__241.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at CoinEx.Net.CoinExClient.<Execute>d__701.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at CoinEx.Net.CoinExClient.<GetMarketStatesAsync>d__32.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at <GetCoinEx_MarketStatesAsync>d__1.MoveNext() in C:

SubscribeOrderUpdate fails

Hi @JKorf ,
when I try to subscribe to order update, the call fails.
Here the log:
[2021/03/22 16:01:37.372, (19, 1)] INFO: 2021/03/22 16:01:37:372 | CoinEx | Debug | Socket 2 connected
[2021/03/22 16:01:37.388, (19, .)] INFO: 2021/03/22 16:01:37:388 | CoinEx | Debug | Socket 2 sending data: {"method":"server.sign","params":["5CC167B173DA4EFD84977E77EB2D0F50","D8DAD20312D59331970626728E3F88CE",1616428897376],"id":28}
[2021/03/22 16:01:37.708, (12, .)] INFO: 2021/03/22 16:01:37:708 | CoinEx | Debug | Socket 2 received data: {"error": null, "result": {"status": "success"}, "id": 28}
[2021/03/22 16:01:37.714, (12, .)] INFO: 2021/03/22 16:01:37:714 | CoinEx | Debug | Authorization completed
[2021/03/22 16:01:37.716, (13, .)] INFO: 2021/03/22 16:01:37:716 | CoinEx | Debug | Socket 2 sending data: {"method":"order.subscribe","params":[["ZECBTC"]],"id":19}
[2021/03/22 16:01:37.918, (28, .)] INFO: 2021/03/22 16:01:37:918 | CoinEx | Debug | Socket 2 received data: {"error": {"code": 1, "message": "invalid argument"}, "result": null, "id": 19}
[2021/03/22 16:01:37.920, (28, .)] INFO: 2021/03/22 16:01:37:920 | CoinEx | Debug | Failed to subscribe: 1 invalid argument
[2021/03/22 16:01:37.926, (23, 2)] INFO: 2021/03/22 16:01:37:926 | CoinEx | Debug | Socket 2 closing

My analyze is that in
return await Subscribe(new CoinExSocketRequest(NextId(), OrderSubject, SubscribeAction, symbols), null, true, internalHandler).ConfigureAwait(false);

symbols is an array of string, but in
public CoinExSocketRequest(int id, string subject, string action, params object[] parameters)
the parameters is an array of one element. And this element is an array of strings.

Hop it help.

Eric

Accept multiple subscription on a single socket

Hi @JKorf
I notice that for CoinEx, you forbid the setting of SocketSubscriptionsCombineTarget.
However, this should work according to CoinEx documentation.

Do you encounter specific problem in this area ?

Thanks.
Eric

websock error

Hi,

I'm getting this sometimes after an invalid state update 5.
image
image

OrderBookUpdate and Checksum

Hi @JKorf ,
I notice that the CoinExSocketOrderBook does not include the checksum field announced in the documentation.

And, as a consequence, the CoinExSymbolOrderBook does not seem to check it.

Do you plan to support this feature of CoinEx?

Thanks
Eric

Place order issue after upgraded

After upgrade, I always get "Error deserializing data" when placing order. It seems there is deserializing issue for result parsing.

Run time environment:

CoinEx.Net version = 3.0.11
CryptoExchange.Net version = 3.0.14
.NetStandard version = 2.0 (It works)
.Net Framework version = 4.6.1 (Error deserializing data)

Extra element in stream for asset make deserialize fails

Hi @JKorf ,
when I subscribe to the asset stream, with SubscribeToBalanceUpdatesAsync
I received a two elements array. The second element is only a single zero.
I don't known why it is this way.

So the code in the handler throw an exception.
I suggest that you accept this case, with something like

            if (data.Length != 1)
            {
                if (data.Length != 2 || (data.Length == 2 && data[1].ToString().Trim() != "0"))
                {
                    log.Write(LogVerbosity.Warning, $"Received unexpected data format for balance update. Expected 1 objects, received {data.Length}. Data: [{string.Join(",", data.Select(s => s.ToString()))}]");
                    return;
                }
            }

Also, I may change the message, as it still refer to order update when it is balance update.

Eric

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.