예제 #1
0
 /// <summary>
 /// Buys shares of the stock
 /// </summary>
 /// <param name="processor">The processor triggering the action</param>
 /// <param name="target">The processing target that triggered the action</param>
 /// <param name="time">The time at which the action was triggered</param>
 public void Buy(StockProcessor processor, StockProcessor.ProcessingTarget target, DateTime time)
 {
     Broker.Instance.SubmitOrder(new Broker.Order()
     {
         Symbol   = target.Symbol,
         BuySell  = Broker.Order.BuySellType.BUY,
         Type     = Broker.Order.OrderType.MARKET,
         Quantity = 1
     });
 }
예제 #2
0
 /// <summary>
 /// Buys shares of the stock
 /// </summary>
 /// <param name="processor">The processor triggering the action</param>
 /// <param name="target">The processing target that triggered the action</param>
 /// <param name="time">The time at which the action was triggered</param>
 public void Sell(StockProcessor processor, StockProcessor.ProcessingTarget target, DateTime time)
 {
     Broker.Instance.GetPositionInfo(target.Symbol, (position) =>
     {
         Broker.Instance.SubmitOrder(new Broker.Order()
         {
             Symbol   = target.Symbol,
             BuySell  = Broker.Order.BuySellType.SELL,
             Type     = Broker.Order.OrderType.MARKET,
             Quantity = position.Shares
         });
     });
 }
        /// <summary>
        /// Evaluates
        /// </summary>
        /// <param name="data">The data set to work from</param>
        /// <param name="index">The index which should be evaluated</param>
        /// <param name="target">The reference point to use when evaluating the stock</param>
        /// <returns>True if the analyzer criteria is met at the given data point</returns>
        public override bool Evaluate(StockDataSet <StockDataSink> data, int index, StockProcessor.ProcessingTarget target)
        {
            float refPrice;

            if (!ReferencePrices.TryGetValue(target.Symbol, out refPrice))
            {
                refPrice = data[index].Price;
                ReferencePrices.Add(target.Symbol, refPrice);
            }
            var percentDiff = ((data[index].Price - refPrice) / refPrice);

            return(((percentDiff >= Percentage) && MonitorIncrease) ||
                   ((percentDiff <= -Percentage) && MonitorDecrease));
        }
 /// <summary>
 /// Evaluates
 /// </summary>
 /// <param name="data">The data set to work from</param>
 /// <param name="index">The index which should be evaluated</param>
 /// <param name="target">The reference point to use when evaluating the stock</param>
 /// <returns>True if the analyzer criteria is met at the given data point</returns>
 public abstract bool Evaluate(StockDataSet <StockDataSink> data, int index, StockProcessor.ProcessingTarget target);
예제 #5
0
 /// <summary>
 /// Buys shares of the stock
 /// </summary>
 /// <param name="processor">The processor triggering the action</param>
 /// <param name="target">The processing target that triggered the action</param>
 /// <param name="time">The time at which the action was triggered</param>
 public void Notify(StockProcessor processor, StockProcessor.ProcessingTarget target, DateTime time)
 {
     StockList.Instance.Add(StockList.NOTIFICATIONS, target.Symbol, new StockList.NotificationSummary(DataAccessor.Subscribe(target.Symbol, DataAccessor.SUBSCRIBE_ONE_SEC)));
 }