コード例 #1
0
    public DatedDataCollectionGen<double> GetSeries(Periodicity type_)
    {
      if (m_lastType == type_ && m_cachedSeries != null)
        return m_cachedSeries;

      m_lastType = type_;


      var ds = m_eval.ToPeriod(type_, DoubleCollationType.Sum);

      if (m_lag == 0)
      {
        m_cachedSeries = ds;
        return ds;
      }

      double[] values=new double[ds.Data.Length-m_lag];
      DateTime[] dates=new DateTime[ds.Data.Length-m_lag];

      for (int i = m_lag; i < ds.Data.Length; ++i)
      {
        values[i-m_lag]=ds.Data[i-m_lag];
        dates[i-m_lag]=ds.Dates[i];
      }

      m_cachedSeries = ds = new DatedDataCollectionGen<double>(dates, values);

      return ds;
    }
コード例 #2
0
ファイル: DataRequest.cs プロジェクト: CosimoDeMedici/Duomo
        private static string PeriodicityToUrlChar(Periodicity periodicity)
        {
            switch (periodicity)
            {
                case Duomo.Common.Lib.Yahoo.Periodicity.Daily:
                    return "d";

                default:
                    throw new ArgumentException("Unrecognized periodicity.", "periodicity");
            }
        }
コード例 #3
0
        public static YahooHistoricalDataTable Run(string ticker, DateTime startDate, DateTime endDate, Periodicity periodicity)
        {
            DataRequest request = new DataRequest();
            request.Ticker = ticker;
            request.StartDate = startDate;
            request.EndDate = endDate;
            request.Periodicity = periodicity;

            string url = request.ToURL();

            string csvString = WebDataRequester.GetStringResponse(url);

            YahooHistoricalDataTable retValue = new YahooHistoricalDataTable();
            retValue.ParseCsvString(ticker, csvString);

            return retValue;
        }
コード例 #4
0
ファイル: StorageConvert.cs プロジェクト: ifzz/FDK
        public static BarPeriod ToBarPeriod(Periodicity periodicity)
		{
			var st = periodicity.ToString();
			if (st == "S1")
			{
				return BarPeriod.S1;
			}
			if (st == "S10")
			{
				return BarPeriod.S10;
			}
			if (st == "M1")
			{
				return BarPeriod.M1;
			}
			if (st == "M5")
			{
				return BarPeriod.M5;
			}
			if (st == "M15")
			{
				return BarPeriod.M15;
			}
			if (st == "H1")
			{
				return BarPeriod.H1;
			}
			if (st == "H4")
			{
				return BarPeriod.H4;
			}
			if (st == "D1")
			{
				return BarPeriod.D1;
			}
			if (st == "MN1")
			{
				return BarPeriod.MN1;
			}

			throw new ArgumentException("Unknown periodicity = " + st);
		}
コード例 #5
0
        public void RecurringTransactionWithTransactionRegisteredOnCurrentPeriodShouldReturnOnlyFuture(Periodicity periodicity, int assertCount)
        {
            var passedTransactionDate = DateTime.Today;
            var recurStartDate        = DateTime.Today.AddDays(-1);
            var rT     = new RecurringTransactionFactory().WithCreditDefaultValues().WithPeriodicity(periodicity).WithStartDate(recurStartDate).WithCurrency(new Currency()).WithPassedTransactionOn(passedTransactionDate).Build();
            var future = rT.GetFutureTransaction();
            var dates  = GetLimitDates(periodicity, passedTransactionDate);

            future.Should().HaveCount(assertCount);
            future.Where(f => dates.Item1 < f.Date && f.Date < dates.Item2).Should().BeEmpty();
        }
コード例 #6
0
ファイル: SmartStorage.cs プロジェクト: ifzz/FDK
        static void ForwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, ICollection<HistoryBar> bars)
        {
            try
            {
                for (var current = startTime; current < endTime; )
                {
                    var report = cache.QueryBarHistory(current, -RequestedBarsNumber, symbol, periodicity.ToString(), priceType);
                    var items = report.Items;

                    foreach (var element in report.Items)
                    {
                        if (element.Time >= endTime)
                        {
                            return;
                        }
                        bars.Add(element);
                    }
                    if (items.Count == 0)
                    {
                        return;
                    }
                    current = items.Last().Time;
                    current = current + periodicity;
                }
            }
            catch (StorageHistoryNotFoundException)
            {
            }
        }
コード例 #7
0
 private Tuple <DateTime, DateTime> GetLimitDates(Periodicity periodicity, in DateTime passedTransactionDate)
コード例 #8
0
ファイル: ORequestContract.cs プロジェクト: Rab815/BBWebApi
 public void SetPeriodicityAdjustment(Periodicity periodicity)
 {
     _periodicity = periodicity;
 }
