Script Bots (C#)

The Script Bot is able to read and execute an external C# script. The scripts are fully customizable. There is an API available to gather the information needed to create your own custom bot.

Please note that the built-in Script Editor does not work with C# scripts. Please use your preferred text editor or IDE to create your own or edit the ones provided here.

Restriction

Limit orders only (more order types coming) Can only trade on one market at a time.

About

The script needs to be written in C# .NET 4.5 and are based on OOP. A few examples are listed below.

Performance

Relies heavily on user-defined parameters.

Parameter

Coin Position

This is the start position of the bot. If your assets are currently in BTC select BTC. If they are in USD, select USD. The value has no relation to the trade amount currency.

Trade Amount

The allocated amount for the bot to use.

Fee

Some exchanges offer different fees for some order types. This will adjust the profit calculation.

Script Settings

All scripts located in the HTS/ScriptBots folder will be listed here. The script selected will be used in the bot. When the script has external settings they will be listed below Bot Settings.

Script API

public interface IScriptBotAPI
{
    #region Information
    /// <summary>
    /// Get all available price sources
    /// </summary>
    List<string> GetAllPriceSources();

    /// <summary>
    /// Get all active price sources
    /// </summary>
    /// <returns></returns>
    List<string> GetEnabledPriceSources();

    /// <summary>
    /// Get all markets of a specific price source.
    /// </summary>
    /// <param name="pricesourceName"></param>
    /// <returns>
    /// Returns the short name of the markets
    /// - BTC/USD
    /// - BTC/USD (WEEKLY)
    /// </returns>
    List<string> GetPriceMarkets(string pricesourceName);
    #endregion

    #region Price Data
    /// <summary>
    /// Get open, high, low, close, asks, bids and volume data of a specific market.
    /// </summary>
    /// <param name="pricesourceName">Price source as returned by GetEnabledPriceSources()</param>
    /// <param name="primaryCurrency">Primary currency as returned by GetPriceMarkets()</param>
    /// <param name="secondaryCurrency">Secondary currency as returned by GetPriceMarkets()</param>
    /// <param name="contractName">Contract name as returned by GetPriceMarkets(). Leave blank if the markets hasn't got a contract name.</param>
    /// <param name="interval">The interval of the ticks.</param>
    /// <param name="ticksBack"></param>
    /// <returns></returns>
    IPriceInstrument GetPriceInstrument(string pricesourceName, string primaryCurrency, string secondaryCurrency, string contractName, int interval, int ticksBack);

    /// <summary>
    /// Get the last known price of a specific market.
    /// </summary>
    /// <param name="pricesourceName">Price source as returned by GetEnabledPriceSources()</param>
    /// <param name="primaryCurrency">Primary currency as returned by GetPriceMarkets()</param>
    /// <param name="secondaryCurrency">Secondary currency as returned by GetPriceMarkets()</param>
    /// <param name="contractName">Contract name as returned by GetPriceMarkets(). Leave blank if the markets hasn't got a contract name.</param>
    /// <returns>PriceTick with current price data</returns>
    PriceTick GetPriceTick(string pricesourceName, string primaryCurrency, string secondaryCurrency, string contractName);

    /// <summary>
    /// Get the last known minute price of a specific market.
    /// </summary>
    /// <param name="pricesourceName">Prices ource as returned by GetEnabledPriceSources()</param>
    /// <param name="primaryCurrency">Primary currency as returned by GetPriceMarkets()</param>
    /// <param name="secondaryCurrency">Secondary currency as returned by GetPriceMarkets()</param>
    /// <param name="contractName">Contract name as returned by GetPriceMarkets(). Leave blank if the markets hasn't got a contract name.</param>
    /// <returns>PriceTick with current minute price data</returns>
    PriceTick GetMinutePriceTick(string pricesourceName, string primaryCurrency, string secondaryCurrency, string contractName);
    #endregion

    #region Order Control
    /// <summary>
    /// Cancel an open order
    /// </summary>
    /// <param name="orderId">Open Order ID as returned by the place order calls</param>
    void CancelOrder(string orderId);

    /// <summary>
    /// Place an buy order
    /// </summary>
    /// <param name="amount">Amount of the order</param>
    /// <param name="price">Price of the orders</param>
    /// <returns>Order ID</returns>
    string PlaceBuyOrder(decimal amount, decimal price);

    /// <summary>
    /// Place an sell order
    /// </summary>
    /// <param name="amount">Amount of the order</param>
    /// <param name="price">Price of the order</param>
    /// <returns>Order ID</returns>
    string PlaceSellOrder(decimal amount, decimal price);

    /// <summary>
    /// Place an order to go long.
    /// </summary>
    /// <param name="amount">Amount of the order</param>
    /// <param name="price">Price of the order</param>
    /// <returns>Order ID</returns>
    string PlaceGoLongOrder(decimal amount, decimal price);

    /// <summary>
    /// Place an order to exit a long.
    /// </summary>
    /// <param name="amount">Amount of the order</param>
    /// <param name="price">Price of the order</param>
    /// <returns>Order ID</returns>
    string PlaceExitLongOrder(decimal amount, decimal price);

    /// <summary>
    /// Place an order to go short.
    /// </summary>
    /// <param name="amount">Amount of the order</param>
    /// <param name="price">Price of the order</param>
    /// <returns>Order ID</returns>
    string PlaceGoShortOrder(decimal amount, decimal price);

    /// <summary>
    /// Place an order to exit a short.
    /// </summary>
    /// <param name="amount">Amount of the order</param>
    /// <param name="price">Price of the order</param>
    /// <returns>Order ID</returns>
    string PlaceExitShortOrder(decimal amount, decimal price);

    /// <summary>
    /// Returns the status of the order
    /// </summary>
    /// <param name="orderId">Open Order ID as returned by the place order calls</param>
    /// <returns></returns>
    enumScriptOrderStatus GetOrderStatus(string orderId);
    #endregion

    #region Position Control
    /// <summary>
    /// Switch the bot's position to bought without executing an order.
    /// </summary>
    void SetCoinPositionToBought();

    /// <summary>
    /// Switch the bot's position to sold without executing an order.
    /// </summary>
    void SetCoinPositionToSold();

    /// <summary>
    /// Switch the bot's position to no position without executing an order.
    /// </summary>
    void SetCoinPositionToNoPosition();

    /// <summary>
    /// Switch the bot's position to a long without executing an order.
    /// </summary>
    void SetCoinPositionToLong();

    /// <summary>
    /// Switch the bot's position to a short without executing an order.
    /// </summary>
    void SetCoinPositionToShort();
    #endregion

    #region Warnings
    /// <summary>
    /// Show a trade amount error in the UI. The error will reset every update.
    /// </summary>
    void SignalWalletAlert();
    #endregion
}

public enum enumScriptOrderStatus
{
    Open,
    Cancelled,
    Finished,
    OrderUnknown
}

Last updated