static void Main(string[] args) { //parameters int MaxNoTrades = 0; // Max number of concurrent trades int MaxTradeNo = 1; //Max number of trades to execute before exiting int PollTime = 1; // How often to poll for price updates. decimal TradeAmount = 0.001m; //trading amount in BTC. TradingAlgorthm TradingAlgorthm = TradingAlgorthm.SimpleSMA; BinanceClient binanceClient = new BinanceClient(new ApiClient(ConfigurationManager.AppSettings["ApiKey"], ConfigurationManager.AppSettings["ApiSecret"]), false); //binanceClient.ListenKlineEndpoint("ethbtc", TimeInterval.Minutes_1, KlineHandler); //get trading pairs, filter for BTC. Order by Volume if possible. var technicalAnalysis = new TechnicalAnalysis(binanceClient, new BackTestRequest()); technicalAnalysis.AddTradingPair("eosbtc", TimeInterval.Minutes_1); var results = technicalAnalysis.GetTradingOpportunities("Buy"); foreach (var result in results) { Console.WriteLine(result); } Console.ReadKey(); }
public BackTest(IRequest request) : base(request) { technicalAnalysis = new TechnicalAnalysis(BinanceClient, _request); tradingStrategy = new TradingStrategy(BinanceClient, _request); LastPrices = new Dictionary <string, decimal>(); CandleSticks = new Queue <Dictionary <string, Candlestick> >(); IsLastCandleStick = false; foreach (var item in _request.TradingPairs) { LastPrices.Add(item, 0m); } }
private static void SaveRateToFileTrainData(string currency) { var rates = Utils.ReadExchangeRatesForPeriod("PLN", currency, DateTime.Today.AddYears(-4), DateTime.Today.AddDays(-365)).Result.OrderBy(x => x.Date).ToList(); var ma5 = TechnicalAnalysis.MovingAverage(rates, 5).ToList(); var ma10 = TechnicalAnalysis.MovingAverage(rates, 10).ToList(); var ma15 = TechnicalAnalysis.MovingAverage(rates, 15).ToList(); var ma20 = TechnicalAnalysis.MovingAverage(rates, 20).ToList(); var ma50 = TechnicalAnalysis.MovingAverage(rates, 50).ToList(); var macd = TechnicalAnalysis.Macd(rates).ToList(); var nextDayRate = new List <ExchangeRate>(); for (int i = 0; i < rates.Count - 1; i++) { nextDayRate.Add(rates.ElementAt(i + 1)); } rates = rates.Skip(50).ToList(); ma5 = ma5.Skip(50).ToList(); ma10 = ma10.Skip(50).ToList(); ma15 = ma15.Skip(50).ToList(); ma20 = ma20.Skip(50).ToList(); ma50 = ma50.Skip(50).ToList(); macd = macd.Skip(50).ToList(); nextDayRate = nextDayRate.Skip(50).ToList(); List <InputOutputData> inputOutputDatas = new List <InputOutputData>(); for (int i = 0; i < rates.Count - 1; i++) { inputOutputDatas.Add(new InputOutputData { ExchangeRate = rates.ElementAt(i), Ma5 = ma5.ElementAt(i).Rate, Ma10 = ma10.ElementAt(i).Rate, Ma15 = ma15.ElementAt(i).Rate, Ma20 = ma20.ElementAt(i).Rate, Ma50 = ma50.ElementAt(i).Rate, Macd = macd.ElementAt(i).Rate, NextDayRate = nextDayRate.ElementAt(i).Rate }); } string projectDirectory = System.IO.Path.GetFullPath(@"..\..\..\"); PreparingExchangeRateData.SaveToFile(inputOutputDatas, projectDirectory + $"/Data/{inputOutputDatas.First().ExchangeRate.Currency}RateTrain.csv"); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Asset vix = new Asset(); vix.readPricesFromJson(@"C:\Users\lchan1\Downloads\vixcurrent.json"); Console.WriteLine(vix.getPrice().ToString()); Asset gold = new Asset(); gold.readPricesFromJson(@"C:\Users\lchan1\Downloads\goldcurrent.json"); Console.WriteLine(gold.getPrice().ToString()); DateTime start = vix.getEarliestDate() > gold.getEarliestDate() ? vix.getEarliestDate() : gold.getEarliestDate(); List <Tick> vixMACD = vix.getMACD(); List <Tick> vixSignal = TechnicalAnalysis.GetEMA(9, vixMACD); List <Tick> goldMACD = gold.getMACD(); List <Tick> goldSignal = TechnicalAnalysis.GetEMA(9, goldMACD); Console.ReadLine(); }
private double GetValue(TechnicalAnalysis dataSet) { return(dataSet.DataPoints[dataSet.DataPoints.Count() - 1][1]); }