コード例 #9
0
ファイル: Plugin.cs プロジェクト: rodyan/amibroker
        public static unsafe int GetQuotesEx(string ticker, Periodicity periodicity, int lastValid, int size, Quotation* quotes, GQEContext* context)
        {
            // TODO: Add logic here. Take a look at the demo below:

            Debug.WriteLine("GetQuotesEx(ticker: " + ticker + ", periodicity: " + periodicity + ", lastValid: " + lastValid + ", size: " + size + ", ...)");

            /*for (var i = 0; i < 5; i++)
            {
                quotes[i].DateTime = new AmiDate(DateTime.Now.AddDays(i - 5));
                quotes[i].Price = 10;
                quotes[i].Open = 15;
                quotes[i].High = 16;
                quotes[i].Low = 9;
                quotes[i].Volume = 1000;
                quotes[i].OpenInterest = 0;
                quotes[i].AuxData1 = 0;
                quotes[i].AuxData2 = 0;
            }

            return 5;*/

            // return 'lastValid + 1' if no updates are found and you want to keep all existing records
            return lastValid + 1;
        }
コード例 #10
0
ファイル: Plugin.cs プロジェクト: modulexcite/amibroker
        public static unsafe int GetQuotesEx(string ticker, Periodicity periodicity, int lastValid, int size, Quotation* quotes, GQEContext* context)
        {
            Debug.WriteLine("GetQuotesEx(ticker: " + ticker + ", periodicity: " + periodicity + ", lastValid: " + lastValid + ", size: " + size + ", ...)");

            var existingQuotes = new Quotation[0];

            if (lastValid > 2)
            {
                Array.Resize<Quotation>(ref existingQuotes, lastValid + 1);

                for (var i = 0; i <= lastValid; i++)
                {
                    existingQuotes[i] = new Quotation
                    {
                        DateTime = quotes[i].DateTime,
                        Open = quotes[i].Open,
                        High = quotes[i].High,
                        Low = quotes[i].Low,
                        Price = quotes[i].Price,
                        Volume = quotes[i].Volume,
                        OpenInterest = quotes[i].OpenInterest,
                        AuxData1 = quotes[i].AuxData1,
                        AuxData2 = quotes[i].AuxData2
                    };
                }

                Array.Sort<Quotation>(existingQuotes, new Comparison<Quotation>((q1, q2) => q1.DateTime.CompareTo(q2.DateTime)));
            }

            var newQuotes = DataSource.GetQuotes(ticker, periodicity, size, existingQuotes);

            if (newQuotes.Any())
            {
                lastValid = 0;
                for (var i = 0; i < newQuotes.Length; i++)
                {
                    quotes[i].DateTime = newQuotes[i].DateTime;
                    quotes[i].Price = newQuotes[i].Price;
                    quotes[i].Open = newQuotes[i].Open;
                    quotes[i].High = newQuotes[i].High;
                    quotes[i].Low = newQuotes[i].Low;
                    quotes[i].Volume = newQuotes[i].Volume;
                    quotes[i].OpenInterest = newQuotes[i].OpenInterest;
                    quotes[i].AuxData1 = newQuotes[i].AuxData1;
                    quotes[i].AuxData2 = newQuotes[i].AuxData2;
                    lastValid++;
                }

                return lastValid;
            }

            // return 'lastValid + 1' if no updates are found and you want to keep all existing records
            return lastValid + 1;
        }
コード例 #11
0
        public void AddChart(CtlPainelChart chart, DockWindow Window, XmlNode Propriedades, XmlNode node, string simbolo, Periodicity periodicity, int barSize, int mBars, string windowName)
        {
            chart.StockChartX1.Visible = false;

            chart.LoadCtlPainelChart(frmMain2.GInstance, frmMain2.GInstance._mCtlData, simbolo, periodicity, barSize,
                                     mBars, "Plena", true);


            chart.StateDummy       = true;
            chart.BlockUpdateStock = true;
            chart.m_StopLoadScroll = true;
            Window.Controls.Add(chart);
            chart.BlockUpdateStock = false;
            frmMain2.XmlChartPropriedades(chart, Propriedades);
            if (Window.DockState == DockState.Floating)
            {
                Window.FloatingParent.ShowInTaskbar   = true;
                Window.FloatingParent.MinimizeBox     = true;
                Window.FloatingParent.MaximizeBox     = true;
                Window.FloatingParent.FormBorderStyle = FormBorderStyle.Sizable;
                Window.FloatingParent.Activated      += new EventHandler(frmMain2.GInstance.Window_Activated);
                Window.FloatingParent.Closing        += new System.ComponentModel.CancelEventHandler(frmMain2.GInstance.Window_Closing);
                frmMain2.Window_Initialize(Window, chart);
            }

            if ((node["VISIBLE"] != null) && (node["VISIBLE"].InnerText.Equals("0")))
            {
                return;
            }
            chart.StateDummy = false;
            chart.InitRTChartAsync(b => chart._asyncOp.Post(() =>
            {
                if (b)
                {
                    chart.StockChartX1.FirstVisibleRecord = int.Parse(Propriedades["FIRST_VISIBLE_RECORD"].InnerText);
                    chart.StockChartX1.LastVisibleRecord  = int.Parse(Propriedades["LAST_VISIBLE_RECORD"].InnerText);
                    chart.BindContextMenuEvents();
                    chart.m_SchemeColor = Propriedades["COLOR"].InnerText;
                    Scheme.Instance().UpdateChartColors(chart.StockChartX1, chart.m_SchemeColor);
                    //chart.StockChartX1.Update();
                    //chart.StockChartX1.ForcePaint();
                    frmMain2.GInstance.MActiveChart = chart;
                    chart.LoadDataTemplate("-987654321.123456789");
                    chart.UpdateMenus();
                    chart.StockChartX1.Visible = true;
                    chart.StockChartX1.Width   = chart.Width - 4;
                    //frmMain2.GInstance.LoadColorScheme(chart);
                    if (File.Exists(windowName))
                    {
                        chart.StockChartX1.LoadGeneralTemplate(windowName);
                    }
                    chart.LoadScroll();
                    return;
                }
                return;
            }));
        }
