Skip to content

Commit

Permalink
Added ability to remove all pp screener created bots
Browse files Browse the repository at this point in the history
  • Loading branch information
r4stl1n committed Jul 10, 2018
1 parent 81dbba3 commit f05c297
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
49 changes: 49 additions & 0 deletions PPScreener/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,55 @@ public static BaseCustomBot PerformBackTest(string market)

}

public static List<BaseCustomBot> GetAllCustomBots()
{
if (ActionManager.CheckHaasConnection())
{
HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret);

var getAllCustomBotsTask = Task.Run(async () => await haasonlineClient.CustomBotApi.GetAllBots());

getAllCustomBotsTask.Wait();

return getAllCustomBotsTask.Result.Result;
}
else
{
return null;
}
}


public static BaseCustomBot GetCustomBotByName(string botName)
{

if (ActionManager.CheckHaasConnection())
{
// Find active bot markets
foreach (var bot in ActionManager.GetAllCustomBots())
{
if (bot.Name.Equals(botName))
{
return bot;
}
}
}

return null;
}


public static void DeleteBot(string botGuid)
{
if (ActionManager.CheckHaasConnection())
{
HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret);
var deleteTask = Task.Run(async () => await haasonlineClient.CustomBotApi.RemoveBot(botGuid));

deleteTask.Wait();
}
}

public static void CreatePersistentBot(string market)
{
string[] accountGuidSplit = ActionManager.mainConfig.AccountGUID.Split('-');
Expand Down
27 changes: 27 additions & 0 deletions PPScreener/InteractiveShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,33 @@ public void StartScreenerCommand(string arg)
}
}

[CmdCommand(Command = "remove-all-bots", Description = StaticStrings.REMOVE_ALL_BOTS_HELP_TEXT)]
public void RemoveAllBotsCommand(string arg)
{
string[] accountGuidSplit = ActionManager.mainConfig.AccountGUID.Split('-');


var customBots = ActionManager.GetAllCustomBots();

var markets = ActionManager.GetMarkets();

Console.WriteLine("[*] Deleteing All Bots Managed By BruteScalpe");

foreach (var market in markets)
{

string botName = "PP-" + accountGuidSplit[0] + "-" + market + ":" + ActionManager.mainConfig.PrimaryCurrency;

var customBot = ActionManager.GetCustomBotByName(botName);

if (customBot != null)
{
ActionManager.DeleteBot(customBot.GUID);
}

}
}

public InteractiveShell()
{

Expand Down
1 change: 1 addition & 0 deletions PPScreener/StaticStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static class StaticStrings
public const string SET_ACCOUNT_HELP_TEXT = "Set Active Account";
public const string SHOW_MARKETS_HELP_TEXT = "Show Current Markets";
public const string START_SCREENER_HELP_TEXT = "Start Screener";
public const string REMOVE_ALL_BOTS_HELP_TEXT = "Remove All PP Bots";


}
Expand Down

0 comments on commit f05c297

Please sign in to comment.