DigitexConnectorCSharp 0.8.7

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

// Install DigitexConnectorCSharp as a Cake Tool
#tool nuget:?package=DigitexConnectorCSharp&version=0.8.7

Manual for algorithm implementation

There is the example of Interval algorithm.

Every algo is inherited from the class TradingAlgorithm.

What you can do:
    1. subscribe for SpotPriceUpdated, OrderBookUpdated, TraderInfoChanged, 
       NewTrades, Connected, Reconnected and Disconnected events.
    2. take information about your account and current order book.

Account

    This object has the following properties to make implementation easier:
        List<TraderInfo> TraderStatistic - General indicators of a trader from the exchange.
        NotificationDictionary<Guid, OrderBase> Orders - colection of all active orders.
        List<OrderTrailingStop> TrailingOrders - collection of all active trailing stop orders.
        
        

OrderBook

    This object has the following properties and methods to make implementation easier:

        decimal GetBestAskPrice() // Return min ask price if ask.Count is not 0 otherwise null;
        decimal GetBestBidPrice() // Return max bid price if ask.Count is not 0 otherwise null;
        decimal LastTradePrice;
        decimal LastTradeQuantity;
        decimal SpotPrice;
        decimal AdjustedSpotPrice - rounded spot price;
        Dictionary<decimal, decimal> Asks - collection of asks;
        Dictionary<decimal, decimal> Bids - collection of bids;
        DateTime LastFullUpdateTimestamp;

        
    To create an object of this class, use the method 
    Account.TrackSymbol(
        Symbol symbol, 
        Action<OrderBook> spotPriceUpdatedHandler = null, 
        Action<OrderBook> orderBookUpdatedHandler = null, 
        Action<OrderBook> orderBookConnectedHandler = null, 
        Action<OrderBook> orderBookDisconnectedHandler = null,
        Action<OrderBook> orderBookReconnectedHandler = null
    )

    Pass the appropriate delegates to the method for processing orderbook events.
    To make a symbol, use SymbolsContainer.GetSymbol(SymbolName).
    
        

SpotPriceUpdated Receive all updates of spot price. To hanlde this event your method must be like this:

    public void SpotPriceUpdatedHandler(OrderBook orderBook)
        

OrderBookUpdated Receive reference to order book when updates are received. To hanlde this event your method must be like this:

    public void OnOrderBookUpdatedHandler(OrderBook orderBook)
    

TraderInfoUpdated Receive updates of changes in Account. To hanlde this event your method must be like this:

    public void OnTraderInfoHandler(TraderInfo traderInfo);
    

You also need to override the following methods:

    public abstract void Prepare(); - this method adds events subscriptions and called before trading.
    public virtual void SetAlgoArguments(Dictionary<string, string> algoArguments); - (not necessary) if your 
    algorithm has parameters you can initialize them with this methods.
    public virtual List<ModuleState> GetParams(); - (not necessary) returns parameters of algorithm.
    public abstract void OnDispose(); - this method called before dispose.

Example of these methods implementation:

    Prepare:
            Here you can initialize timer or run CancelAllOrders or another.
            
    SetAlgoArguments:
            if (algoArguments.ContainsKey("tradingInterval"))
            { tradingInterval = int.Parse(algoArguments["tradingInterval"]); }
            if (algoArguments.ContainsKey("tradingQuantity"))
            { tradingQuantity = int.Parse(algoArguments["tradingQuantity"]); }
                     
    GetParams:
            Here just return default values of parameters that you need.

How to send messages in algorithm:

In your algo you can call following methods:

    OrderLimit PlaceOrderLimit(
        OrderSide side, 
        decimal quantity, 
        decimal price, 
        Action<OrderBase> orderStatusHandler = null, 
        Action<OrderBase, ErrorCodes> errorHandler = null
    );
    Pass the appropriate delegates to the method for processing order events.
    
    OrderMarket PlaceOrderMarket(
        OrderSide side, 
        decimal quantity, 
        Action<OrderBase> orderStatusHandler = null, 
        Action<OrderBase, ErrorCodes> errorHandler = null
    );
    Pass the appropriate delegates to the method for processing order events.
    
    OrderTrailingStop PlaceOrderTrailingStop(
        OrderSide side, 
        decimal quantity, 
        int lagTicks,
        Action<OrderBase> orderStatusHandler = null, 
        Action<OrderBase, ErrorCodes> errorHandler = null
    );
    Pass the appropriate delegates to the method for processing order events.
        
    The methods listed above return an OrderBase object if successful, otherwise null.
        
    Unknown parameters:
        decimal price - must be greater than 0 and multiple of appropriate Symbol.PriceStep;
        decimal quantity - must be greater than 0 and multiple of appropriate Symbol.QuantityStep;
        OrderSide side - available values are Buy or Sell;
        int lagTicks - number of intervals for which is behind and ahead of the trailing stop;
        Action<OrderBase> orderStatusHandler - when order status is changed and received from the exchange this handler is called;
        Action<OrderBase, ErrorCodes> errorHandler - if you receive some errors from the exchange this handler is called;
        
    Example:
        OrderBase order = PlaceOrderLimit(
            DigitexWire.OrderSide.Sell, 
            quantity, 
            price, 
            OrderStatusHandler, 
            ErrorHandler
        );
        
        public void OrderStatusHandler(OrderBase order)
        {
            Console.WriteLine(order.Status);
        }

        private void ErrorHandler(OrderBase order, DigitexConnector.EngineAPI.ErrorCodes errorCode)
        {
            Console.WriteLine(errorCode);
        }

How to launch you algorithm from your app:

    DigitexConnector.Configuration.Server = Servers.testnet;
    DigitexConnector.Configuration.Token = "<your_API_token>";

    Algorithm = new YourAlgorithmClass();  // must be legacy from abstract class DigitexConnector.Trading.TradingAlgorithm or DigitexConnector.Trading.TradingAdapter
    Algorithm.AccountConnected += AccountConnectedHandler;  // Your implementation of connect to trade channel.
    Algorithm.AccountReconnected += AccountReconnectedHandler;  // Your implementation of reconnect to trade channel.
    Algorithm.AccountDisconnected += AccountDisconnectedHandler;  // Your implementation of disconnect from trade channel.
    Algorithm.TraderInfoUpdated += TraderInfoUpdatedHandler;  // Your implementation of TraderInfo updates.
    Algorithm.SetAlgoArguments(algoArguments);
    Algorithm.Prepare();
    Algorithm.Connect();  // After this you can send messages to exchange and receive trading and data information.

How to work with static class SymbolsContainer

    For load symbols, copy file Symbols.testnet.json or Symbols.mainnet.json from this repository to your project's target directory,
    then rename him to Symbols.json. 
    If you need for load symbols from another file, use SymbolsContainer.UpdateSymbols(string path), 
    where path - path to your file in the appropriate format. 
    For get symbols use SymbolsContainer.GetSymbol(string name) or SymbolsContainer.GetSymbol(int marketId).
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
0.9.0 400 1/13/2021
0.8.7 407 12/25/2020
0.8.5 387 12/5/2020
0.8.3 406 11/19/2020
0.8.2 367 11/18/2020