コード例 #12
0
 ///// <summary>
 ///// GetExtra data is optional function for retrieving non-quotation data
 ///// </summary>
 public static AmiVar GetExtraData(string ticker, string name, int arraySize, Periodicity periodicity, Alloc alloc)
 {
     return(new AmiVar());
 }
コード例 #13
0
 static void BackwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, List <HistoryBar> bars)
 {
     ForwardFillBars(cache, symbol, periodicity, priceType, endTime, startTime, bars);
     bars.Reverse();
 }
コード例 #14
0
ファイル: ctlAlert.cs プロジェクト: Ales999/plena
 public void BarUpdate(string Symbol, Periodicity BarType, int BarSize, M4.DataServer.Interface.BarData Bar, bool IsNewBar)
 {
 }
コード例 #15
0
 protected override IEnumerable <IEnumerable <PointInTime> > GetPoints(int projectId, DateRange dateRange, Periodicity periodicity)
 {
     return(this.MetricsService.GetMetricData(projectId, dateRange, periodicity));
 }
コード例 #16
0
        protected override List <HistoryBar> RequestHistory(DateTime timestamp, int count)
        {
            var result = new List <HistoryBar>(Math.Abs(count));

            if (count == 0)
            {
                return(result);
            }

            try
            {
                var report = _historyClient.QueryQuoteHistoryBars(timestamp, count, Symbol, Periodicity.ToString(), (PriceType.HasValue && (PriceType.Value == FxPriceType.Ask)) ? TTQuoteHistoryClient.PriceType.Ask : TTQuoteHistoryClient.PriceType.Bid);
                var bars   = report.Select(srcBar =>
                {
                    var dstBar = new HistoryBar
                    {
                        Time  = srcBar.Time,
                        Open  = srcBar.Open,
                        Hi    = srcBar.High,
                        Low   = srcBar.Low,
                        Close = srcBar.Close
                    };
                    return(dstBar);
                });
                result.AddRange(bars);
            }
            catch (Exception) {}

            return(result);
        }
コード例 #17
0
 protected override DateTime NormalizeTimestamp(DateTime timestamp)
 {
     return(Periodicity.GetPeriodStartTime(timestamp));
 }
