Bitmex.NET 1.0.1.26810

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bitmex.NET --version 1.0.1.26810
NuGet\Install-Package Bitmex.NET -Version 1.0.1.26810
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="1.0.1.26810" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bitmex.NET --version 1.0.1.26810
#r "nuget: Bitmex.NET, 1.0.1.26810"
#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=1.0.1.26810

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

Bitmex.NET

Wrapper for BitMEX.com REST API

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 Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 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,516 6/21/2019
2.0.84 1,427 3/31/2019
2.0.82 2,168 11/26/2018
2.0.79 767 11/19/2018
2.0.70 762 11/13/2018
2.0.67 915 10/29/2018
2.0.66 709 10/26/2018
2.0.65 1,250 9/2/2018
2.0.64 924 8/26/2018
2.0.58 925 8/5/2018
2.0.43 883 7/22/2018
2.0.41 867 7/21/2018
2.0.39 971 7/19/2018
2.0.30 890 7/18/2018
2.0.27 853 7/18/2018
2.0.24 818 7/4/2018
2.0.2.8524 968 5/24/2018
1.0.3.26546 977 5/13/2018
1.0.2.25211 985 4/30/2018
1.0.1.26810 982 3/21/2018
1.0.0.32297 1,011 3/20/2018

Initial release with built-in the most important API to implement a bot