Skip to content

Commit a27c8c2

Browse files
author
nicehashdev
committed
Bug fixes
- Few bug fixes regarding price adjustments - Price decrease every 10 minutes - Removed bin folder
1 parent 08444fa commit a27c8c2

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

bin/NiceHashBot_1.0.0.0.zip

-213 KB
Binary file not shown.

bin/NiceHashBot_1.0.1.0.zip

-213 KB
Binary file not shown.

bin/NiceHashBot_1.0.1.1.zip

-214 KB
Binary file not shown.

src/NiceHashBot/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.1.0")]
36-
[assembly: AssemblyFileVersion("1.0.1.0")]
35+
[assembly: AssemblyVersion("1.0.1.2")]
36+
[assembly: AssemblyFileVersion("1.0.1.2")]

src/NiceHashBotLib/APIWrapper.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ public class APIWrapper
2525
/// </summary>
2626
public readonly static string[] SERVICE_NAME = { "NiceHash", "WestHash" };
2727

28-
28+
/// <summary>
29+
/// Names for algorithms.
30+
/// </summary>
2931
public readonly static string[] ALGORITHM_NAME = { "Scrypt", "SHA256", "Scrypt-A.-Nf.", "X11", "X13", "Keccak", "X15", "Nist5", "NeoScrypt", "Lyra2RE" };
3032

3133
/// <summary>
3234
/// Total number of algorithms.
3335
/// </summary>
34-
public readonly static int NumberOfAlgorithms = 10;
36+
public readonly static int NUMBER_OF_ALGORITHMS = 10;
3537

3638
/// <summary>
3739
/// Price decrease steps for all algorithms.
3840
/// </summary>
39-
public readonly static double[] PriceDecreaseSteps = { -0.001, -0.0001, -0.002, -0.001, -0.001, -0.0001, -0.001, -0.001, -0.01, -0.002 };
41+
public readonly static double[] PRICE_DECREASE_STEP = { -0.001, -0.0001, -0.002, -0.001, -0.001, -0.0001, -0.001, -0.001, -0.01, -0.002 };
42+
43+
/// <summary>
44+
/// Price decrase interval - it is 10 minutes.
45+
/// </summary>
46+
public readonly static TimeSpan PRICE_DECREASE_INTERVAL = new TimeSpan(0, 10, 1);
4047

4148
/// <summary>
4249
/// API ID.
@@ -63,8 +70,8 @@ public class APIWrapper
6370
#region PRIVATE_PROPERTIES
6471

6572
private static object CacheLock = new object();
66-
private static CachedOrderList[,] CachedOList = new CachedOrderList[SERVICE_LOCATION.Length, NumberOfAlgorithms];
67-
private static CachedStats[,] CachedSList = new CachedStats[SERVICE_LOCATION.Length, NumberOfAlgorithms];
73+
private static CachedOrderList[,] CachedOList = new CachedOrderList[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];
74+
private static CachedStats[,] CachedSList = new CachedStats[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];
6875

6976
#endregion
7077

src/NiceHashBotLib/OrderInstance.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class OrderInstance
2020
private Order LastOrderStats;
2121
private double StartingPrice;
2222
private double StartingAmount;
23+
private DateTime DecreaseTime;
2324

2425
#endregion
2526

@@ -47,6 +48,7 @@ public OrderInstance(int SL, int Algo, double MaximalPrice, double Limit, Pool P
4748
OrderID = ID;
4849
StartingPrice = Price;
4950
StartingAmount = Amount;
51+
DecreaseTime = DateTime.Now - APIWrapper.PRICE_DECREASE_INTERVAL;
5052

5153
OrderThread = new Thread(ThreadRun);
5254
OrderThread.Start();
@@ -233,8 +235,13 @@ private double GetMinimalNeededPrice(Order[] AllOrders, double TotalSpeed)
233235

234236
private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice)
235237
{
236-
// Do not make price higher if we are already on top of the list
237-
if (AllOrders[0] == MyOrder) return false;
238+
// Do not make price higher if we are already on top of the list (first alive).
239+
foreach (Order O in AllOrders)
240+
{
241+
if (!O.Alive) continue;
242+
if (O == MyOrder) return false;
243+
else break;
244+
}
238245

239246
// Do not increase price, if we already have price higher or equal compared to minimal price.
240247
if (MyOrder.Price >= MinimalPrice) return false;
@@ -245,27 +252,39 @@ private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice
245252
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MinimalPrice.ToString("F4"));
246253
double NewP = MyOrder.SetPrice(MinimalPrice);
247254
if (NewP > 0) MyOrder.Price = NewP;
255+
256+
return true;
248257
}
249258
else if (MyOrder.Price < MaxPrice)
250259
{
251260
// We can at least set price to be MaxPrice
252261
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MaxPrice.ToString("F4"));
253262
double NewP = MyOrder.SetPrice(MaxPrice);
254263
if (NewP > 0) MyOrder.Price = NewP;
264+
265+
return true;
255266
}
256267

257-
return true; // Return true anyway, we don't want to check for price decrease, because we should increase the price.
268+
return false;
258269
}
259270

260271

261272
private void DecreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice)
262273
{
263-
// Decrease only in case if we are still above or equal to minimal price.
264-
if (MyOrder.Price + APIWrapper.PriceDecreaseSteps[MyOrder.Algorithm] >= MinimalPrice)
274+
// Check time if decrase is possible.
275+
if (DecreaseTime + APIWrapper.PRICE_DECREASE_INTERVAL > DateTime.Now) return;
276+
277+
// Decrease only in case if we are still above or equal to minimal price. Or if we are above maximal price.
278+
if (MyOrder.Price + APIWrapper.PRICE_DECREASE_STEP[MyOrder.Algorithm] >= MinimalPrice ||
279+
MyOrder.Price > MaxPrice)
265280
{
266-
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Decreasing price order #" + MyOrder.ID);
267281
double NewP = MyOrder.SetPriceDecrease();
268-
if (NewP > 0) MyOrder.Price = NewP;
282+
if (NewP > 0)
283+
{
284+
MyOrder.Price = NewP;
285+
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Decreasing price order #" + MyOrder.ID + " to " + NewP.ToString("F4"));
286+
DecreaseTime = DateTime.Now;
287+
}
269288
}
270289
}
271290

0 commit comments

Comments
 (0)