コード例 #18
0
 public void setPeriod(Periodicity x)
 {
     period = x;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeSeriesOnSpeciesObservationAbundanceIndexExcelXlsx"/> class.
 /// </summary>
 /// <param name="currentUser">Current user context.</param>
 /// <param name="periodicity">Periodicity</param>
 /// <param name="addSettings">True if settings sheet should be included</param>
 /// <param name="addProvenance">True if provenance sheet should be included.</param>
 public TimeSeriesOnSpeciesObservationAbundanceIndexExcelXlsx(IUserContext currentUser, Periodicity periodicity, bool addSettings, bool addProvenance)
 {
     IsColumnHeaderBackgroundUsed = true;
     base.currentUser             = currentUser;
     base.addSettings             = addSettings;
     base.addProvenance           = addProvenance;
     _periodicity = periodicity;
 }
コード例 #20
0
ファイル: YDataSource.cs プロジェクト: seenuchennai/shubanet
 public override bool SetTimeBase(Periodicity timeBase)
 {
     // Yahoo can return 1 min, 5 min and daily bars
     return(timeBase == Periodicity.OneMinute || timeBase == Periodicity.FiveMinutes || timeBase == Periodicity.EndOfDay);
 }
コード例 #21
0
 public void BarUpdate(string Symbol, Periodicity BarType, int BarSize, BarData Bar, bool IsNewBar)
 {
 }
コード例 #22
0
ファイル: YDatabase.cs プロジェクト: seenuchennai/shubanet
        internal AmiVar GetExtraData(string ticker, string name, Periodicity periodicity, int arraySize)
        {
            if (!connected)
            {
                return(new AmiVar(ATFloat.Null));            // to prevent AFL engine to report AFL method call failure
            }
            try
            {
                TickerData tickerData = tickers.GetTickerData(ticker);

                // if it is a new ticker or  data is not available yet
                if (string.IsNullOrEmpty(name) | tickerData == null)
                {
                    return(new AmiVar(ATFloat.Null));        // to prevent AFL engine to report AFL method call failure
                }

                lock (tickerData)
                {
                    string[] parts = name.Split('.');
                    object   obj   = tickerData;
                    Type     type;

                    // walk the object hierarchy using reflection
                    for (int i = 0; i < parts.GetLength(0); i++)
                    {
                        type = obj.GetType();
                        obj  = type.InvokeMember(parts[i], BindingFlags.Default | BindingFlags.GetField | BindingFlags.GetProperty, null, obj, null);
                        if (obj == null && i < parts.GetLength(0) - 1)
                        {
                            LogAndMessage.LogAndAdd(MessageType.Warning, "Extra data field does not exist: " + name, tickerData);
                            return(new AmiVar(ATFloat.Null));            // to prevent AFL engine to report AFL method call failure
                        }
                    }

                    // convert object value to AmiVar and return it to AB

                    if (obj == null)       // it was a string or an object
                    {
                        return(new AmiVar(""));
                    }

                    Type valType = obj.GetType();

                    if (valType == typeof(bool))
                    {
                        return(new AmiVar((bool)obj ? 1.0f : 0.0f));
                    }

                    if (valType.BaseType == typeof(System.Enum))
                    {
                        return(new AmiVar((int)obj));
                    }

                    if (valType == typeof(short))
                    {
                        return(new AmiVar((short)obj));
                    }

                    if (valType == typeof(int))
                    {
                        return(new AmiVar((int)obj));
                    }

                    if (valType == typeof(long))
                    {
                        return(new AmiVar((long)obj));
                    }

                    if (valType == typeof(float))
                    {
                        return(new AmiVar((float)obj));
                    }

                    if (valType == typeof(double))
                    {
                        return(new AmiVar((float)(double)obj));
                    }

                    if (valType == typeof(string))
                    {
                        return(new AmiVar((string)obj));
                    }

                    if (valType == typeof(DateTime))
                    {
                        return(new AmiVar(ATFloat.DateTimeToABDateNum((DateTime)obj)));
                    }

                    if (valType == typeof(TimeSpan))
                    {
                        return(new AmiVar(ATFloat.TimeSpanToABTimeNum((TimeSpan)obj)));
                    }

                    return(new AmiVar(ATFloat.Null));            // to prevent AFL engine to report AFL method call failure
                }
            }
            catch (MissingMethodException)
            {
                LogAndMessage.LogAndAdd(MessageType.Warning, "Extra data field does not exist: " + name);
                return(new AmiVar(ATFloat.Null));                // to prevent AFL engine to report AFL method call failure
            }
            catch (Exception ex)
            {
                LogAndMessage.LogAndAdd(MessageType.Error, "Failed to get extra data: " + ex);
                return(new AmiVar(ATFloat.Null));                // to prevent AFL engine to report AFL method call failure
            }
        }
コード例 #23
0
 public Quotation[] GetQuotes(string ticker, Periodicity periodicity, int limit, Quotation[] existingQuotes)
 {
     // TODO: Return the list of quotes for the specified ticker.
     return(new Quotation[] { });
 }
        public async Task <IReadOnlyList <InventorySnapshotBriefModel> > GetTimelineAsync(DateTime startDate, DateTime endDate, Periodicity periodicity)
        {
            var snapshots = await _inventorySnapshotService.GetAsync(startDate, endDate, (Core.Domain.InventorySnapshots.Periodicity) periodicity);

            var model = Mapper.Map <List <InventorySnapshotBriefModel> >(snapshots);

            return(model);
        }
 /// <summary>
 /// Get number of observation for each time step determinined by search criteria and time step type.
 /// </summary>
 /// <param name="clientInformation">Information about the client that makes this web service call.</param>
 /// <param name="searchCriteria">The species observation search criteria.</param>
 /// <param name="periodicity">Time step type.</param>
 /// <param name="coordinateSystem">Coordinate system used for polygons in species observation search criteria.</param>
 /// <returns></returns>
 public List <WebTimeStepSpeciesObservationCount> GetTimeSpeciesObservationCounts(WebClientInformation clientInformation,
                                                                                  WebSpeciesObservationSearchCriteria searchCriteria,
                                                                                  Periodicity periodicity,
                                                                                  WebCoordinateSystem coordinateSystem)
 {
     using (ClientProxy client = new ClientProxy(this, 5))
     {
         return(client.Client.GetTimeSpeciesObservationCountsBySpeciesObservationSearchCriteria(clientInformation, searchCriteria, periodicity, coordinateSystem));
     }
 }
コード例 #26
0
ファイル: SmartStorage.cs プロジェクト: ifzz/FDK
 static void BackwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, List<HistoryBar> bars)
 {
     ForwardFillBars(cache, symbol, periodicity, priceType, endTime, startTime, bars);
     bars.Reverse();
 }
