Example #1
0
 // single layer network
 public static NeuralNetwork<Vector> Create(IDataSet<Vector, Vector> dataSet, IActivator activator)
 {
     var workLayer = new FullyConnectedLayer(dataSet.FirstInput.Size, dataSet.FirstOutput.Size, activator);
     var outputLayer = new OutputLayer<Vector>();
     var layers = new CompositeLayer<Vector, Vector, Vector>(workLayer, outputLayer);
     return new NeuralNetwork<Vector>(layers);
 }
Example #2
0
        public static NeuralNetwork<Matrix> Create(IDataSet<Matrix, Vector> dataSet)
        {
            var count  = 5;

            var a = new ISingleLayer<Matrix, Matrix>[count];
            for (var i = 0; i < count; ++i)
                a[i] = new MatrixConvolutor(28, 28, 24, 24, new Tanh());

            var b = new ISingleLayer<Matrix, Matrix>[count];
            for (var i = 0; i < count; ++i)
                b[i] = new MatrixSubsampler(24, 24, 12, 12, new Tanh());

            var c = new ISingleLayer<Matrix, Matrix>[count];
            for (var i = 0; i < count; ++i)
                c[i] = new MatrixConvolutor(12, 12, 8, 8, new Tanh());

            var d = new ISingleLayer<Matrix, Matrix>[count];
            for (var i = 0; i < count; ++i)
                d[i] = new MatrixSubsampler(8, 8, 4, 4, new Tanh());

            var splitter    = new Splitter<Matrix, Matrix>(a);
            var applicator1 = new Applicator<Matrix, Matrix>(b);
            var applicator2 = new Applicator<Matrix, Matrix>(c);
            var merger      = new MatrixMerger<Matrix>(d);

            var classif  = new FullyConnectedLayer(16 * count, 10, new Tanh());

            var comp = CompositeLayer<Vector, Vector[], Vector>.Compose(splitter,
                                                                        applicator1,
                                                                        applicator2,
                                                                        merger,
                                                                        classif);

            return new NeuralNetwork<Matrix>(comp);
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            var adClosePrice = new double[Bars];

            for (int bar = 1; bar < Bars; bar++)
                if (Time[bar - 1].Day != Time[bar].Day)
                    adClosePrice[bar - 1] = Close[bar - 1];

            // Check the last bar
            TimeSpan tsBarClosing = Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int) Period, 0));
            var tsDayClosing = new TimeSpan(24, 0, 0);
            if (tsBarClosing == tsDayClosing)
                adClosePrice[Bars - 1] = Close[Bars - 1];

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Closing price of the day",
                    DataType = IndComponentType.ClosePrice,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 2,
                    Value = adClosePrice
                };
        }
        private void TestIndicator(IIndicator indicator, SlotTypes slotType, IDataSet dataSet, Random random)
        {
            indicator.Initialize(slotType);

            // List parameters
            foreach (ListParam list in indicator.IndParam.ListParam)
                if (list.Enabled)
                {
                    list.Index = random.Next(list.ItemList.Length);
                    list.Text = list.ItemList[list.Index];
                }

            // Numeric parameters
            foreach (NumericParam num in indicator.IndParam.NumParam)
                if (num.Enabled)
                {
                    double step = Math.Pow(10, -num.Point);
                    double minimum = num.Min;
                    double maximum = num.Max;
                    double value = minimum + step * random.Next((int)((maximum - minimum) / step));
                    num.Value = Math.Round(value, num.Point);
                }

            indicator.Calculate(dataSet);
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var entryHour = (int) IndParam.NumParam[0].Value;
            var entryMinute = (int) IndParam.NumParam[1].Value;
            var entryTime = new TimeSpan(entryHour, entryMinute, 0);

            // Calculation
            const int firstBar = 1;
            var adBars = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                adBars[bar] = Time[bar].TimeOfDay == entryTime ? Open[bar] : 0;
            }

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Entry hour",
                    DataType = IndComponentType.OpenPrice,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };
        }
        public LogisticRegressionClassifierTraining(int featuresCount, double regularizationParameter, IDataSet<bool, double> dataSet)
        {
            if (featuresCount <= 0)
            {
                throw new ArgumentOutOfRangeException("featuresCount", featuresCount, "Features count must be positive number.");
            }

            if (regularizationParameter < 0)
            {
                throw new ArgumentOutOfRangeException("regularizationParameter", regularizationParameter, "Regularization parameter must be non negative number.");
            }

            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            this.featuresCount = featuresCount;
            this.regularizationParameter = regularizationParameter;
            this.dataSet = dataSet;
            this.samplesCount = dataSet.GetTrainingSamplesCount();
            if (this.samplesCount <= 0)
            {
                throw new ArgumentOutOfRangeException("dataSet.GetTrainingSamplesCount()", this.samplesCount, "Samples count must be positive integer.");
            }
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var price = (BasePrice) IndParam.ListParam[1].Index;
            double margin = IndParam.NumParam[0].Value*Point;
            int prvs = IndParam.CheckParam[0].Checked ? 1 : 0;

            // TimeExecution
            if (price == BasePrice.Open && Math.Abs(margin - 0) < Epsilon)
                IndParam.ExecutionTime = ExecutionTime.AtBarOpening;
            else if (price == BasePrice.Close && Math.Abs(margin - 0) < Epsilon)
                IndParam.ExecutionTime = ExecutionTime.AtBarClosing;

            // Calculation
            double[] adBasePr = Price(price);
            var adUpBand = new double[Bars];
            var adDnBand = new double[Bars];

            int firstBar = 1 + prvs;

            for (int iBar = firstBar; iBar < Bars; iBar++)
            {
                adUpBand[iBar] = adBasePr[iBar - prvs] + margin;
                adDnBand[iBar] = adBasePr[iBar - prvs] - margin;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Up Price",
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adUpBand
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Down Price",
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adDnBand
                };

            switch (IndParam.ListParam[0].Text)
            {
                case "Enter long after an upward move":
                    Component[0].DataType = IndComponentType.OpenLongPrice;
                    Component[1].DataType = IndComponentType.OpenShortPrice;
                    break;

                case "Enter long after a downward move":
                    Component[0].DataType = IndComponentType.OpenShortPrice;
                    Component[1].DataType = IndComponentType.OpenLongPrice;
                    break;
            }
        }
