Bitmex.NET
2.0.39
Wrapper for BitMEX.com API (REST & WebSocket)
See the version list below for details.
Install-Package Bitmex.NET -Version 2.0.39
dotnet add package Bitmex.NET --version 2.0.39
<PackageReference Include="Bitmex.NET" Version="2.0.39" />
paket add Bitmex.NET --version 2.0.39
Bitmex.NET 
Wrapper for BitMEX.com REST API
Issue reporting
Recently Bitmex API has been changed. Now it requires the NONCE value in seconds rather than milliseconds plus authentification headers have been changed for REST and WebSocket both. It would be much appreciated if the community raised a bug in the repository to fix it immediately.
From my side, I will try to schedule the integration tests to be aware of the changes in API and such crucial things as authentification
Quick Start
Install NuGet package Install-Package Bitmex.NET
Create default API service:
First approach, creating default instance
var bitmexAuthorization = new BitmexAuthorization()
{
BitmexEnvironment = Bitmex.NET.Models.BitmexEnvironment.Test,
Key = "your api key",
Secret = "your api secret"
};
var bitmexApiService = BitmexApiService.CreateDefaultApi(bitmexAuthorization);
Another, registering in a DI container (e.g. Unity).
Container.RegisterType<IBitmexApiProxy, BitmexApiProxy>();
Container.RegisterType<IBitmexApiService, BitmexApiService>();
var authorization = new BitmexAuthorization
{
BitmexEnvironment = Bitmex.NET.Models.BitmexEnvironment.Test,
Key = "your api key",
Secret = "your api secret"
};
Container.RegisterInstance<IBitmexAuthorization>(authorization);
place an order :
private async void Sell()
{
var posOrderParams = OrderPOSTRequestParams.CreateSimpleMarket("XBTUSD", Size, OrderSide.Sell);
await _bitmexApiService.Execute(BitmexApiUrls.Order.PostOrder, posOrderParams).ContinueWith(ProcessPostOrderResult);
}
Extensibility
I haven't implemented and tested all the existing methods yet so that you might want to call BitMEX APIs that haven't been done so far. To make you be able to call all APIs using the existing service I've tried to make the classes extensible.
So...
To implement your own API method please create your own parameters class (or use existing) deriving it from QueryStringParams
(for GET requests) or JsonQueryParams
(for POST/PUT/DELETE requests) and a class for requests (or use existing)
private class SomeQueryStringParams : QueryStringParams
{
[DisplayName("val")]
public string Value { get; set; }
}
private class SomeJsonParams : QueryJsonParams
{
[JsonProperty("symbol")]
public string Symbol { get; set; }
}
private class AResult
{
[JsonProperty("value")]
public string Value { get; set; }
}
Call it
var result = await bitmexApiService.Execute(new ApiActionAttributes<SomeJsonParams, AResult>("anApiMethod", HttpMethods.POST), new SomeJsonParams(){Symbol = "XBTUSD"});
// if the method returns an array of objects
var result = await bitmexApiService.Execute(new ApiActionAttributes<SomeJsonParams, List<AResult>>("anApiMethod", HttpMethods.POST), new SomeJsonParams(){Symbol = "XBTUSD"});
Progress
The following methods were implemented and covered with the
Method|REST API Method
------------|------------
GET|execution
GET|execution/tradeHistory
GET|instrument
GET|instrument/active
GET|instrument/activeAndIndices
GET|instrument/activeIntervals
GET|instrument/compositeIndex
GET|instrument/indices
GET |order
PUT |order
POST |order
DELETE |order
DELETE |order/all
PUT |order/bulk
POST |order/bulk
POST |order/cancelAllAfter
POST |order/closePosition
GET |orderBook/L2|yes
GET |position|yes
POST |position/isolate
POST |position/leverage
POST |position/riskLimit
POST |position/transferMargin
GET |quote
GET |quote/bucketed
GET |trade
GET |trade/bucketed
Examples
Please see example of simple Buy&Sell application
Integration Tests
You will find a live example for all the implemented APIs within integration tests project
Other
API was taken from
Bitmex.NET 
Wrapper for BitMEX.com REST API
Issue reporting
Recently Bitmex API has been changed. Now it requires the NONCE value in seconds rather than milliseconds plus authentification headers have been changed for REST and WebSocket both. It would be much appreciated if the community raised a bug in the repository to fix it immediately.
From my side, I will try to schedule the integration tests to be aware of the changes in API and such crucial things as authentification
Quick Start
Install NuGet package Install-Package Bitmex.NET
Create default API service:
First approach, creating default instance
var bitmexAuthorization = new BitmexAuthorization()
{
BitmexEnvironment = Bitmex.NET.Models.BitmexEnvironment.Test,
Key = "your api key",
Secret = "your api secret"
};
var bitmexApiService = BitmexApiService.CreateDefaultApi(bitmexAuthorization);
Another, registering in a DI container (e.g. Unity).
Container.RegisterType<IBitmexApiProxy, BitmexApiProxy>();
Container.RegisterType<IBitmexApiService, BitmexApiService>();
var authorization = new BitmexAuthorization
{
BitmexEnvironment = Bitmex.NET.Models.BitmexEnvironment.Test,
Key = "your api key",
Secret = "your api secret"
};
Container.RegisterInstance<IBitmexAuthorization>(authorization);
place an order :
private async void Sell()
{
var posOrderParams = OrderPOSTRequestParams.CreateSimpleMarket("XBTUSD", Size, OrderSide.Sell);
await _bitmexApiService.Execute(BitmexApiUrls.Order.PostOrder, posOrderParams).ContinueWith(ProcessPostOrderResult);
}
Extensibility
I haven't implemented and tested all the existing methods yet so that you might want to call BitMEX APIs that haven't been done so far. To make you be able to call all APIs using the existing service I've tried to make the classes extensible.
So...
To implement your own API method please create your own parameters class (or use existing) deriving it from QueryStringParams
(for GET requests) or JsonQueryParams
(for POST/PUT/DELETE requests) and a class for requests (or use existing)
private class SomeQueryStringParams : QueryStringParams
{
[DisplayName("val")]
public string Value { get; set; }
}
private class SomeJsonParams : QueryJsonParams
{
[JsonProperty("symbol")]
public string Symbol { get; set; }
}
private class AResult
{
[JsonProperty("value")]
public string Value { get; set; }
}
Call it
var result = await bitmexApiService.Execute(new ApiActionAttributes<SomeJsonParams, AResult>("anApiMethod", HttpMethods.POST), new SomeJsonParams(){Symbol = "XBTUSD"});
// if the method returns an array of objects
var result = await bitmexApiService.Execute(new ApiActionAttributes<SomeJsonParams, List<AResult>>("anApiMethod", HttpMethods.POST), new SomeJsonParams(){Symbol = "XBTUSD"});
Progress
The following methods were implemented and covered with the
Method|REST API Method
------------|------------
GET|execution
GET|execution/tradeHistory
GET|instrument
GET|instrument/active
GET|instrument/activeAndIndices
GET|instrument/activeIntervals
GET|instrument/compositeIndex
GET|instrument/indices
GET |order
PUT |order
POST |order
DELETE |order
DELETE |order/all
PUT |order/bulk
POST |order/bulk
POST |order/cancelAllAfter
POST |order/closePosition
GET |orderBook/L2|yes
GET |position|yes
POST |position/isolate
POST |position/leverage
POST |position/riskLimit
POST |position/transferMargin
GET |quote
GET |quote/bucketed
GET |trade
GET |trade/bucketed
Examples
Please see example of simple Buy&Sell application
Integration Tests
You will find a live example for all the implemented APIs within integration tests project
Other
API was taken from
Release Notes
See release notes here https://github.com/semashkinvg/Bitmex.NET/blob/master/releasenotes.md
Dependencies
-
.NETStandard 2.0
- Newtonsoft.Json (>= 11.0.2)
- WebSocket4Net (>= 0.15.2)
GitHub Usage
This package is not used by any popular GitHub repositories.
Version History
Version | Downloads | Last updated | ||
---|---|---|---|---|
2.0.99 | 1,041 | 6/21/2019 | ||
2.0.84 | 932 | 3/31/2019 | ||
2.0.82 | 1,597 | 11/26/2018 | ||
2.0.79 | 196 | 11/19/2018 | ||
2.0.70 | 194 | 11/13/2018 | ||
2.0.67 | 357 | 10/29/2018 | ||
2.0.66 | 183 | 10/26/2018 | ||
2.0.65 | 609 | 9/2/2018 | ||
2.0.64 | 282 | 8/26/2018 | ||
2.0.58 | 296 | 8/5/2018 | ||
2.0.43 | 267 | 7/22/2018 | ||
2.0.41 | 236 | 7/21/2018 | ||
2.0.39 | 257 | 7/19/2018 | ||
2.0.30 | 222 | 7/18/2018 | ||
2.0.27 | 199 | 7/18/2018 | ||
2.0.24 | 224 | 7/4/2018 | ||
2.0.2.8524 | 238 | 5/24/2018 | ||
1.0.3.26546 | 221 | 5/13/2018 | ||
1.0.2.25211 | 233 | 4/30/2018 | ||
1.0.1.26810 | 282 | 3/21/2018 | ||
1.0.0.32297 | 306 | 3/20/2018 |