コード例 #27
0
ファイル: YDataSource.cs プロジェクト: seenuchennai/shubanet
 public override AmiVar GetExtraData(string ticker, string name, Periodicity periodicity, int arraySize)
 {
     return(database.GetExtraData(ticker, name, periodicity, arraySize));
 }
コード例 #28
0
 protected override IEnumerable <PointInTime> GetPoints(int projectId, DateRange dateRange, Periodicity periodicity)
 {
     return(this.StatisticsProvider.GetVideos(projectId, dateRange, periodicity));
 }
コード例 #29
0
        public IEnumerable <PointInTime> GetEntitiesForChart <T>(IEnumerable <T> query, DateRange range, Periodicity periodicity, Func <IEnumerable <T>, double> getValueFunc) where T : DateEntity
        {
            IList <PointInTime> result = new List <PointInTime>();
            var timeIncrease           = this.GetTimeIncreaseFunction(periodicity);
            var executedQuery          = query.ToList();

            for (var date = range.From; date < range.To; date = timeIncrease(date))
            {
                IEnumerable <T> entities = executedQuery.Where(x => (x.PostedDate >= date) && (x.PostedDate < timeIncrease(date))).ToList();

                result.Add(new PointInTime
                {
                    Date  = date,
                    Value = getValueFunc(entities)
                });
            }

            return(result);
        }
コード例 #30
0
        protected override IEnumerable <IEnumerable <PointInTime> > GetPoints(int projectId, DateRange dateRange, Periodicity periodicity)
        {
            // TODO: .SkipWhile(x, e => e.Value == 0))
            var result = this.MetricsService.GetUsersCount(projectId, dateRange, periodicity);

            return(result);
        }