Example #8
0
 public RowIndex(int index, IDataSet mainContainer = null, IRowIndex parent = null)
 {
     Index = index;
     Parent = parent;
     MainContainer = mainContainer;
     Weight = 1.0;
 }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            if (!IsBacktester)
            {
                // FST sends the N bars for exit to the expert. Expert watches the position and closes it.
                return;
            }

            var nExit = (int) IndParam.NumParam[0].Value;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "N Bars Exit (" + nExit.ToString(CultureInfo.InvariantCulture) + ")",
                    DataType = IndComponentType.ForceClose,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = true,
                    FirstBar = 1,
                    Value = new double[Bars]
                };
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            const int firstBar = 2;
            var adIb = new double[Bars];

            for (int iBar = 2; iBar < Bars; iBar++)
            {
                adIb[iBar] = ((High[iBar - 1] < High[iBar - 2]) && (Low[iBar - 1] > Low[iBar - 2])) ? 1 : 0;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Allow long entry",
                    DataType = IndComponentType.AllowOpenLong,
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adIb
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Allow short entry",
                    DataType = IndComponentType.AllowOpenShort,
                    ChartType = IndChartType.NoChart,
                    FirstBar = firstBar,
                    Value = adIb
                };
        }
 /// <summary>
 ///     Converts indicator components to strategy data set time.
 /// </summary>
 public void NormalizeComponents(IDataSet strategyDataSet)
 {
     foreach (IndicatorComp indicatorComp in Component)
     {
         indicatorComp.Value = NormalizeComponentValue(indicatorComp.Value, strategyDataSet.Time);
         indicatorComp.FirstBar = NormalizeComponentFirstBar(indicatorComp.FirstBar, strategyDataSet.Time);
     }
 }
		/// <summary>Default constructor</summary>
		public SigmoidCombinedAsymmetricFactorModel() : base()
		{
			AdditionalFeedback = new PosOnlyFeedback<SparseBooleanMatrix>(); // in case no test data is provided
			Regularization = 0.015f;
			LearnRate = 0.001f;
			BiasLearnRate = 0.7f;
			BiasReg = 0.33f;
		}
Example #13
0
    public void Initialize()
    {
        //_data = PivotTableUtils.SampleDataStore.GetSample(2);
        _data = new SQLDataSet(CSVDatabase.SampleSales, "SELECT * FROM PRODUCTS.CSV");
        //_voldata = PivotTableUtils.SampleDataStore.GetResource("dummyvolsurfaces.js");

        //_data = new SQLDataSet(SQLiteDatabase.SampleSales, "SELECT * FROM SALES");
    }
		///
		public virtual void RemoveRatings(IDataSet ratings_to_delete)
		{
			for (int i = 0; i < ratings_to_delete.Count; i++)
			{
				int index;
				if (Ratings.TryGetIndex(ratings_to_delete.Users[i], ratings_to_delete.Items[i], out index))
					Ratings.RemoveAt(index);
			}
		}
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            if (IsBacktester)
                CalculateForBacktester();
            else
                CalculateForTrader();
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var fromHour = (int) IndParam.NumParam[0].Value;
            var fromMin = (int) IndParam.NumParam[1].Value;
            var untilHour = (int) IndParam.NumParam[2].Value;
            var untilMin = (int) IndParam.NumParam[3].Value;
            var fromTime = new TimeSpan(fromHour, fromMin, 0);
            var untilTime = new TimeSpan(untilHour, untilMin, 0);

            // Calculation
            const int firstBar = 1;
            var adBars = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                if (fromTime < untilTime)
                    adBars[bar] = Time[bar].TimeOfDay >= fromTime &&
                                  Time[bar].TimeOfDay < untilTime
                                      ? 1
                                      : 0;
                else if (fromTime > untilTime)
                    adBars[bar] = Time[bar].TimeOfDay >= fromTime ||
                                  Time[bar].TimeOfDay < untilTime
                                      ? 1
                                      : 0;
                else
                    adBars[bar] = 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Is long entry allowed",
                    DataType = IndComponentType.AllowOpenLong,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Is short entry allowed",
                    DataType = IndComponentType.AllowOpenShort,
                    ChartType = IndChartType.NoChart,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = adBars
                };
        }
        /// <summary>
        /// Adds a data set to the aggregate.
        /// </summary>
        /// <param name="dataSet">The data set to add.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="dataSet"/> is null.</exception>
        /// <exception cref="ArgumentException">Thrown if <paramref name="dataSet"/> is already a member of this aggregate.</exception>
        public virtual void AddDataSet(IDataSet dataSet)
        {
            if (dataSet == null)
                throw new ArgumentNullException("dataSet");

            if (dataSets == null)
                dataSets = new List<IDataSet>();
            else if (dataSets.Contains(dataSet))
                throw new ArgumentException("The data set is already a member of the aggregate.", "dataSet");

            dataSets.Add(dataSet);
        }
 public void CalculateIndicatorWithRandomParameters(IIndicator indicator, IDataSet dataSet, int testPerSlot)
 {
     Random random = new Random(DateTime.Now.Second);
     var types = (SlotTypes[])Enum.GetValues(typeof(SlotTypes));
     foreach (var type in types)
         if (indicator.TestPossibleSlot(type))
             for (int i = 0; i < testPerSlot; i++)
             {
                 TestIndicator(indicator, type, dataSet, random);
                 ShowResult(indicator);
             }
 }
