Ejemplo n.º 1
0
        /// <summary>
        /// Adds the signal.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">The name.</param>
        /// <param name="action">The action.</param>
        /// <param name="trigger">The trigger.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Universe trigger is empty for adding a trading event</exception>
        public TradingSignal AddSignal <T>(string name, Func <Security, bool> action, Dictionary <Security, T> trigger)
            where T : IndicatorBase <IndicatorDataPoint>
        {
            if (trigger.Count == 0)
            {
                throw new ArgumentNullException("Universe trigger is empty for adding a trading event");
            }

            //Get first item
            var foundtrigger = trigger.Values.First();

            //Create trading event
            TradingSignal nevent = new TradingSignal(Universe, name, action);

            foundtrigger.Updated += (sender, updated) =>
            {
                if (IsRunning)
                {
                    nevent.Execute();
                }
            };
            nevent.SignalFired  += OnSignal;
            Signals[nevent.Name] = nevent;
            return(nevent);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the signal.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="action">The action.</param>
        /// <param name="interval">The interval.</param>
        /// <returns></returns>
        public TradingSignal AddSignal(string name, Func <Security, bool> action, TimeSpan interval)
        {
            TradingSignal nevent = new TradingSignal(Universe, name, action, true);

            ScheduledActionsKeeper.Event(QuantFund.FundId, Date.EveryDay(), Time.Every(interval), () =>
            {
                if (IsRunning)
                {
                    nevent.Execute();
                }
            });
            Signals[nevent.Name] = nevent;
            return(nevent);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the signal.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="action">The action.</param>
        /// <param name="trigger">The trigger.</param>
        /// <returns></returns>
        public TradingSignal AddSignal(string name, Func <Security, bool> action, DataAggregator trigger)
        {
            TradingSignal nevent = new TradingSignal(Universe, name, action);

            trigger.DataAggregated += (sender, aggregate) =>
            {
                if (IsRunning)
                {
                    nevent.Execute();
                }
            };
            nevent.SignalFired  += OnSignal;
            Signals[nevent.Name] = nevent;
            return(nevent);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds the signal.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">The name.</param>
        /// <param name="action">The action.</param>
        /// <param name="trigger">The trigger.</param>
        /// <returns></returns>
        public TradingSignal AddSignal <T>(string name, Func <Security, bool> action, T trigger)
            where T : IndicatorBase <IndicatorDataPoint>
        {
            TradingSignal nevent = new TradingSignal(Universe, name, action);

            trigger.Updated += (sender, updated) =>
            {
                if (IsRunning)
                {
                    nevent.Execute();
                }
            };
            nevent.SignalFired  += OnSignal;
            Signals[nevent.Name] = nevent;
            return(nevent);
        }