コード例 #31
0
        unsafe public static int GetQuotesEx(string ticker, Periodicity periodicity, int lastValid, int size, Quotation *quotes, GQEContext *context)
        {
            // TODO: Add logic here. Take a look at the demo below:
            int    i         = 0;
            string chktmp    = ConfigurationManager.AppSettings["txtTargetFolderforami"];
            string timerflag = ConfigurationManager.AppSettings["timerflag"];

            if (timerflag == "1")
            {
                Status = StatusCode.OK;
            }
            if (timerflag == "2")
            {
                Status = StatusCode.Unknown;
            }
            try
            {
                string tempfilepath = chktmp + "\\ShubhaRT.txt";
                int    flag         = 0;
                string datatostore  = ticker;

                string Openinterest1 = ConfigurationManager.AppSettings["Openinterest"];
                string Open1         = ConfigurationManager.AppSettings["Open"];
                string High1         = ConfigurationManager.AppSettings["High"];
                string Low1          = ConfigurationManager.AppSettings["Low"];
                string Volume1       = ConfigurationManager.AppSettings["Volume"];

                string Ask1 = ConfigurationManager.AppSettings["Ask"];
                string Bid1 = ConfigurationManager.AppSettings["Bid"];

                string Preset1           = ConfigurationManager.AppSettings["preset"];
                string servername1       = ConfigurationManager.AppSettings["servername"];
                string refreshtime1      = ConfigurationManager.AppSettings["interval"];
                int    volumecount       = 0;
                int    openinterestcount = 0;
                int    opencount         = 0;
                int    highcount         = 0;
                int    lowcount          = 0;
                int    askcount          = 0;
                int    bidcount          = 0;
                int    count             = 2;
                //first 2 position of file is for 1.LTT,2.LTP,3.Volume
                if (Volume1 != "")
                {
                    //if user want openint it come at position 4 in file
                    count++;
                    volumecount = count;
                }
                if (Openinterest1 != "")
                {
                    //if user want openint it come at position 4 in file
                    count++;
                    openinterestcount = count;
                }
                if (Open1 != "")
                {
                    count++;
                    opencount = count;
                }
                if (High1 != "")
                {
                    count++;
                    highcount = count;
                }
                if (Low1 != "")
                {
                    count++;
                    lowcount = count;
                }

                if (Ask1 != "")
                {
                    count++;
                    askcount = count;
                }
                if (Bid1 != "")
                {
                    count++;
                    bidcount = count;
                }

                ////////////////////////////////
                string[] wordsdata1 = ticker.Split('|');
                if (wordsdata1[1].Contains("-"))
                {
                    wordsdata1[1] = wordsdata1[1].Substring(0, wordsdata1[1].Length - 3);
                }

                if (!File.Exists(chktmp + "\\" + wordsdata1[1] + ".csv"))
                {
                    return(0);
                }
                ////////////////////////////////imp

                using (var reader = new StreamReader(chktmp + "\\" + wordsdata1[1] + ".csv"))
                {
                    string line = null;

                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] wordsdata = line.Split(',');

                        DateTime date     = Convert.ToDateTime(wordsdata[0]);
                        TimeSpan time     = TimeSpan.Parse(wordsdata[1]);
                        DateTime dateTime = date.Add(time);


                        quotes[i].DateTime = PackDate(dateTime.AddDays(0));

                        quotes[i].Price = float.Parse(wordsdata[2], CultureInfo.InvariantCulture.NumberFormat);// Convert.ToInt32(wordsdata[3]);
                        if (volumecount == 0)
                        {
                            quotes[i].Volume = 0;
                        }
                        else
                        {
                            quotes[i].Volume = float.Parse(wordsdata[volumecount], CultureInfo.InvariantCulture.NumberFormat);//Convert.ToInt32(wordsdata[4]);
                        }
                        if (opencount == 0)
                        {
                            quotes[i].Open = float.Parse(wordsdata[2], CultureInfo.InvariantCulture.NumberFormat);// Convert.ToInt32(wordsdata[3]);;
                        }
                        else

                        {
                            quotes[i].Open = float.Parse(wordsdata[opencount], CultureInfo.InvariantCulture.NumberFormat);//Convert.ToInt32(wordsdata[3]);
                        }

                        if (highcount == 0)
                        {
                            quotes[i].High = float.Parse(wordsdata[2], CultureInfo.InvariantCulture.NumberFormat);// Convert.ToInt32(wordsdata[3]);;
                        }
                        else
                        {
                            quotes[i].High = float.Parse(wordsdata[highcount], CultureInfo.InvariantCulture.NumberFormat);//Convert.ToInt32(wordsdata[3]);
                        }


                        if (lowcount == 0)
                        {
                            quotes[i].Low = float.Parse(wordsdata[2], CultureInfo.InvariantCulture.NumberFormat);// Convert.ToInt32(wordsdata[3]);;
                        }
                        else
                        {
                            quotes[i].Low = float.Parse(wordsdata[lowcount], CultureInfo.InvariantCulture.NumberFormat);// Convert.ToInt32(wordsdata[3]);
                        }

                        if (openinterestcount == 0)
                        {
                            quotes[i].OpenInterest = 0;
                        }
                        else
                        {
                            quotes[i].OpenInterest = float.Parse(wordsdata[openinterestcount], CultureInfo.InvariantCulture.NumberFormat);;
                        }

                        if (askcount == 0)
                        {
                            quotes[i].AuxData1 = 0;
                        }
                        else
                        {
                            quotes[i].AuxData1 = float.Parse(wordsdata[askcount], CultureInfo.InvariantCulture.NumberFormat);;
                        }

                        if (bidcount == 0)
                        {
                            quotes[i].AuxData2 = 0;
                        }
                        else
                        {
                            quotes[i].AuxData2 = float.Parse(wordsdata[bidcount], CultureInfo.InvariantCulture.NumberFormat);
                        }
                        i++;
                    }
                }
            }
            catch
            {
            }
            return(i);
        }