Example #19
0
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var dowFromDay = (DayOfWeek) IndParam.ListParam[1].Index;
            var dowUntilDay = (DayOfWeek) IndParam.ListParam[2].Index;

            // Calculation
            const int firstBar = 1;
            var signal = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                if (dowFromDay < dowUntilDay)
                    signal[bar] = Time[bar].DayOfWeek >= dowFromDay &&
                                  Time[bar].DayOfWeek < dowUntilDay
                        ? 1
                        : 0;
                else if (dowFromDay > dowUntilDay)
                    signal[bar] = Time[bar].DayOfWeek >= dowFromDay ||
                                  Time[bar].DayOfWeek < dowUntilDay
                        ? 1
                        : 0;
                else
                    signal[bar] = 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
            {
                CompName = "Allow long entry",
                DataType = IndComponentType.AllowOpenLong,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = false,
                FirstBar = firstBar,
                Value = signal
            };

            Component[1] = new IndicatorComp
            {
                CompName = "Allow short entry",
                DataType = IndComponentType.AllowOpenShort,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = false,
                FirstBar = firstBar,
                Value = signal
            };
        }
Example #20
0
        private void TestPivotTableQuery(IDataSet dataset, int expected)
        {
            var settings = new QuerySettings();
            var queryParams = new QueryParams()
            {
                filter = new Dictionary<string, string>(),
                valueFields = new List<string>() { "Sales", "Profit" },
                nextPivot = "Province"
            };

            var queryResults = dataset.Query(queryParams, settings);
            Assert.AreEqual(queryResults.Count, expected);
        }
Example #21
0
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var maMethod = (MAMethod) IndParam.ListParam[1].Index;
            var period = (int) IndParam.NumParam[0].Value;
            var multipl = (int) IndParam.NumParam[1].Value;
            int prev = IndParam.CheckParam[0].Checked ? 1 : 0;

            // Calculation
            int firstBar = period + 2;

            var atr = new double[Bars];

            for (int bar = 1; bar < Bars; bar++)
                atr[bar] = Math.Max(High[bar], Close[bar - 1]) - Math.Min(Low[bar], Close[bar - 1]);

            atr = MovingAverage(period, 0, maMethod, atr);

            var atrStop = new double[Bars];
            double pip = (Digits == 5 || Digits == 3) ? 10*Point : Point;
            double minStop = 5*pip;

            for (int bar = firstBar; bar < Bars - prev; bar++)
                atrStop[bar + prev] = Math.Max(atr[bar]*multipl, minStop);

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "ATR Stop margin",
                    DataType = IndComponentType.IndicatorValue,
                    FirstBar = firstBar,
                    ShowInDynInfo = false,
                    Value = atrStop
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "ATR Stop for the transferred position",
                    DataType = IndComponentType.Other,
                    ShowInDynInfo = false,
                    FirstBar = firstBar,
                    Value = new double[Bars]
                };
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Close Price",
                    DataType = (IndParam.SlotType == SlotTypes.Open) ? IndComponentType.OpenPrice : IndComponentType.ClosePrice,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 2,
                    Value = Close
                };
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Trailing Stop for the transferred position",
                    DataType = IndComponentType.Other,
                    ShowInDynInfo = false,
                    FirstBar = 1,
                    Value = new double[Bars]
                };
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
                {
                    CompName = "Opening price of the bar",
                    DataType = IndComponentType.OpenPrice,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 2,
                    Value = Open
                };
        }
Example #25
0
        static async Task MainAsync(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine(@"Choose an implementation: ");
            Console.ForegroundColor = ConsoleColor.White;

            foreach (Implementation value in Enum.GetValues(typeof(Implementation)))
            {
                Console.WriteLine($"{(int)value}. {value}");
            }
            Implementation option;

            if (!Enum.TryParse(Console.ReadLine(), out option))
            {
                option = Implementation.Memory;
            }

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine($"Using the '{option}' implementation");
            Console.ForegroundColor = ConsoleColor.White;

            // Run map samples
            IDataMap dataMap = GetDataMapImplementation(option);

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("Map samples");
            Console.ForegroundColor = ConsoleColor.White;
            await RunMapSamplesAsync(dataMap);

            // Run set samples
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("Set samples");
            Console.ForegroundColor = ConsoleColor.White;
            IDataSet dataSet = GetDataSetImplementation(option);

            await RunSetSamplesAsync(dataSet);

            // Run set map samples
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("SetMap samples");
            Console.ForegroundColor = ConsoleColor.White;
            IDataSetMap dataSetMap = GetDataSetMapImplementation(option);

            await RunSetMapSamplesAsync(dataSetMap);

            Console.ReadLine();
        }
Example #26
0
        public IEnumerable <IData> CreateDataRows(IDataSet dataSet)
        {
            var          rows    = _factory.CreateDataRows(dataSet).ToList();
            List <IData> tempSet = new List <IData>();
            Dictionary <string, List <IData> > extractions = new Dictionary <string, List <IData> >();

            foreach (var row in rows)
            {
                foreach (var feature in _features.OfType <ISingleRowFeature>())
                {
                    if (!extractions.ContainsKey(feature.FeatureName))
                    {
                        extractions.Add(feature.FeatureName, new List <IData>());
                    }
                    extractions[feature.FeatureName].Add(feature.Extract(row));
                }
                foreach (var feature in _features.OfType <IOneOnOneFeature>())
                {
                    foreach (var child in feature.Extract(row))
                    {
                        string header = GetHeader(child);
                        if (!extractions.ContainsKey(header))
                        {
                            extractions.Add(header, new List <IData>());
                        }
                        extractions[header].Add(child);
                    }
                }
                tempSet.Add(row);
                if (tempSet.Count > 1)
                {
                    foreach (var feature in _features.OfType <IDualRowFeature>())
                    {
                        if (!extractions.ContainsKey(feature.FeatureName))
                        {
                            extractions.Add(feature.FeatureName, new List <IData>());
                        }

                        extractions[feature.FeatureName].Add(feature.Extract(tempSet));
                    }

                    tempSet.Remove(tempSet[0]);
                }
            }

            return(CreateData(extractions));
        }
