Git Product home page Git Product logo

liquidquoine.net's Introduction

Icon LiquidQuoine.Net

build-nuget

LiquidQuoine.Net is a .Net wrapper for the liquid.com (by Quoine) API as described on documentation. It includes all features the API provides using clear and readable C# objects including

  • Reading market info
  • Placing and managing orders
  • Reading accounts, balances and funds

If you think something is broken, something is missing or have any questions, please open an Issue


Also check out other exchange API wrappers based on JKorf's abstraction CryptoExchange.Net:

Donations

Donations are greatly appreciated and a motivation to keep improving.

Btc: 1KhYc4yQUHpj6tjpjh64KQ9Ki77N4srCxj
Eth: 0x84f892FaBCE99e3429a4318948B9bBe1434Bbe4A

Installation

Nuget version Nuget downloads

Available on NuGet:

PM> Install-Package LiquidQuoine.Net

To get started with LiquidQuoine.Net first you will need to get the library itself. The easiest way to do this is to install the package into your project using NuGet. Using Visual Studio this can be done in two ways.

Using the package manager

In Visual Studio right click on your solution and select 'Manage NuGet Packages for solution...'. A screen will appear which initially shows the currently installed packages. In the top bit select 'Browse'. This will let you download net package from the NuGet server. In the search box type 'LiquidQuoine.Net' and hit enter. The LiquidQuoine.Net package should come up in the results. After selecting the package you can then on the right hand side select in which projects in your solution the package should install. After you've selected all project you wish to install and use LiquidQuoine.Net in hit 'Install' and the package will be downloaded and added to you projects.

Using the package manager console

In Visual Studio in the top menu select 'Tools' -> 'NuGet Package Manager' -> 'Package Manager Console'. This should open up a command line interface. On top of the interface there is a dropdown menu where you can select the Default Project. This is the project that LiquidQuoine.Net will be installed in. After selecting the correct project type Install-Package LiquidQuoine.Net in the command line interface. This should install the latest version of the package in your project.

After doing either of above steps you should now be ready to actually start using LiquidQuoine.Net.

Getting started

After it's time to actually use it. To get started we have to add the LiquidQuoine.Net namespace: using LiquidQuoine.Net;.

LiquidQuoine.Net provides client to interact with the Liquid.com API. The LiquidQuoineClient provides all rest API calls.

Most API methods are available in two flavors, sync and async:

public void NonAsyncMethod()
{
    using(var client = new LiquidQuoineClient())
    {
        var result = client.GetAllProducts();
    }
}

public async Task AsyncMethod()
{
    using(var client = new LiquidQuoineClient())
    {
        var result2 = await client.GetAllProductsAsync();
    }
}

Response handling

All API requests will respond with an CallResult object. This object contains whether the call was successful, the data returned from the call and an error if the call wasn't successful. As such, one should always check the Success flag when processing a response. For example:

using(var client = new LiquidQuoineClient())
{
	var orderBookByProductId = client.GetOrderBook(5);
	if (priceResult.Success)
		Console.WriteLine($"OrderBook: {orderBookByProductId.Data.BuyPriceLevels[0].Price}");
	else
		Console.WriteLine($"Error: {orderBookByProductId.Error.Message}");
}

Options & Authentication

The default behavior of the clients can be changed by providing options to the constructor, or using the SetDefaultOptions before creating a new client to set options for all new clients. Api credentials can be provided in the options.

Release notes

  • Version 0.0.2 - 04 feb 2019
    • Orders implemented
  • Version 0.0.1 - 03 feb 2019
    • Initial release

liquidquoine.net's People

Contributors

alokym86 avatar dependabot-support avatar dimsumcode avatar ocengiz0 avatar ridicoulous avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

liquidquoine.net's Issues

websocket host to tap.liquid.com

/* javascript */

/////////////////////////////////////////////
// using Liquid Tap with Pusher library
var pusherKey = 'LIQUID'
var pusherChannel = 'price_ladders_cash_btcusd_sell'
var pusherEvent = 'updated'
var pusherTapHost = 'tap.liquid.com'

const tapSocket = new Pusher(pusherKey, {
wsHost: pusherTapHost
});

var channel = tapSocket.subscribe(pusherChannel);
channel.bind(pusherEvent, function (data, metadata) {
console.log("message from Liquid Tap: " + data);
});

/////////////////////////////////////////////
tried to change host,but not working.
tap.liquid.com websockets will make rest api obsolete .and low latency

Orders implementation

  • Create an Order
  • Get an Order
  • Get Orders
  • Cancel an Order
  • Edit a Live Order
  • Get an Order’s Trades

Websocket login problem

Dear Sir,
I have a problem. When I use these codes:
api = new LiquidQuoineClient(new LiquidQuoineClientOptions() { ApiCredentials = credentials });
ws = new LiquidQuoineSocketClient(new LiquidQuoineSocketClientOptions() { ApiCredentials = credentials });
api variable is login correctly but ws variable is not login and authprovider property in ws is null.
Could you help me?

