Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Few bug fixes regarding price adjustments
- Price decrease every 10 minutes
- Removed bin folder
  • Loading branch information
nicehashdev committed Feb 12, 2015
1 parent 08444fa commit a27c8c2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
Binary file removed bin/NiceHashBot_1.0.0.0.zip
Binary file not shown.
Binary file removed bin/NiceHashBot_1.0.1.0.zip
Binary file not shown.
Binary file removed bin/NiceHashBot_1.0.1.1.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions src/NiceHashBot/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.0.1.2")]
[assembly: AssemblyFileVersion("1.0.1.2")]
17 changes: 12 additions & 5 deletions src/NiceHashBotLib/APIWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,25 @@ public class APIWrapper
/// </summary>
public readonly static string[] SERVICE_NAME = { "NiceHash", "WestHash" };


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

/// <summary>
/// Total number of algorithms.
/// </summary>
public readonly static int NumberOfAlgorithms = 10;
public readonly static int NUMBER_OF_ALGORITHMS = 10;

/// <summary>
/// Price decrease steps for all algorithms.
/// </summary>
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 };
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 };

/// <summary>
/// Price decrase interval - it is 10 minutes.
/// </summary>
public readonly static TimeSpan PRICE_DECREASE_INTERVAL = new TimeSpan(0, 10, 1);

/// <summary>
/// API ID.
Expand All @@ -63,8 +70,8 @@ public class APIWrapper
#region PRIVATE_PROPERTIES

private static object CacheLock = new object();
private static CachedOrderList[,] CachedOList = new CachedOrderList[SERVICE_LOCATION.Length, NumberOfAlgorithms];
private static CachedStats[,] CachedSList = new CachedStats[SERVICE_LOCATION.Length, NumberOfAlgorithms];
private static CachedOrderList[,] CachedOList = new CachedOrderList[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];
private static CachedStats[,] CachedSList = new CachedStats[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];

#endregion

Expand Down
33 changes: 26 additions & 7 deletions src/NiceHashBotLib/OrderInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class OrderInstance
private Order LastOrderStats;
private double StartingPrice;
private double StartingAmount;
private DateTime DecreaseTime;

#endregion

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

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

private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice)
{
// Do not make price higher if we are already on top of the list
if (AllOrders[0] == MyOrder) return false;
// Do not make price higher if we are already on top of the list (first alive).
foreach (Order O in AllOrders)
{
if (!O.Alive) continue;
if (O == MyOrder) return false;
else break;
}

// Do not increase price, if we already have price higher or equal compared to minimal price.
if (MyOrder.Price >= MinimalPrice) return false;
Expand All @@ -245,27 +252,39 @@ private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MinimalPrice.ToString("F4"));
double NewP = MyOrder.SetPrice(MinimalPrice);
if (NewP > 0) MyOrder.Price = NewP;

return true;
}
else if (MyOrder.Price < MaxPrice)
{
// We can at least set price to be MaxPrice
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Setting price order #" + MyOrder.ID + " to " + MaxPrice.ToString("F4"));
double NewP = MyOrder.SetPrice(MaxPrice);
if (NewP > 0) MyOrder.Price = NewP;

return true;
}

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


private void DecreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice)
{
// Decrease only in case if we are still above or equal to minimal price.
if (MyOrder.Price + APIWrapper.PriceDecreaseSteps[MyOrder.Algorithm] >= MinimalPrice)
// Check time if decrase is possible.
if (DecreaseTime + APIWrapper.PRICE_DECREASE_INTERVAL > DateTime.Now) return;

// Decrease only in case if we are still above or equal to minimal price. Or if we are above maximal price.
if (MyOrder.Price + APIWrapper.PRICE_DECREASE_STEP[MyOrder.Algorithm] >= MinimalPrice ||
MyOrder.Price > MaxPrice)
{
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Decreasing price order #" + MyOrder.ID);
double NewP = MyOrder.SetPriceDecrease();
if (NewP > 0) MyOrder.Price = NewP;
if (NewP > 0)
{
MyOrder.Price = NewP;
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Decreasing price order #" + MyOrder.ID + " to " + NewP.ToString("F4"));
DecreaseTime = DateTime.Now;
}
}
}

Expand Down

0 comments on commit a27c8c2

Please sign in to comment.