Example #27
0
        /// <summary>
        /// Returns a native raster of the appropriate file type and data type by parsing the fileName.
        /// </summary>
        /// <param name="fileName">The string fileName to attempt to open with a native format</param>
        /// <param name="inRam">The boolean value.</param>
        /// <returns>An IRaster which has been opened to the specified file.</returns>
        public static IRaster OpenFile(string fileName, bool inRam)
        {
            // Ensure that the fileName is valid
            if (fileName == null)
            {
                throw new NullException("fileName");
            }
            if (File.Exists(fileName) == false)
            {
                throw new FileNotFoundException("fileName");
            }

            // default to opening values into ram
            IDataSet dataset = DataManager.DefaultDataManager.OpenFile(fileName, inRam);

            return(dataset as IRaster);
        }
Example #28
0
        protected async Task <TResult> PerformWithRepositoryAsync <TEntity, TResult>(Func <IDataSet <TEntity>, Task <TResult> > action)
            where TEntity : IEntity
        {
            IDataSet <TEntity> repository = _factory.Resolve <TEntity>();

            try
            {
                return(await action(repository));
            }
            finally
            {
                if (repository != null)
                {
                    _factory.Dispose(repository);
                }
            }
        }
Example #29
0
        internal Counter(IDataSet dataSet)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            this.DataSet = dataSet;
            this.DataSet.OnDataSealed +=
                (start, end) =>
            {
                if (this.OnCounterDataSealed != null)
                {
                    this.OnCounterDataSealed(this, new DateTimeOffset(start), new DateTimeOffset(end));
                }
            };
        }
Example #30
0
        public void CalculateIndicatorWithRandomParameters(IIndicator indicator, IDataSet dataSet, int testPerSlot)
        {
            Random random = new Random(DateTime.Now.Second);
            var    types  = (SlotTypes[])Enum.GetValues(typeof(SlotTypes));

            foreach (var type in types)
            {
                if (indicator.TestPossibleSlot(type))
                {
                    for (int i = 0; i < testPerSlot; i++)
                    {
                        TestIndicator(indicator, type, dataSet, random);
                        ShowResult(indicator);
                    }
                }
            }
        }
Example #31
0
        public void GetItemsAppliesNoTranslationIfNoAliasesAreDefined()
        {
            List <KeyValuePair <string, string> > metadataPairs = new List <KeyValuePair <string, string> >();

            metadataPairs.Add(new KeyValuePair <string, string>("Foo", "Bar"));

            IDataSet dataSet = Mocks.StrictMock <IDataSet>();

            using (Mocks.Record())
            {
                SetupResult.For(dataSet.ColumnCount).Return(2);

                Expect.Call(dataSet.GetItems(null, true)).IgnoreArguments().Do((GetItemsDelegate) delegate(ICollection <DataBinding> bindings,
                                                                                                           bool includeDynamicItems)
                {
                    Assert.IsTrue(includeDynamicItems);
                    List <IDataItem> items = new List <IDataItem>();
                    items.Add(new ListDataItem <object>(new object[] { "abc", "def", "ghi" }, metadataPairs, false));

                    List <DataBinding> bindingList = new List <DataBinding>(bindings);

                    Assert.AreEqual("untranslatedPath", bindingList[0].Path);
                    Assert.AreEqual(1, bindingList[0].Index);

                    return(items);
                });
            }

            using (Mocks.Playback())
            {
                DataSource source = new DataSource("theName");
                source.AddDataSet(dataSet);

                DataBinding[] bindings = new DataBinding[] {
                    new DataBinding(1, "untranslatedPath")
                };

                List <IDataItem> items = new List <IDataItem>(source.GetItems(bindings, true));
                Assert.Count(1, items);

                PropertyBag map = DataItemUtils.GetMetadata(items[0]);
                Assert.Count(1, map);
                Assert.AreEqual("Bar", map.GetValue("Foo"));
                Assert.AreEqual("def", items[0].GetValue(bindings[0]));
            }
        }
Example #32
0
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            int hour   = (int)IndParam.NumParam[0].Value;
            int minute = (int)IndParam.NumParam[1].Value;

            // Calculation
            const int firstBar = 2;

            double[] signal = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                DateTime closeTime = Time[bar].AddMinutes((int)Period);
                if (closeTime.Hour == hour && closeTime.Minute == minute)
                {
                    signal[bar] = 1;
                }
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
            {
                CompName      = "Close out long position",
                DataType      = IndComponentType.ForceCloseLong,
                ChartType     = IndChartType.NoChart,
                ShowInDynInfo = true,
                FirstBar      = firstBar,
                Value         = signal
            };

            Component[1] = new IndicatorComp
            {
                CompName      = "Close out short position",
                DataType      = IndComponentType.ForceCloseShort,
                ChartType     = IndChartType.NoChart,
                ShowInDynInfo = true,
                FirstBar      = firstBar,
                Value         = signal
            };
        }
