Esempio n. 1
0
 public SecurityPrice(DateTime priceDate, double price, SecurityPrices prices)
 {
     PriceDate = priceDate;
     Price     = price;
     Prices    = prices;
     Index     = prices.Prices.Count;
 }
Esempio n. 2
0
        private void ExecuteStrategy()
        {
            var securityPrices   = new SecurityPrices(_secId);
            var listOfDataPoints = _marketDataPoints.ToList();

            for (int i = 0; i < listOfDataPoints.Count; i++)
            {
                var strategy = TradeIdentifyingStrategy.CreateNewInstance();

                var dataPoint = listOfDataPoints[i];

                securityPrices.Add(dataPoint.MarketDate, dataPoint.MarketDataPoint, strategy);

                var currentSecurity = securityPrices[i];

                currentSecurity.RunTradeIdentifier();

                strategy.SetSecurityPriceData(currentSecurity);

                _tradeStrategies.Add(strategy);
            }
        }
Esempio n. 3
0
        public SecurityPrices GetPreviousPrices(int periodsBack)
        {
            var security_prices = new SecurityPrices(Prices.SecurityId);
            var prices          = new List <SecurityPrice>(periodsBack);

            if (periodsBack < Index)
            {
                for (var i = 0; i <= periodsBack; i++)
                {
                    if (i == 0)
                    {
                        prices.Add(this);
                    }
                    else
                    {
                        var price = prices[i - 1].GetPreviousPrice();
                        prices.Add(price);
                    }
                }
                var c = prices.Count;
                if (c > 1)
                {
                    prices.RemoveAt(c - 1);
                }
                prices.Reverse();

                //remove the last price so that periods actually equal count of items. we are including current item in collection so we remove the last.
                foreach (var sprice in prices)
                {
                    security_prices.Add(sprice);
                }
                return(security_prices);
            }
            else
            {
                return(null);
            }
        }