public static List <string> GetMarkets() { List <string> results = new List <string>(); if (ActionManager.CheckHaasConnection()) { try { HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); AccountInformation accountInformation = haasonlineClient.AccountDataApi.GetAccountDetails(mainConfig.AccountGUID).Result.Result; var markets = haasonlineClient.MarketDataApi.GetPriceMarkets(accountInformation.ConnectedPriceSource); foreach (var market in markets.Result.Result) { if (market.SecondaryCurrency.Equals(mainConfig.PrimaryCurrency)) { results.Add(market.PrimaryCurrency); } } } catch { return(results); } } return(results); }
public static void DeactivateCustomBot(string botGuid) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var task = Task.Run(async() => await haasonlineClient.CustomBotApi.DeactivateBots(botGuid, false)); task.Wait(); }
public static bool GrabMarketData(string market, string maincoin) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); AccountInformation accountInformation = haasonlineClient.AccountDataApi.GetAccountDetails(ConfigManager.mainConfig.AccountGUID).Result.Result; var keepPolling = true; var counter = 0; while (keepPolling) { var res = haasonlineClient.MarketDataApi.GetHistory(accountInformation.ConnectedPriceSource, market, maincoin, "", 1, ConfigManager.mainConfig.BackTestLength * 2).Result; if (res.ErrorCode == EnumErrorCode.Success && res.Result.Count >= ConfigManager.mainConfig.BackTestLength) { break; } counter++; if (counter > 30) { return(false); } Thread.Sleep(3000); } return(true); }
public static void DeleteTemplateBot() { if (ActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); haasonlineClient.CustomBotApi.RemoveBot(ActionManager.BaseBotTemplateGuid); } }
public static void MarketSellPosition(string primaryCoin, string secondaryCoin, decimal amount) { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var priceTickTask = Task.Run(async() => await haasonlineClient.TradeApi.PlaceSpotSellOrder(ConfigManager.mainConfig.AccountGUID, primaryCoin, secondaryCoin, 0, amount)); } }
public static void RemoveOpenOrder(string orderId) { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var cancelOpenOrderCommand = Task.Run(async() => await haasonlineClient.TradeApi.CancelTemplate(orderId)); } }
public static BaseCustomBot PerformBackTest(string market) { HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); var task = Task.Run(async() => await haasonlineClient.CustomBotApi.BacktestBot <BaseCustomBot>(BaseBotTemplateGuid, ActionManager.mainConfig.BackTestLength, ActionManager.mainConfig.AccountGUID, market, ActionManager.mainConfig.PrimaryCurrency, "")); task.Wait(); return(task.Result.Result); }
public static void GrabMarketData(string market) { HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); AccountInformation accountInformation = haasonlineClient.AccountDataApi.GetAccountDetails(mainConfig.AccountGUID).Result.Result; var task = Task.Run(async() => await haasonlineClient.MarketDataApi.GetHistory(accountInformation.ConnectedPriceSource, market, mainConfig.PrimaryCurrency, "", 1, mainConfig.BackTestLength * 2)); task.Wait(); }
public static void DeleteBot(string botGuid) { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var deleteTask = Task.Run(async() => await haasonlineClient.CustomBotApi.RemoveBot(botGuid)); deleteTask.Wait(); } }
public static ScalperBot UpdateScalperBot(string guid, string botName, string primaryCurrency, string secondaryCurrency, string position, decimal amount, decimal targetPercentage, decimal safetyPercentage) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var task = Task.Run(async() => await haasonlineClient.CustomBotApi.SetupScalpingBot(guid, botName, ConfigManager.mainConfig.AccountGUID, primaryCurrency, secondaryCurrency, "", 0, EnumBotTradeAmount.Static, amount, ConfigManager.mainConfig.Fee, position, "LOCKEDLIMITORDERGUID", targetPercentage, safetyPercentage)); task.Wait(); return(task.Result.Result); }
public static void CreatePersistentBot(string market) { string botName = "PP-" + market + ":" + ActionManager.mainConfig.PrimaryCurrency; HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); var task = Task.Run(async() => await haasonlineClient.CustomBotApi.NewBot(Haasonline.Public.LocalApi.CSharp.Enums.EnumCustomBotType.PingPongBot, botName, ActionManager.mainConfig.AccountGUID, market, ActionManager.mainConfig.PrimaryCurrency, "")); task.Wait(); Thread.Sleep(1000); }
public static bool CheckHaasConnection() { HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); var accounts = haasonlineClient.AccountDataApi.GetEnabledAccounts(); if (accounts.Result.ErrorCode == Haasonline.LocalApi.CSharp.Enums.EnumErrorCode.Success) { return(true); } return(false); }
public static PriceTick GetOneMinutePriceDataForMarket(EnumPriceSource priceSource, string primaryCoin, string secondaryCoin) { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var priceTickTask = Task.Run(async() => await haasonlineClient.MarketDataApi.GetMinutePriceTicker(priceSource, primaryCoin, secondaryCoin, "")); priceTickTask.Wait(); return(priceTickTask.Result.Result); } return(null); }
public static Wallet GetWalletInformation() { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var walletTasks = Task.Run(async() => await haasonlineClient.AccountDataApi.GetWallet(ConfigManager.mainConfig.AccountGUID)); walletTasks.Wait(); return(walletTasks.Result.Result); } return(null); }
public static void Test() { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var resultsTask = Task.Run(async() => await haasonlineClient.AccountDataApi.GetOrderTemplates()); resultsTask.Wait(); foreach (var result in resultsTask.Result.Result) { Console.WriteLine("TEST: {0} - {1}", result.Key, result.Value); } } }
public static List <BaseCustomBot> GetAllCustomBots() { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var getAllCustomBotsTask = Task.Run(async() => await haasonlineClient.CustomBotApi.GetAllBots()); getAllCustomBotsTask.Wait(); return(getAllCustomBotsTask.Result.Result); } else { return(null); } }
public static AccountInformation GetAccountInformation() { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var accountInformationTask = Task.Run(async() => await haasonlineClient.AccountDataApi.GetAccountDetails(ConfigManager.mainConfig.AccountGUID)); accountInformationTask.Wait(); return(accountInformationTask.Result.Result); } else { return(null); } }
public static ScalperBot RetrieveScalperObjectFromAPI(string guid) { if (HaasActionManager.CheckHaasConnection()) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var getScalperBotTask = Task.Run(async() => await haasonlineClient.CustomBotApi.GetBot <ScalperBot>(guid)); getScalperBotTask.Wait(); return(getScalperBotTask.Result.Result); } else { return(null); } }
public static void CreatePersistentBot(string botName, string market, string maincoin, decimal targetPercentage, decimal safetyPercentage) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var createBot = Task.Run(async() => await haasonlineClient.CustomBotApi.NewBot <ScalperBot>(Haasonline.Public.LocalApi.CSharp.Enums.EnumCustomBotType.ScalperBot, botName, ConfigManager.mainConfig.AccountGUID, market, maincoin, "")); createBot.Wait(); var setupScalpBotComplete = haasonlineClient.CustomBotApi.SetupScalpingBot(createBot.Result.Result.GUID, botName, ConfigManager.mainConfig.AccountGUID, market, maincoin, "", 0, EnumBotTradeAmount.Static, 1000, ConfigManager.mainConfig.Fee, maincoin, "LOCKEDLIMITORDERGUID", targetPercentage, safetyPercentage); setupScalpBotComplete.Wait(); Thread.Sleep(1000); }
public static List <Tuple <string, string> > GetAccountGUIDS() { List <Tuple <string, string> > results = new List <Tuple <string, string> >(); HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); var accounts = haasonlineClient.AccountDataApi.GetEnabledAccounts(); // Quick hacky to get a key foreach (string x in accounts.Result.Result.Keys) { results.Add(new Tuple <string, string>(accounts.Result.Result[x], x)); } return(results); }
public static string CreateTemplateBot() { List <string> markets = ActionManager.GetMarkets(); if (ActionManager.CheckHaasConnection()) { if (markets.Count > 0) { HaasonlineClient haasonlineClient = new HaasonlineClient(ActionManager.mainConfig.IPAddress, ActionManager.mainConfig.Port, ActionManager.mainConfig.Secret); var newBot = haasonlineClient.CustomBotApi.NewBot <BaseCustomBot>(Haasonline.Public.LocalApi.CSharp.Enums.EnumCustomBotType.PingPongBot, "PPScreener-Template", mainConfig.AccountGUID, markets[0], mainConfig.PrimaryCurrency, ""); ActionManager.BaseBotTemplateGuid = newBot.Result.Result.GUID; } } return(ActionManager.BaseBotTemplateGuid); }
public static BaseCustomBot PerformBackTest(string market, string maincoin, decimal targetPercentage, decimal safetyPercentage) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var task = Task.Run(async() => await haasonlineClient.CustomBotApi.SetupScalpingBot(BaseBotTemplateGuid, "BruteScalpe-Template", ConfigManager.mainConfig.AccountGUID, market, maincoin, "", 0, EnumBotTradeAmount.Static, 1000, ConfigManager.mainConfig.Fee, maincoin, "LOCKEDLIMITORDERGUID", targetPercentage, safetyPercentage)); task.Wait(); var task2 = Task.Run(async() => await haasonlineClient.CustomBotApi.BacktestBot <BaseCustomBot>(BaseBotTemplateGuid, ConfigManager.mainConfig.BackTestLength, ConfigManager.mainConfig.AccountGUID, market, maincoin, "")); task2.Wait(); return(task2.Result.Result); }
public static string CreateTemplateBot() { List <Tuple <string, string> > markets = HaasActionManager.GetMarkets(); if (HaasActionManager.CheckHaasConnection()) { if (markets.Count > 0) { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var newBot = Task.Run(async() => await haasonlineClient.CustomBotApi.NewBot <ScalperBot>(Haasonline.Public.LocalApi.CSharp.Enums.EnumCustomBotType.ScalperBot, "BruteScalpe-Template", ConfigManager.mainConfig.AccountGUID, markets[0].Item1, markets[0].Item2, "")); newBot.Wait(); HaasActionManager.BaseBotTemplateGuid = newBot.Result.Result.GUID; } } return(HaasActionManager.BaseBotTemplateGuid); }
public static bool CheckHaasConnection() { try { HaasonlineClient haasonlineClient = new HaasonlineClient(ConfigManager.mainConfig.IPAddress, ConfigManager.mainConfig.Port, ConfigManager.mainConfig.Secret); var accounts = haasonlineClient.AccountDataApi.GetEnabledAccounts(); if (accounts.Result.ErrorCode == EnumErrorCode.Success) { if (HaasActionManager.GetAccountGUIDS().Count > 0) { return(true); } } } catch { // Just to supress the stack error that occurs for failed connection } return(false); }