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

1
public interface IScriptBotAPI
2
{
3
#region Information
4
/// <summary>
5
/// Get all available price sources
6
/// </summary>
7
List<string> GetAllPriceSources();
8
9
/// <summary>
10
/// Get all active price sources
11
/// </summary>
12
/// <returns></returns>
13
List<string> GetEnabledPriceSources();
14
15
/// <summary>
16
/// Get all markets of a specific price source.
17
/// </summary>
18
/// <param name="pricesourceName"></param>
19
/// <returns>
20
/// Returns the short name of the markets
21
/// - BTC/USD
22
/// - BTC/USD (WEEKLY)
23
/// </returns>
24
List<string> GetPriceMarkets(string pricesourceName);
25
#endregion
26
27
#region Price Data
28
/// <summary>
29
/// Get open, high, low, close, asks, bids and volume data of a specific market.
30
/// </summary>
31
/// <param name="pricesourceName">Price source as returned by GetEnabledPriceSources()</param>
32
/// <param name="primaryCurrency">Primary currency as returned by GetPriceMarkets()</param>
33
/// <param name="secondaryCurrency">Secondary currency as returned by GetPriceMarkets()</param>
34
/// <param name="contractName">Contract name as returned by GetPriceMarkets(). Leave blank if the markets hasn't got a contract name.</param>
35
/// <param name="interval">The interval of the ticks.</param>
36
/// <param name="ticksBack"></param>
37
/// <returns></returns>
38
IPriceInstrument GetPriceInstrument(string pricesourceName, string primaryCurrency, string secondaryCurrency, string contractName, int interval, int ticksBack);
39
40
/// <summary>
41
/// Get the last known price of a specific market.
42
/// </summary>
43
/// <param name="pricesourceName">Price source as returned by GetEnabledPriceSources()</param>
44
/// <param name="primaryCurrency">Primary currency as returned by GetPriceMarkets()</param>
45
/// <param name="secondaryCurrency">Secondary currency as returned by GetPriceMarkets()</param>
46
/// <param name="contractName">Contract name as returned by GetPriceMarkets(). Leave blank if the markets hasn't got a contract name.</param>
47
/// <returns>PriceTick with current price data</returns>
48
PriceTick GetPriceTick(string pricesourceName, string primaryCurrency, string secondaryCurrency, string contractName);
49
50
/// <summary>
51
/// Get the last known minute price of a specific market.
52
/// </summary>
53
/// <param name="pricesourceName">Prices ource as returned by GetEnabledPriceSources()</param>
54
/// <param name="primaryCurrency">Primary currency as returned by GetPriceMarkets()</param>
55
/// <param name="secondaryCurrency">Secondary currency as returned by GetPriceMarkets()</param>
56
/// <param name="contractName">Contract name as returned by GetPriceMarkets(). Leave blank if the markets hasn't got a contract name.</param>
57
/// <returns>PriceTick with current minute price data</returns>
58
PriceTick GetMinutePriceTick(string pricesourceName, string primaryCurrency, string secondaryCurrency, string contractName);
59
#endregion
60
61
#region Order Control
62
/// <summary>
63
/// Cancel an open order
64
/// </summary>
65
/// <param name="orderId">Open Order ID as returned by the place order calls</param>
66
void CancelOrder(string orderId);
67
68
/// <summary>
69
/// Place an buy order
70
/// </summary>
71
/// <param name="amount">Amount of the order</param>
72
/// <param name="price">Price of the orders</param>
73
/// <returns>Order ID</returns>
74
string PlaceBuyOrder(decimal amount, decimal price);
75
76
/// <summary>
77
/// Place an sell order
78
/// </summary>
79
/// <param name="amount">Amount of the order</param>
80
/// <param name="price">Price of the order</param>
81
/// <returns>Order ID</returns>
82
string PlaceSellOrder(decimal amount, decimal price);
83
84
/// <summary>
85
/// Place an order to go long.
86
/// </summary>
87
/// <param name="amount">Amount of the order</param>
88
/// <param name="price">Price of the order</param>
89
/// <returns>Order ID</returns>
90
string PlaceGoLongOrder(decimal amount, decimal price);
91
92
/// <summary>
93
/// Place an order to exit a long.
94
/// </summary>
95
/// <param name="amount">Amount of the order</param>
96
/// <param name="price">Price of the order</param>
97
/// <returns>Order ID</returns>
98
string PlaceExitLongOrder(decimal amount, decimal price);
99
100
/// <summary>
101
/// Place an order to go short.
102
/// </summary>
103
/// <param name="amount">Amount of the order</param>
104
/// <param name="price">Price of the order</param>
105
/// <returns>Order ID</returns>
106
string PlaceGoShortOrder(decimal amount, decimal price);
107
108
/// <summary>
109
/// Place an order to exit a short.
110
/// </summary>
111
/// <param name="amount">Amount of the order</param>
112
/// <param name="price">Price of the order</param>
113
/// <returns>Order ID</returns>
114
string PlaceExitShortOrder(decimal amount, decimal price);
115
116
/// <summary>
117
/// Returns the status of the order
118
/// </summary>
119
/// <param name="orderId">Open Order ID as returned by the place order calls</param>
120
/// <returns></returns>
121
enumScriptOrderStatus GetOrderStatus(string orderId);
122
#endregion
123
124
#region Position Control
125
/// <summary>
126
/// Switch the bot's position to bought without executing an order.
127
/// </summary>
128
void SetCoinPositionToBought();
129
130
/// <summary>
131
/// Switch the bot's position to sold without executing an order.
132
/// </summary>
133
void SetCoinPositionToSold();
134
135
/// <summary>
136
/// Switch the bot's position to no position without executing an order.
137
/// </summary>
138
void SetCoinPositionToNoPosition();
139
140
/// <summary>
141
/// Switch the bot's position to a long without executing an order.
142
/// </summary>
143
void SetCoinPositionToLong();
144
145
/// <summary>
146
/// Switch the bot's position to a short without executing an order.
147
/// </summary>
148
void SetCoinPositionToShort();
149
#endregion
150
151
#region Warnings
152
/// <summary>
153
/// Show a trade amount error in the UI. The error will reset every update.
154
/// </summary>
155
void SignalWalletAlert();
156
#endregion
157
}
158
159
public enum enumScriptOrderStatus
160
{
161
Open,
162
Cancelled,
163
Finished,
164
OrderUnknown
165
}
Copied!
Last modified 1yr ago