public void SetUp() { _mockAlpacaTradingClient = new Mock <IAlpacaTradingClient>(); _mockAlpacaTradingStreamingClient = new Mock <IAlpacaStreamingClient>(); _mockAlpacaDataClient = new Mock <IAlpacaDataClient>(); _mockAlpacaDataStreamingClient = new Mock <IAlpacaDataStreamingClient>(); _alpacaClient = new AlpacaClient( _mockAlpacaTradingClient.Object, _mockAlpacaTradingStreamingClient.Object, _mockAlpacaDataClient.Object, _mockAlpacaDataStreamingClient.Object ); }
/// <param name="stockSymbols">A list of the stock symbols to employ the trading strategies on.</param> /// <param name="strategyName">A strategy to employ on the stock. Possible list list of strategies: MeanReversionStrategy, MLStrategy, and MicrotrendStrategy.</param> static async Task <int> Main(string[] stockSymbols = null, string strategyName = null) { var args = new Dictionary <string, string>(); if (!string.IsNullOrWhiteSpace(strategyName)) { args.Add("Stock_Strategy", strategyName); } if (stockSymbols?.Any(x => !string.IsNullOrWhiteSpace(x)) ?? false) { args.Add("Stock_List_Raw", stockSymbols.Aggregate((x, y) => $"{x}, {y}")); } //Config var config = new ConfigurationBuilder() .AddJsonFile($"appsettings.json", true, true) .AddEnvironmentVariables() .AddInMemoryCollection(args) .Build(); var alpacaConfig = config.Get <AlpacaConfig>(); var stockConfig = config.Get <StockConfig>(); var mlConfig = config.Get <MLConfig>(); using var alpacaClient = new AlpacaClient(alpacaConfig); /* * using var repo = new TrackingRepository(new DatabaseContext(new DatabaseConfig())); * * await repo.AddOrder("Bomb", "GE", DateTime.UtcNow); * * Console.WriteLine(repo.GetOrders().Select(x => $"{x.Id} {x.StockSymbol} {x.Strategy}").Aggregate((x, y) => $"{x}, {y}")); * return 0;*/ await AutoTradeStocks(alpacaClient, stockConfig, mlConfig); while (true) { await Task.Delay(600000); } }