Example #33
0
        public static IDataSet <T>[] createDataSet <T>(int aSize, int iSize)
        {
            IDataSet <T> [] temp = new IDataSet <T> [aSize];
            Random          r    = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < aSize; i++)
            {
                temp[i] = Factory.getObject <IDataSet <T> >();
                temp[i].CreateItems(iSize);

                for (int j = 0; j < iSize; j++)
                {
                    temp[i].SetValue((T)Convert.ChangeType(r.NextDouble(), typeof(T)), j);
                }
            }
            return(temp);
        }
Example #34
0
        public static BigListResult <object> Show(Form owner, Core core, IDataSet config, EShow show, object automaticAddTemplate)
        {
            using (var frm = new FrmBigList(core, config, show, automaticAddTemplate))
            {
                if (owner is FrmBigList)
                {
                    frm.Size = new Size(Math.Max(128, owner.Width - 32), Math.Max(128, owner.Height - 32));
                }

                if (UiControls.ShowWithDim(owner, frm) != DialogResult.OK)
                {
                    return(null);
                }

                return(new BigListResult <object>(frm._list, frm._selectionResult));
            }
        }
Example #35
0
        internal Counter(IDataSet dataSet)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            this.DataSet = dataSet;
            this.DataSet.OnDataSealed +=
                (start, end) =>
                {
                    if (this.OnCounterDataSealed != null)
                    {
                        this.OnCounterDataSealed(this, new DateTimeOffset(start), new DateTimeOffset(end));
                    }
                };
        }
        public ReportDiscrete <DomainType, LabelType> GenerateAndTestDiscrete(IDataSet <DomainType, LabelType> training_set, IDataSet <DomainType, LabelType> test_set)
        {
            //TODO check data contexts (they should match)
            IModelDiscrete <DomainType, LabelType> model = GenerateModelDiscrete(training_set);
            int label_value_count = test_set.DataContext.GetLabelDescriptor(0).ValueCount;

            int[,] confusion_matrix_instances = new int[label_value_count, label_value_count];
            for (int instance_index = 0; instance_index < test_set.InstanceCount; instance_index++)
            {
                //int true_label_index = test_set.DataContext.GetLabelValueIndex(test_set.GetInstanceLabelData(instance_index));
                //int model_label_index = model.GetLabelIndex(test_set.GetInstanceFeatureData(instance_index));
                //confusion_matrix_instances[true_label_index, model_label_index]++;
                ////
                throw new NotImplementedException();
            }
            return(new ReportDiscrete <DomainType, LabelType>(model, confusion_matrix_instances));
        }
Example #37
0
        public IModelDiscreteIterative <DomainType, LabelType> GenerateModelDiscrete(IDataSet <DomainType, LabelType> training_set)
        {
            ModelNearestNeighborKDTree <DomainType, DistanceType, LabelType> model = new ModelNearestNeighborKDTree <DomainType, DistanceType, LabelType>(
                this.DataContext,
                this.kdtree.Copy(),
                this.DistanceFunction,
                this.voting_system,
                this.neighbor_count);
            IList <Tuple <DomainType[], LabelType> > training_instances = new List <Tuple <DomainType[], LabelType> >();

            for (int instance_index = 0; instance_index < training_set.InstanceCount; instance_index++)
            {
                training_instances.Add(new Tuple <DomainType[], LabelType>(training_set.GetInstanceFeatureData(instance_index), training_set.GetInstanceLabelData(instance_index)[0]));
            }
            model.Add(training_instances);
            return(model);
        }
Example #38
0
        private FrmSelectList(IFormList handler, IDataSet opts, bool multiSelect, IEnumerable defaultSelection, Core core)
            : this()
        {
            this.Text = opts.Title;
            this.ctlTitleBar1.Text    = opts.Title;
            this.ctlTitleBar1.SubText = opts.SubTitle;
            this._btnEdit.Visible     = opts.ListSupportsChanges;

            this._handler              = handler;
            this._opts                 = opts;
            this._multiSelect          = multiSelect;
            this._flpSelectAll.Visible = multiSelect;

            this._handler.Initialise(this, core);

            this.RefreshList(defaultSelection);
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
            {
                CompName  = "Is long entry allowed",
                DataType  = IndComponentType.AllowOpenLong,
                ChartType = IndChartType.NoChart,
                FirstBar  = 0,
                Value     = new double[Bars]
            };

            Component[1] = new IndicatorComp
            {
                CompName  = "Is short entry allowed",
                DataType  = IndComponentType.AllowOpenShort,
                ChartType = IndChartType.NoChart,
                FirstBar  = 0,
                Value     = new double[Bars]
            };

            // Calculation of the logic
            switch (IndParam.ListParam[0].Text)
            {
            case "Open long positions only":
                for (int i = 0; i < Bars; i++)
                {
                    Component[0].Value[i] = 1;
                    Component[1].Value[i] = 0;
                }
                break;

            case "Open short positions only":
                for (int i = 0; i < Bars; i++)
                {
                    Component[0].Value[i] = 0;
                    Component[1].Value[i] = 1;
                }
                break;
            }
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
                {
                    CompName = "Is long entry allowed",
                    DataType = IndComponentType.AllowOpenLong,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 0,
                    Value = new double[Bars]
                };

            Component[1] = new IndicatorComp
                {
                    CompName = "Is short entry allowed",
                    DataType = IndComponentType.AllowOpenShort,
                    ChartType = IndChartType.NoChart,
                    FirstBar = 0,
                    Value = new double[Bars]
                };

            // Calculation of the logic
            switch (IndParam.ListParam[0].Text)
            {
                case "Open long positions only":
                    for (int i = 0; i < Bars; i++)
                    {
                        Component[0].Value[i] = 1;
                        Component[1].Value[i] = 0;
                    }
                    break;

                case "Open short positions only":
                    for (int i = 0; i < Bars; i++)
                    {
                        Component[0].Value[i] = 0;
                        Component[1].Value[i] = 1;
                    }
                    break;
            }
        }