コード例 #32
0
        // not yest implimented
        public static List <ForexPriceRecord> Compress(this List <ForexPriceRecord> recs, string symbol, Periodicity period)
        {
            if (period == Periodicity.OneMinute)
            {
                return(recs);
            }

            List <ForexPriceRecord> cp = recs.Where(r => r.Symbol.Equals(symbol)).OrderBy(p => p.PriceDateTime).ToList();

            if (cp.Count < 2)
            {
                return(cp);
            }

            List <ForexPriceRecord> newRecs  = new List <ForexPriceRecord>();
            List <ForexPriceRecord> tempRecs = new List <ForexPriceRecord>();
            ForexPriceRecord        tempRec  = new ForexPriceRecord();

            ForexPriceRecord firstRec = cp.First();
            ForexPriceRecord lastRec  = cp.Last();

            int minutes = (int)period;

            double OpenPrice    = firstRec.Open;
            double BidOpenPrice = firstRec.BidOpen;
            double AskOpenPrice = firstRec.AskOpen;
            double mult         = firstRec.PipMultiplier;


            #region csv recs in 1 minute tf

            /*
             * AUDCAD	02/04/2009 12:00:00 AM +00:00	0	0	0	0	0.79936	0.79953	0.79932	0.79953	0.80073	0.80085	0.8005	0.80081
             * AUDCAD	02/04/2009 12:01:00 AM +00:00	0	0	0	0	0.79953	0.79973	0.79945	0.79973	0.80081	0.80092	0.80081	0.80092
             * AUDCAD	02/04/2009 12:02:00 AM +00:00	0	0	0	0	0.79973	0.79993	0.79925	0.79957	0.80092	0.80144	0.80064	0.80076
             * AUDCAD	02/04/2009 12:03:00 AM +00:00	0	0	0	0	0.79957	0.79957	0.79905	0.79909	0.80076	0.80076	0.80016	0.80022
             * AUDCAD	02/04/2009 12:04:00 AM +00:00	0	0	0	0	0.79909	0.79959	0.79909	0.79943	0.80022	0.8008	0.80022	0.80059
             * AUDCAD	02/04/2009 12:05:00 AM +00:00	0	0	0	0	0.79943	0.79953	0.79931	0.79948	0.80059	0.80073	0.80047	0.80068
             * AUDCAD	02/04/2009 12:06:00 AM +00:00	0	0	0	0	0.79948	0.79954	0.79936	0.79936	0.80068	0.80075	0.80056	0.80056
             * AUDCAD	02/04/2009 12:07:00 AM +00:00	0	0	0	0	0.79936	0.79961	0.79903	0.79959	0.80056	0.80091	0.80044	0.8008
             * AUDCAD	02/04/2009 12:08:00 AM +00:00	0	0	0	0	0.79959	0.79959	0.79941	0.79948	0.8008	0.8008	0.80061	0.80068
             * AUDCAD	02/04/2009 12:09:00 AM +00:00	0	0	0	0	0.79948	0.80004	0.79936	0.80004	0.80068	0.80123	0.80056	0.80123
             * AUDCAD	02/04/2009 12:10:00 AM +00:00	0	0	0	0	0.80004	0.80039	0.8	0.80039	0.80123	0.80149	0.80117	0.80149
             * AUDCAD	02/04/2009 12:11:00 AM +00:00	0	0	0	0	0.80039	0.80045	0.79989	0.80035	0.80149	0.80155	0.80136	0.80148
             * AUDCAD	02/04/2009 12:12:00 AM +00:00	0	0	0	0	0.80035	0.80043	0.80029	0.80029	0.80148	0.80154	0.80142	0.80142
             * AUDCAD	02/04/2009 12:13:00 AM +00:00	0	0	0	0	0.80029	0.80035	0.80018	0.8002	0.80142	0.80142	0.80136	0.80136
             * AUDCAD	02/04/2009 12:14:00 AM +00:00	0	0	0	0	0.8002	0.80037	0.79963	0.79989	0.80136	0.80156	0.80107	0.80107
             * AUDCAD	02/04/2009 12:15:00 AM +00:00	0	0	0	0	0.79989	0.80012	0.79965	0.79972	0.80107	0.80129	0.80085	0.80091
             * AUDCAD	02/04/2009 12:16:00 AM +00:00	0	0	0	0	0.79972	0.80041	0.79972	0.79984	0.80091	0.80176	0.80091	0.80119
             * AUDCAD	02/04/2009 12:17:00 AM +00:00	0	0	0	0	0.79984	0.80049	0.79984	0.80034	0.80119	0.80174	0.80119	0.80152
             * AUDCAD	02/04/2009 12:18:00 AM +00:00	0	0	0	0	0.80034	0.80093	0.79982	0.80062	0.80152	0.80224	0.80151	0.80193
             * AUDCAD	02/04/2009 12:19:00 AM +00:00	0	0	0	0	0.80062	0.80074	0.80019	0.80019	0.80193	0.80198	0.80147	0.80147
             */

            #endregion

            DateTimeOffset lastDto         = lastRec.PriceDateTime;
            DateTimeOffset currDto         = firstRec.PriceDateTime;
            bool           hasBidAskPrices = firstRec.HasBidAskPrices;
            ForexPriceRecord.ShowPriceOptionsEnum showPriceOpts = firstRec.ShowPriceOptions;
            int symbolId = firstRec.SymbolId;

            while (currDto <= lastDto)
            {
                DateTimeOffset endPeriodDto = currDto.AddMinutes(minutes);

                if (endPeriodDto > lastDto)
                {
                    endPeriodDto = lastDto.AddMinutes(10);
                }

                ForexPrices pr = new ForexPrices()
                {
                    PriceRecords = (from r in recs
                                    where r.PriceDateTime >= currDto & r.PriceDateTime < endPeriodDto
                                    select r).ToList()
                };

                var ts = pr.SymbolTimeStats.FirstOrDefault() as ForexPriceRecordBase;
                tempRecs.Add(new ForexPriceRecord()
                {
                    BidOpen          = ts.BidOpen,
                    BidHigh          = ts.BidHigh,
                    BidLow           = ts.BidLow,
                    BidClose         = ts.BidClose,
                    AskOpen          = ts.AskOpen,
                    AskHigh          = ts.AskHigh,
                    AskLow           = ts.AskLow,
                    AskClose         = ts.AskClose,
                    Open             = ts.Open,
                    High             = ts.High,
                    Low              = ts.Low,
                    Close            = ts.Close,
                    HasBidAskPrices  = hasBidAskPrices,
                    PriceDateTime    = currDto,
                    ShowPriceOptions = showPriceOpts,
                    Symbol           = symbol,
                    SymbolId         = symbolId
                });

                currDto = endPeriodDto;

                if (currDto >= lastDto)
                {
                    break;
                }
            }

            return(tempRecs);
        }
