Scripted Driver

Custom Scripted Driver

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

Requirements

    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

Examples

GitHub - Haasonline/Haasonline.Public.ExchangeDrivers: Examples of the scripted API drivers for Haasonline Tradeserver
GitHub

Interface

1
public interface IScriptApi
2
{
3
void Connect();
4
void Disconnect();
5
int PollingSpeed { get; }
6
7
ScriptedExchangeType PlatformType { get; }
8
9
bool HasTickerBatchCalls { get; }
10
bool HasOrderbookBatchCalls { get; }
11
bool HasLastTradesBatchCalls { get; }
12
13
bool HasPrivateKey { get; set; }
14
bool HasExtraPrivateKey { get; set; }
15
string PingAddress { get; set; }
16
17
void SetCredentials(string publicKey, string privateKey, string extra);
18
19
event EventHandler<string> Error;
20
21
event EventHandler<IScriptTick> PriceUpdate;
22
event EventHandler<IScriptOrderbook> OrderbookUpdate;
23
event EventHandler<IScriptOrderbook> OrderbookCorrection;
24
25
event EventHandler<IScriptLastTrades> LastTradesUpdate;
26
27
event EventHandler<Dictionary<string, decimal>> WalletUpdate;
28
event EventHandler<Dictionary<string, decimal>> WalletCorrection;
29
30
event EventHandler<List<IScriptPosition>> PositionListUpdate;
31
event EventHandler<List<IScriptPosition>> PositionCorrection;
32
33
event EventHandler<List<IScriptOrder>> OpenOrderListUpdate;
34
event EventHandler<List<IScriptOrder>> OpenOrderCorrection;
35
36
IScriptTick GetTicker(IScriptMarket market);
37
List<IScriptTick> GetAllTickers();
38
39
IScriptOrderbook GetOrderbook(IScriptMarket market);
40
List<IScriptOrderbook> GetAllOrderbooks();
41
42
IScriptLastTrades GetLastTrades(IScriptMarket market);
43
List<IScriptLastTrades> GetAllLastTrades();
44
45
Dictionary<string, decimal> GetWallet();
46
IScriptMarginWallet GetMarginWallet();
47
48
List<IScriptOrder> GetOpenOrders();
49
List<IScriptPosition> GetPositions();
50
List<IScriptOrder> GetTradeHistory();
51
52
string PlaceOrder(IScriptMarket market, ScriptedOrderType direction, decimal price, decimal amount, bool isMarketOrder, string template = "", bool hiddenOrder = false);
53
string PlaceOrder(IScriptMarket market, ScriptedLeverageOrderType direction, decimal price, decimal amount, decimal leverage, bool isMarketOrder, string template = "", bool isHiddenOrder = false);
54
55
bool CancelOrder(IScriptMarket market, string orderId, bool isBuyOrder);
56
57
decimal GetContractValue(IScriptMarket pair, decimal price);
58
59
IScriptOrder GetOrderDetails(string orderId, IScriptMarket market, decimal price, decimal amount, bool isBuyOrder);
60
ScriptedOrderStatus GetOrderStatus(string orderId, IScriptMarket scriptMarket, decimal price, decimal amount, bool isBuyOrder);
61
List<IScriptMarket> GetMarkets();
62
List<IScriptMarket> GetMarginMarkets();
63
decimal GetMaxPositionAmount(IScriptMarket pair, decimal tickClose, Dictionary<string, decimal> wallet, decimal leverage, ScriptedLeverageSide scriptedLeverageSide);
64
}
Copied!
Last modified 2yr ago