public void DoExperiment() { PriceSet price_set = ToolsPrice.GetPriceSet(ToolsPrice.DefaultSymbolGBPUSD); List <IIndicator> indicators = new List <IIndicator>(); indicators.Add(new IndicatorRunningAverage(4)); indicators.Add(new IndicatorRunningAverage(6)); indicators.Add(new IndicatorRunningAverage(8)); indicators.Add(new IndicatorRunningAverage(10)); indicators.Add(new IndicatorRunningAverage(12)); IIndicator feature_indicator = new IndicatorFusion(indicators); IIndicator label_indicator = new IndicatorMagicProfit(60); MarketModelSimulation market = new MarketModelSimulation(1000, price_set); DataSet <double, double> dataset = ToolsTradingDataSet.CreateDataSet(market, feature_indicator, label_indicator); ITemplateModelLabel <double, double> template = null;//new TemplateModelLibSVMCSVC(); IModelLabel <double, double> model = template.GenerateModel(dataset); //TODO change everyting into templates List <IIndicator> indicators_2 = new List <IIndicator>(); indicators_2.Add(new IndicatorRunningAverage(4)); indicators_2.Add(new IndicatorRunningAverage(6)); indicators_2.Add(new IndicatorRunningAverage(8)); indicators_2.Add(new IndicatorRunningAverage(10)); indicators_2.Add(new IndicatorRunningAverage(12)); IIndicator feature_indicator_2 = new IndicatorFusion(indicators_2); //Build actual incator IIndicator indicator_0 = new IndicatorMagicProfit(60); IIndicator indicator_1 = new IndicatorMachineLearning(feature_indicator_2, model, "Profit_long_ml"); IList <Color> color_list = new Color[] { Color.Black }; IList <int> index_list = new int[] { 0 }; ToolsTradingPlotting.PlotIndicatorResult(ToolsTradingDataSet.GetPath() + "indicator_0.png", price_set, indicator_0, color_list, index_list, false); ToolsTradingPlotting.PlotIndicatorResult(ToolsTradingDataSet.GetPath() + "indicator_1.png", price_set, indicator_1, color_list, index_list, false); }
public void DoExperiment() { IReadOnlyList <PriceCandle> candles = ToolsPrice.GetPriceCandles(ToolsPrice.DefaultSymbolUSDEUR, TimeScale.Second1); DictionaryCount <int> dic = new DictionaryCount <int>(); foreach (PriceCandle candle in candles) { dic.Increment((int)Math.Round((candle.OpenAsk - candle.OpenBid) / TradingConstants.POINT)); } List <int> keys = new List <int>(dic.Keys); keys.Sort(); string[,] spread_table = new string[keys.Count, 2]; for (int i = 0; i < keys.Count; i++) { Console.WriteLine(keys[i] + " " + dic[keys[i]]); spread_table[i, 0] = keys[i].ToString(CultureInfo.InvariantCulture); spread_table[i, 1] = dic[keys[i]].ToString(CultureInfo.InvariantCulture); } ToolsIOCSV.WriteCSVFile(@"D:\GoogleDrive\TestData\Trading\Spreads.csv", spread_table); }
public void DoExperiment() { ToolsPrice.ComposeBinary(ToolsPrice.DefaultSymbolGBPUSD); PriceSet price_set = ToolsPrice.GetPriceSet(ToolsPrice.DefaultSymbolGBPUSD).SubSet(new DateTimeUTC(2016, 10, 17), new DateTimeUTC(2016, 10, 20)); IIndicator indicator_feature = new IndicatorSuperBollinger(); IIndicator indicator_label = new IndicatorMagicProfit(60); MarketModelSimulation market0 = new MarketModelSimulation(10000, price_set); MarketModelSimulation market1 = new MarketModelSimulation(10000, price_set); double[] time = new double[price_set.Prices.Count]; for (int price_index = 0; price_index < price_set.Prices.Count; price_index++) { time[price_index] = price_set.Prices[price_index].Time.Ticks; } Tuple <double[, ], bool[]> tuple0 = indicator_feature.ComputeAll(market0, price_set.Second1.Count); Tuple <double[, ], bool[]> tuple1 = indicator_label.ComputeAll(market1, price_set.Second1.Count); List <string[]> list_string = new List <string[]>(); for (int index_0 = 0; index_0 < tuple0.Item2.Length; index_0++) { if (tuple0.Item2[index_0] && tuple1.Item2[index_0]) { double[] array_double = ToolsCollection.Append(tuple0.Item1.Select1DIndex0(index_0), tuple1.Item1.Select1DIndex0(index_0)); string[] array_string = new string[array_double.Length]; for (int index_1 = 0; index_1 < array_double.Length; index_1++) { array_string[index_1] = array_double[index_1].ToString(CultureInfo.InvariantCulture); } list_string.Add(array_string); } } ToolsIOCSV.WriteCSVFile(ToolsTradingDataSet.GetPath() + "data.csv", ToolsCollection.ConvertToArray2D(list_string)); }
public void DoExperiment() { PriceSet price_set = ToolsPrice.GetPriceSet(ToolsPrice.DefaultSymbolGBPUSD); List <IPolicy> policies = new List <IPolicy>(); double long_threshold = 10 * Math.Pow(10, -6); double short_threshold = -10 * Math.Pow(10, -6); for (int index = 0; index < 1; index++) { policies.Add(new PolicyTemplateJaapBands().Instance()); } MarketResult[] market_results = new MarketResult[policies.Count]; Parallel.For(0, policies.Count, index => { MarketManagerSimulation exchange = new MarketManagerSimulation(10000, price_set); market_results[index] = exchange.Run(policies[index]); }); List <Tuple <MarketResult, IPolicy> > accepted_policy = new List <Tuple <MarketResult, IPolicy> >(); for (int index = 0; index < market_results.Length; index++) { // if(market_results[index].Market.ClosedOrders.Count > 9 && market_results[index].EndCash > 10000) // { accepted_policy.Add(new Tuple <MarketResult, IPolicy>(market_results[index], policies[index])); // } } for (int index = 0; index < accepted_policy.Count; index++) { var xx = accepted_policy[index]; Console.WriteLine(xx.Item1.EndCash + " in: " + xx.Item1.Market.ClosedOrders.Count); ToolsTradingPlotting.PlotMarketResult(ToolsTradingDataSet.GetPath() + "Trades" + index + ".png", xx.Item1); } }
public void TestSim40() { PriceSet price_set = ToolsPrice.GetPriceSet(ToolsPrice.DefaultSymbolGBPUSD); IMarketModelTest.TestSpeed(10000, price_set, 40); }
public void TestCreateMedium() { PriceSet price_set = new PriceSet(ToolsPrice.DefaultSymbolGBPUSD, ToolsCollection.Select(ToolsPrice.GetPriceList(ToolsPrice.DefaultSymbolGBPUSD), 0, 40)); List <IIndicator> indicators_features = new List <IIndicator>(); indicators_features.Add(new IndicatorRunningAverage(0)); indicators_features.Add(new IndicatorRunningAverage(1)); List <IIndicator> indicators_labels = new List <IIndicator>(); indicators_labels.Add(new IndicatorMagicProfit(0)); indicators_labels.Add(new IndicatorMagicProfit(1)); MarketModelSimulation market = new MarketModelSimulation(1000, price_set); IDataSet <double, double> dataset = ToolsTradingDataSet.CreateDataSet(market, new IndicatorFusion(indicators_features), new IndicatorFusion(indicators_labels)); Assert.AreEqual(39, dataset.InstanceCount); Assert.AreEqual(2, dataset.FeatureCount); Assert.AreEqual(4, dataset.LabelCount); }
public void TestGetPriceSet() { PriceSet price_set = ToolsPrice.GetPriceSet(ToolsPrice.DefaultSymbolGBPUSD); }
public void TestGetPriceCandles() { ToolsPrice.GetPriceCandles(ToolsPrice.DefaultSymbolGBPUSD, TimeScale.Second1); }
public void TestComposeBinary() { ToolsPrice.ComposeBinary(ToolsPrice.DefaultSymbolGBPUSD); }
public void TestComposeSource() { ToolsPrice.ComposeSource(); }