Scripted Driver

Custom Scripted Driver

HaasOnline Trade Server provides the ability to create and maintain your own custom exchange driver.


  • Only 1 driver per instance
  • Spot & Leverage supported
  • No simulated accounts supported
  • .NET Framework v4.5
  • Use RestSharp v105.2.3 for API calls.
  • Place the file in "HTS/ScriptDriver" and rename it to ExchangeDriver.cs



public interface IScriptApi
void Connect();
void Disconnect();
int PollingSpeed { get; }
ScriptedExchangeType PlatformType { get; }
bool HasTickerBatchCalls { get; }
bool HasOrderbookBatchCalls { get; }
bool HasLastTradesBatchCalls { get; }
bool HasPrivateKey { get; set; }
bool HasExtraPrivateKey { get; set; }
string PingAddress { get; set; }
void SetCredentials(string publicKey, string privateKey, string extra);
event EventHandler<string> Error;
event EventHandler<IScriptTick> PriceUpdate;
event EventHandler<IScriptOrderbook> OrderbookUpdate;
event EventHandler<IScriptOrderbook> OrderbookCorrection;
event EventHandler<IScriptLastTrades> LastTradesUpdate;
event EventHandler<Dictionary<string, decimal>> WalletUpdate;
event EventHandler<Dictionary<string, decimal>> WalletCorrection;
event EventHandler<List<IScriptPosition>> PositionListUpdate;
event EventHandler<List<IScriptPosition>> PositionCorrection;
event EventHandler<List<IScriptOrder>> OpenOrderListUpdate;
event EventHandler<List<IScriptOrder>> OpenOrderCorrection;
IScriptTick GetTicker(IScriptMarket market);
List<IScriptTick> GetAllTickers();
IScriptOrderbook GetOrderbook(IScriptMarket market);
List<IScriptOrderbook> GetAllOrderbooks();
IScriptLastTrades GetLastTrades(IScriptMarket market);
List<IScriptLastTrades> GetAllLastTrades();
Dictionary<string, decimal> GetWallet();
IScriptMarginWallet GetMarginWallet();
List<IScriptOrder> GetOpenOrders();
List<IScriptPosition> GetPositions();
List<IScriptOrder> GetTradeHistory();
string PlaceOrder(IScriptMarket market, ScriptedOrderType direction, decimal price, decimal amount, bool isMarketOrder, string template = "", bool hiddenOrder = false);
string PlaceOrder(IScriptMarket market, ScriptedLeverageOrderType direction, decimal price, decimal amount, decimal leverage, bool isMarketOrder, string template = "", bool isHiddenOrder = false);
bool CancelOrder(IScriptMarket market, string orderId, bool isBuyOrder);
decimal GetContractValue(IScriptMarket pair, decimal price);
IScriptOrder GetOrderDetails(string orderId, IScriptMarket market, decimal price, decimal amount, bool isBuyOrder);
ScriptedOrderStatus GetOrderStatus(string orderId, IScriptMarket scriptMarket, decimal price, decimal amount, bool isBuyOrder);
List<IScriptMarket> GetMarkets();
List<IScriptMarket> GetMarginMarkets();
decimal GetMaxPositionAmount(IScriptMarket pair, decimal tickClose, Dictionary<string, decimal> wallet, decimal leverage, ScriptedLeverageSide scriptedLeverageSide);
Last modified 5yr ago