Example #41
0
        public static TileMatrix[] GetTileMatrices(IDataSet dataSet, int minLevel, int maxLevel)
        {
            if (dataSet == null)
            {
                return(null);
            }
            if (minLevel < 0)
            {
                return(null);
            }
            double            semimajor = dataSet.Projection.GeographicInfo.Datum.Spheroid.EquatorialRadius;
            double            top = dataSet.Extent.MaxY;
            double            left = dataSet.Extent.MinX;
            int               tileWidth = 256, tileHeight = 256;
            double            scaleDenominator = 0;
            int               matrixWidth = 0, matrixHeight = 0;
            double            tileDWidth = 0, tileDHeight = 0;
            List <TileMatrix> tileMatrices = new List <TileMatrix>();

            {
                for (int i = minLevel; i <= maxLevel; i++)
                {
                    scaleDenominator = Math.PI * semimajor / (128 * Math.Pow(2, i));
                    tileDWidth       = Math.PI * semimajor / Math.Pow(2, i - 1);
                    tileDHeight      = tileDWidth;
                    matrixWidth      = (int)Math.Ceiling(dataSet.Extent.Width / tileDWidth);
                    matrixHeight     = (int)Math.Ceiling(dataSet.Extent.Height / tileDHeight);
                    TileMatrix tileMatrix = new TileMatrix()
                    {
                        Identifier = new CodeType()
                        {
                            Value = i.ToString()
                        },
                        ScaleDenominator = scaleDenominator,
                        TopLeftCorner    = $"{left} {top}",
                        TileWidth        = tileWidth.ToString(),
                        TileHeight       = tileHeight.ToString(),
                        MatrixWidth      = matrixWidth.ToString(),
                        MatrixHeight     = matrixHeight.ToString()
                    };
                    tileMatrices.Add(tileMatrix);
                }
            }
            return(tileMatrices.ToArray());
        }
Example #42
0
        /// <summary>
        /// Adds a data set to the aggregate.
        /// </summary>
        /// <param name="dataSet">The data set to add.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="dataSet"/> is null.</exception>
        /// <exception cref="ArgumentException">Thrown if <paramref name="dataSet"/> is already a member of this aggregate.</exception>
        public virtual void AddDataSet(IDataSet dataSet)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            if (dataSets == null)
            {
                dataSets = new List <IDataSet>();
            }
            else if (dataSets.Contains(dataSet))
            {
                throw new ArgumentException("The data set is already a member of the aggregate.", "dataSet");
            }

            dataSets.Add(dataSet);
        }
Example #43
0
        public override void run(IDataSet dataSet)
        {
            IStreamObj obj = dataSet.getData(JObjectType.sign_in_ret);

            if (null == obj || null == (obj as JObj_SignRet))
            {
                JLog.Error("JProcesserSignInGet : obj is empty!");
            }

            if ((obj as JObj_SignRet).Result == true)
            {
                //todo:...
                if (null != toSignIn)
                {
                    toSignIn();
                }
            }
        }
Example #44
0
        public override LayerType AddContent(Capabilities capabilities, string dataPath)
        {
            string extension = Path.GetExtension(dataPath);

            if (string.IsNullOrWhiteSpace(extension))
            {
                throw new Exception("不支持的路径");
            }
            IDataSet dataSet = DataHelper.OpenFile(dataPath);

            if (dataSet == null)
            {
                throw new Exception("打开数据失败");
            }
            LayerType layerType = CapabilitiesHelper.AddContent(capabilities, dataSet);

            return(layerType);
        }
Example #45
0
            /// <summary>
            /// Initializes the dataset combo to have the list of datasets from the report and the proper one will be selected.
            /// </summary>
            private void InitializeDataSetsCombo()
            {
                string     dsName    = _reportItem.CustomData.DataSetName;
                PageReport reportDef = GetCurrentReport();

                using (new SuspendLayoutTransaction(cbDataSetName))
                {
                    if (reportDef != null && reportDef.Report != null && reportDef.Report.DataSets != null)
                    {
                        for (int index = 0; index < reportDef.Report.DataSets.Count; index++)
                        {
                            IDataSet ds = reportDef.Report.DataSets[index];
                            cbDataSetName.Items.Add(ds.Name);
                        }
                    }
                    cbDataSetName.Text = dsName ?? string.Empty;
                }
            }
Example #46
0
        private void comboBoxLink_SelectedIndexChanged(object sender, EventArgs e)
        {
            listBoxLinkedObjects.Items.Clear();
            if (comboBoxLink.SelectedIndex == -1)
            {
                return;
            }
            string linkName = (string)comboBoxLink.Items[comboBoxLink.SelectedIndex];

            object[] args    = { PluginCall.IdVersion, linkName, false };
            IDataSet dataSet = PluginCall.GetDataSet("GetLinkedFast", args);

            while (!dataSet.Eof)
            {
                listBoxLinkedObjects.Items.Add(dataSet.FieldValue["_PRODUCT"]);
                dataSet.Next();
            }
        }
Example #47
0
        private static void ProccessDataSetNominalSupportVectorMachine(IDataSet <int, int> training_set, IDataSet <int, int> test_set)
        {
            //ITemplateModelInterval<int, IModelLikelyHood<double[], int, double>>
            IDataSet <double, int> training_set_interval = training_set.ConvertToDataSetInterval();
            IDataSet <double, int> test_set_interval     = test_set.ConvertToDataSetInterval();
            //ITemplateModelDiscrete<IDataSetIntervalLabeled<double,int>, IModelLikelyHood<double[], int, double>> template =
            //    new TemplateModelFeatureSelecting<double, int, IDataSetIntervalLabeled<double, int>>(
            //        new FeatureSelectorGreedy<double, int, IDataSetIntervalLabeled<double,int>>(
            //        new EvaluatorReapetedRandomFold<double, int, IDataSetIntervalLabeled<double, int>>(10)),
            //        new TemplateModelLibSVMCSVC());

            ITemplateModelDiscrete <double, int> template = new TemplateModelLibSVMCSVC(100, 5);

            ReportDiscrete <double, int> report = template.GenerateAndTestDiscrete(training_set_interval, test_set_interval);

            Console.WriteLine(ToolsCollection.ToString(report.ConfusionMatrixInstances));
            Console.WriteLine(report.CorrectLabelRate);
        }
        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);
        }