Change MarginOrderStatusConverter.Opened to MarginOrderStatusConverter.Open (and "opened" to "open")

When returning objects of type LiquidQuoineOrderTrade, Liquid API returns the string "open" for the Status property. It does not return the string "opened".

Bug fix: MarginOrderStatusConverter.Opened should be MarginOrderStatusConverter.Open with string value of 'open' instead of 'opened'.

Link to code fix in my fork:
dimsumcode@82fd7ca

Sample JSON returned:

    "claim_quantity": 0.0,
    "close_fee": 0.0,
    "close_pnl": 0.0,
    "close_price": 0.0,
    "close_quantity": 0.0,
    "created_at": "2019-03-30T11:29:24Z",
    "funding_currency": "USD",
    "id": REDACTED,
    "leverage_level": 25,
    "margin_pending": 0.0,
    "margin_used": 8.14581,
    "mtm": null,
    "netout_order_id": null,
    "offset": 14280649125,
    "open_fee": 0.20365,
    "open_pnl": 0.0,
    "open_price": 4072.90535,
    "order_id": REDACTED,
    "product_id": 1,
    "quantity": 0.05,
    "referenced_order_id": null,
    "side": "short",
    "status": "open",  <---- ********* SEE HERE ********
    "stop_loss": 0.0,
    "take_profit": 0.0,
    "total_interest": 0.006923939095,
    "trader_id": REDACTED,
    "trading_account_id": REDACTED,
    "updated_at": "2019-03-30T11:29:25Z"
  }

Need to fix

  • Constructor comments still refer the HuobiClient
  • Constructor shouldnt expose authentication provider directly:
    public LiquidQuoineClient(LiquidQuoineClientOptions exchangeOptions, LiquidQuoineAuthenticationProvider authenticationProvider) : base(exchangeOptions, authenticationProvider)
  • Not all methods have comments
  • Can add some pre-execute checks, for example:
    public async Task<CallResult<LiquidQuoineDefaultResponse>> GetExecutionsAsync Can return max 1000 results, can return error before executing if param > 1000
  • Placeorder throws an exception with certain parameters, should just return an error result

Bug in OrderTypeConverter

Getting error on PlaceMarginOrder() "order type not valid"
Looking at the source of OrderTypeConverter.c, this looks like a bad search/replace bug:

new KeyValuePair<OrderType, string>(OrderType.Limit, "canclimitelled"),

I would commit a change, but can't get to it until this weekend. Just letting you know.

Trades implemetation

  • Get Trades
  • Close a trade
  • Close all trade
  • Update a trade
  • Get a trade’s loans

Other method not found

I try to use the nugget, and got:
System.MissingMethodException: Method not found: 'Void CryptoExchange.Net.Logging.Log.set_Level(CryptoExchange.Net.Logging.LogVerbosity)'.
at LiquidQuoine.Net.LiquidQuoineClient..ctor(LiquidQuoineClientOptions options)

Any idea?
Du to others packages, I use CryptoExchange.Net 4.2.8

Can it be this?

Thanks.
Eric

PlaceMarginOrderAsync execution error

Executing PlaceMarginOrderAsync with OrderDirection option results in an error

await ApiClinet.PlaceMarginOrderAsync(BtcJpyID, OrderSide.Buy, OrderType.Limit, LeverageLevel.Level4, "JPY", (decimal)0.001, 1000000, null, OrderDirection.Netout);

"order_direction": [ "not_valid" ]

I think that OrderDirection will not be converted by OrderDirectionConverter, but it is a post process with enumerated values

OrderType enum , should we have a Stop?

When calling GetOrders() , Liquid sometimes returns orders of type "stop" (if the user set a stop order on the exchange itself). The JsonConverter crashes because there is no OrderType.Stop defined. Should we add a Stop OrderType? Or, better yet, there may be a way to configure the JsonConverter to handle undefined order types in the returned response. Haven't had time to research yet.

Method not found exception in the constructor

Hello,
while constructing the client,
using (var client = new LiquidQuoineClient())
i get the exception :

Method not found: 'Void CryptoExchange.Net.RestClient..ctor(CryptoExchange.Net.Objects.RestClientOptions, CryptoExchange.Net.Authentication.AuthenticationProvider)'. at LiquidQuoine.Net.LiquidQuoineClient..ctor(LiquidQuoineClientOptions options)
at LiquidQuoine.Net.LiquidQuoineClient..ctor()

i just installed the latest NuGet version in VisualStudio 2019

can you please give advise?

Test orders placing

  • client.PlaceOrder()
  • client.PlaceMarginOrder()
  • client.CancelOrder()
  • client.EditOrder()
  • client.GetOrderTrades()
  • client.GetOrderExecutions()

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.