Bitmex.NET 2.0.27

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bitmex.NET --version 2.0.27                
NuGet\Install-Package Bitmex.NET -Version 2.0.27                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitmex.NET" Version="2.0.27" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bitmex.NET --version 2.0.27                
#r "nuget: Bitmex.NET, 2.0.27"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Bitmex.NET as a Cake Addin
#addin nuget:?package=Bitmex.NET&version=2.0.27

// Install Bitmex.NET as a Cake Tool
#tool nuget:?package=Bitmex.NET&version=2.0.27                

Bitmex.NET Build Status

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). Example

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 Example:

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 integration tests

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 here

Integration Tests

You will find a live example for all the implemented APIs within integration tests project here

Other

API was taken from testnet.bitmex.com

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.99 6,876 6/21/2019
2.0.84 1,455 3/31/2019
2.0.82 2,203 11/26/2018
2.0.79 797 11/19/2018
2.0.70 791 11/13/2018
2.0.67 952 10/29/2018
2.0.66 747 10/26/2018
2.0.65 1,295 9/2/2018
2.0.64 958 8/26/2018
2.0.58 957 8/5/2018
2.0.43 911 7/22/2018
2.0.41 895 7/21/2018
2.0.39 1,001 7/19/2018
2.0.30 917 7/18/2018
2.0.27 881 7/18/2018
2.0.24 846 7/4/2018
2.0.2.8524 997 5/24/2018
1.0.3.26546 1,008 5/13/2018
1.0.2.25211 1,014 4/30/2018
1.0.1.26810 1,011 3/21/2018
1.0.0.32297 1,037 3/20/2018