Example #49
0
        private static void ReadWorker(XmlReader reader, IDataSet dataSet)
        {
            Worker inst = new Worker();

            reader.ReadStartElement("Worker");
            inst.Id   = reader.ReadElementContentAsInt();
            inst.Name = reader.ReadElementContentAsString();
            int PostId = reader.ReadElementContentAsInt();

            inst.Post = dataSet.Posts.FirstOrDefault(el => el.Id == PostId);
            inst.Unit = reader.ReadElementContentAsString();
            string Exp_ = reader.ReadElementContentAsString();

            inst.Exp             = string.IsNullOrEmpty(Exp_) ? (int?)null : int.Parse(Exp_);
            inst.Bio             = reader.ReadElementContentAsString();
            inst.Kharakteristika = reader.ReadElementContentAsString();
            dataSet.Workers.Add(inst);
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            const int firstBar = 1;
            var       adBars   = new double[Bars];

            // Calculation of the logic
            for (int bar = 0; bar < Bars - 1; bar++)
            {
                if (Time[bar].DayOfWeek > DayOfWeek.Wednesday &&
                    Time[bar + 1].DayOfWeek < DayOfWeek.Wednesday)
                {
                    adBars[bar] = Close[bar];
                }
                else
                {
                    adBars[bar] = 0;
                }
            }

            // Check the last bar
            TimeSpan tsBarClosing = Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int)Period, 0));
            var      tsDayClosing = new TimeSpan(24, 0, 0);

            if (Time[Bars - 1].DayOfWeek == DayOfWeek.Friday && tsBarClosing == tsDayClosing)
            {
                adBars[Bars - 1] = Close[Bars - 1];
            }

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
            {
                CompName      = "Week Closing",
                DataType      = IndComponentType.ClosePrice,
                ChartType     = IndChartType.NoChart,
                ShowInDynInfo = false,
                FirstBar      = firstBar,
                Value         = adBars
            };
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var exitHour = (int) IndParam.NumParam[0].Value;
            var tsExitHour = new TimeSpan(exitHour, 0, 0);

            // Calculation
            const int firstBar = 1;
            var adBars = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                if (Time[bar - 1].DayOfYear == Time[bar].DayOfYear &&
                    Time[bar - 1].TimeOfDay < tsExitHour &&
                    Time[bar].TimeOfDay >= tsExitHour)
                    adBars[bar - 1] = Close[bar - 1];
                else if (Time[bar - 1].DayOfYear != Time[bar].DayOfYear &&
                         Time[bar - 1].TimeOfDay < tsExitHour)
                    adBars[bar - 1] = Close[bar - 1];
                else
                    adBars[bar] = 0;
            }

            // Check the last bar
            if (Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int) Period, 0)) == tsExitHour)
                adBars[Bars - 1] = Close[Bars - 1];

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
            {
                CompName = "Exit hour",
                DataType = IndComponentType.ClosePrice,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = false,
                FirstBar = firstBar,
                Value = adBars
            };
        }
 public static IMapLayer Insert(this IMapLayerCollection collection, int index, IDataSet dataset)
 {
     IFeatureSet featureSet = dataset as IFeatureSet;
     if (featureSet != null)
     {
         return collection.Insert(index, featureSet);
     }
     IRaster raster = dataset as IRaster;
     if (raster != null)
     {
         return collection.Insert(index, raster);
     }
     IImageData image = dataset as IImageData;
     if (image != null)
     {
         return collection.Insert(index, image);
     }
     return null;
 }
Example #53
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="box">Box to manage (mandatory)</param>
        /// <param name="editButton">Edit button (optional)</param>
        /// <param name="items">Items to populate with</param>
        /// <param name="includeNull">Whether to include an extra item for a "null" or empty selection.</param>
        public EditableComboBox([NotNull] ComboBox box, [CanBeNull] Button editButton, [NotNull] IDataSet items, EFlags flags)
        {
            this.ComboBox     = box;
            this._button      = editButton;
            this._includeNull = flags.Has(EFlags.IncludeNone) ? ENullItemName.RepresentingNone : flags.Has(EFlags.IncludeAll) ? ENullItemName.RepresentingAll : ENullItemName.NoNullItem;
            this._flags       = flags;
            this._config      = items;

            if (this._button != null)
            {
                this._button.Click += this._button_Click;
            }

            this.ComboBox.DrawMode              = DrawMode.OwnerDrawFixed;
            this.ComboBox.DrawItem             += this.ComboBox_DrawItem;
            this.ComboBox.DropDown             += this.ComboBox_DropDown; // Update on every drop-down in case something else modified the list
            this.ComboBox.SelectedIndexChanged += ComboBox_SelectedIndexChanged;
            this.UpdateItemsNoPreserve();                                 // Don't do this yet or we'll NRE if the caller has events on the combobox
        }
Example #54
0
        /// <summary>Partition the indices of a dataset into groups</summary>
        /// <returns>the grouped indices</returns>
        /// <param name='dataset'>a dataset</param>
        /// <param name='num_groups'>the number of groups</param>
        public static IList <IList <int> > PartitionIndices(this IDataSet dataset, int num_groups)
        {
            num_groups = Math.Min(num_groups, dataset.Count);
            var indices = dataset.RandomIndex;

            var groups = new IList <int> [num_groups];

            for (int i = 0; i < num_groups; i++)
            {
                groups[i] = new List <int>();
            }

            for (int index = 0; index < dataset.Count; index++)
            {
                groups[index % num_groups].Add(indices[index]);
            }

            return(groups);
        }