コード例 #33
0
ファイル: Plugin.cs プロジェクト: rodyan/amibroker
 public static AmiVar GetExtraData(string ticker, string name, int arraySize, Periodicity periodicity, Alloc alloc)
 {
     return new AmiVar();
 }
コード例 #34
0
        /// <summary>
        /// Creates an xml excel file with the number of observed species over a selected period of time.
        /// </summary>
        /// <param name="currentUser">Current user context</param>
        /// <param name="periodicity">The periodicity.</param>
        /// <param name="addSettings">True if settings sheet should be included</param>
        /// <param name="addProvenance">True if provenance sheet should be included.</param>
        /// <returns>The xml excel file.</returns>
        public static TimeSeriesOnSpeciesObservationCountsExcelXml GetTimeSeriesOnSpeciesObservationCountsAsExcelXml(IUserContext currentUser, Periodicity periodicity, bool addSettings, bool addProvenance)
        {
            TimeSeriesOnSpeciesObservationCountsExcelXml file = new TimeSeriesOnSpeciesObservationCountsExcelXml(currentUser, periodicity, addSettings, addProvenance);

            return(file);
        }
コード例 #35
0
ファイル: DataSource.cs プロジェクト: modulexcite/amibroker
 public Quotation[] GetQuotes(string ticker, Periodicity periodicity, int limit, Quotation[] existingQuotes)
 {
     // TODO: Return the list of quotes for the specified ticker.
     return new Quotation[] { };
 }
コード例 #36
0
 /// <summary>
 /// Creates an xlsx excel file with time series statistics on species observation abundance index.
 /// </summary>
 /// <param name="currentUser">Current user context</param>
 /// <param name="periodicity">The periodicity.</param>
 /// <param name="addSettings">True if settings sheet should be included</param>
 /// <param name="addProvenance">True if provenance sheet should be included.</param>
 /// <returns>The xlsx excel file.</returns>
 public static TimeSeriesOnSpeciesObservationAbundanceIndexExcelXlsx GetTimeSeriesOnSpeciesObservationAbundanceIndexAsExcelXlsx(IUserContext currentUser, Periodicity periodicity, bool addSettings, bool addProvenance)
 {
     return(new TimeSeriesOnSpeciesObservationAbundanceIndexExcelXlsx(currentUser, periodicity, addSettings, addProvenance));
 }
        public Dictionary <string, long> GetTimeSpeciesObservationCountsBySearchCriteria(string filter, Periodicity periodicity)
        {
            Dictionary <string, long> uniqueValues;

            switch (periodicity)
            {
            case Periodicity.Yearly:
                uniqueValues = GroupBy(SpeciesObservationType, new ElasticsearchTerm("Event_Start_Year"), filter).UniqueValues;
                break;

            case Periodicity.MonthOfTheYear:
                uniqueValues = GroupBy(SpeciesObservationType, new ElasticsearchTerm("Event_Start_MonthOfYear"), filter).UniqueValues;
                break;

            case Periodicity.WeekOfTheYear:
                uniqueValues = GroupBy(SpeciesObservationType, new ElasticsearchTerm("Event_Start_WeekOfYear"), filter).UniqueValues;
                break;

            case Periodicity.DayOfTheYear:
                uniqueValues = GroupBy(SpeciesObservationType, new ElasticsearchTerm("Event_Start_DayOfYear"), filter).UniqueValues;
                break;

            case Periodicity.Monthly:
                uniqueValues = GroupBy(SpeciesObservationType, new ElasticsearchTerm("Event_Start_YearAndMonth"), filter).UniqueValues;
                break;

            case Periodicity.Weekly:
                uniqueValues = GroupBy(SpeciesObservationType, new ElasticsearchTerm("Event_Start_YearAndWeek"), filter).UniqueValues;
                break;

            case Periodicity.Daily:
                uniqueValues = GroupBy(SpeciesObservationType, new ElasticsearchTerm("Event_Start_DatePartOnly"), filter).UniqueValues;
                break;

            default:
                throw new NotImplementedException(string.Format("Periodicity not recognized [{0}]", periodicity));
            }
            return(uniqueValues);
        }
コード例 #38
0
        public void RecurringTransactionWithoutQuantityShouldHaveFutureTransactionDependingOnPeriodicityForOneYear(Periodicity periodicity, int assertCount)
        {
            var rT     = new RecurringTransactionFactory().WithCreditDefaultValues().WithPeriodicity(periodicity).WithStartDate(DateTime.Today.AddDays(-1)).WithCurrency(new Currency()).Build();
            var future = rT.GetFutureTransaction();

            future.Should().HaveCount(assertCount);
        }