Example #55
0
        /// <summary>
        /// Adds the dataset specified to the file. Depending on whether this is a featureSet,
        /// Raster, or ImageData, this will return the appropriate layer for the map.
        /// </summary>
        /// <param name="dataSet">A dataset.</param>
        /// <returns>The IMapLayer to add.</returns>
        public virtual IMapLayer Add(IDataSet dataSet)
        {
            if (dataSet is ISelfLoadSet ss)
            {
                return(Add(ss));
            }

            if (dataSet is IFeatureSet fs)
            {
                return(Add(fs));
            }

            if (dataSet is IRaster r)
            {
                return(Add(r));
            }

            return(dataSet is IImageData id?Add(id) : null);
        }
Example #56
0
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            int hour = (int) IndParam.NumParam[0].Value;
            int minute = (int) IndParam.NumParam[1].Value;

            // Calculation
            const int firstBar = 2;
            double[] signal = new double[Bars];

            // Calculation of the logic
            for (int bar = firstBar; bar < Bars; bar++)
            {
                DateTime closeTime = Time[bar].AddMinutes((int) Period);
                if (closeTime.Hour == hour && closeTime.Minute == minute)
                    signal[bar] = 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
            {
                CompName = "Close out long position",
                DataType = IndComponentType.ForceCloseLong,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = true,
                FirstBar = firstBar,
                Value = signal
            };

            Component[1] = new IndicatorComp
            {
                CompName = "Close out short position",
                DataType = IndComponentType.ForceCloseShort,
                ChartType = IndChartType.NoChart,
                ShowInDynInfo = true,
                FirstBar = firstBar,
                Value = signal
            };
        }
Example #57
0
        public bool Propagate(IDataSet data, bool testing = false)
        {
            if (data.InputSet.Length != NumInputs || data.ExpectedOutputSet.Length != NumOutputs)
            {
                return(false);
            }

            if (InvalidatedNetwork == true)
            {
                Reset();
            }

            if (testing == true && CompletedBatches > 0)
            {
                BackPropagate();
                CompletedBatches = 0;
            }

            //for (uint i = 0; i < NumInputs; i++)
            //{
            //    InputLayer.Perceptrons[i].Outputs[CompletedBatches] = inputs[i];
            //}
            //for (uint i = 0; i < OutputLayer.Perceptrons.Length; i++)
            //{
            //    OutputLayer.Perceptrons[i].ExpectedOutputs[CompletedBatches] = expectedOutputs[i];
            //}

            InputLayer.UploadInputs(data.InputSet, CompletedBatches);
            OutputLayer.UploadExpectedOutputs(data.ExpectedOutputSet, CompletedBatches);

            ForwardPropagate();
            if (testing == false)
            {
                if (IncrementBatch() == false)
                {
                    CompletedBatches = (int)Batches;
                    BackPropagate();
                }
            }
            LastPropagateWasATest = testing;

            return(true);
        }
Example #58
0
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Calculation
            const int firstBar = 1;

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp
            {
                CompName      = "Stop to a transferred position",
                DataType      = IndComponentType.Other,
                ShowInDynInfo = false,
                FirstBar      = firstBar,
                Value         = new double[Bars]
            };
        }
        public DataSetConfiguration(NapDbConfiguration <TDb, TKey> dbConfig, IDataSet <TKey> dataSet)
        {
            DbConfig = dbConfig;
            DataSet  = dataSet;

            FolderName    = dataSet.Name;
            EnableCaching = false;
            Serializer    = GlobalDefaults.CreateDefaultSerializer <TKey>();
            Reader        = GlobalDefaults.CreateDefaultReader();
            NameResolver  = GlobalDefaults.CreateDefaultNameResolver <TKey>();

            PropertyConfigs = dataSet
                              .GetEntityType()
                              .GetProperties()
                              .Where(ReflectionHelper.IsPropertyConfigurable)
                              .ToDictionary(
                p => p.Name,
                p => new EntityPropertyConfiguration <TDb, TKey>(this, p));
        }
        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            int iFromDay  = (int)IndParam.NumParam[0].Value;
            int iUntilDay = (int)IndParam.NumParam[1].Value;

            // Calculation
            int iFirstBar = 1;
            double[] adBars = new double[Bars];

            // Calculation of the logic
            for (int iBar = iFirstBar; iBar < Bars; iBar++)
            {
                if (iFromDay < iUntilDay)
                    adBars[iBar] = Time[iBar].Day >= iFromDay && Time[iBar].Day <  iUntilDay ? 1 : 0;
                else if (iFromDay > iUntilDay)
                    adBars[iBar] = Time[iBar].Day >= iFromDay || Time[iBar].Day <  iUntilDay ? 1 : 0;
                else
                    adBars[iBar] = 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp();
            Component[0].CompName      = "Allow long entry";
            Component[0].DataType      = IndComponentType.AllowOpenLong;
            Component[0].ChartType     = IndChartType.NoChart;
            Component[0].ShowInDynInfo = false;
            Component[0].FirstBar      = iFirstBar;
            Component[0].Value         = adBars;

            Component[1] = new IndicatorComp();
            Component[1].CompName      = "Allow short entry";
            Component[1].DataType      = IndComponentType.AllowOpenShort;
            Component[1].ChartType     = IndChartType.NoChart;
            Component[1].ShowInDynInfo = false;
            Component[1].FirstBar      = iFirstBar;
            Component[1].Value         = adBars;
        }