예제 #1
0
        public int BarsSave(Bars bars)
        {
            int      ret   = 0;
            DateTime start = DateTime.Now;
            Storage  db    = StorageFactory.Instance.CreateStorage();

            db.Open(this.Abspath, pagePoolSize);
            BarsPerst barsPerst = db.Root as BarsPerst;

            barsPerst               = (BarsPerst)db.CreateClass(typeof(BarsPerst));
            barsPerst.Symbol        = bars.Symbol;
            barsPerst.SecurityName  = bars.SecurityName;
            barsPerst.ScaleInterval = bars.ScaleInterval;

            /// If number of element in block is 100, time series period is 1 day, then
            /// value of maxBlockTimeInterval can be set as 100*(24*60*60*10000000L)*2
            //long maxBlockTimeInterval = (number of elements in block)*(tick interval)*2;
            TICKS_PER_SECOND = bars.ScaleInterval.TimeSpanInSeconds;

            barsPerst.BarsStored = db.CreateTimeSeries <BarPerst>(N_ELEMS_PER_BLOCK, N_ELEMS_PER_BLOCK * TICKS_PER_SECOND * 2);
            foreach (Bar bar in bars.Values)
            {
                BarPerst barPerst = new BarPerst(bar);
                barsPerst.BarsStored.Add(barPerst);
            }
            ret     = barsPerst.BarsStored.Count;
            db.Root = barsPerst;
            db.Commit();
            db.Close();
            string msg = "Elapsed time for storing " + ret + " bars: " + (DateTime.Now - start);

            return(ret);
        }
		public int BarsSave(Bars bars) {
			int ret = 0;
	        DateTime start = DateTime.Now;
	        Storage db = StorageFactory.Instance.CreateStorage();
	        db.Open(this.Abspath, pagePoolSize);
	        BarsPerst barsPerst = db.Root as BarsPerst;
	        barsPerst = (BarsPerst) db.CreateClass(typeof(BarsPerst));
	        barsPerst.Symbol = bars.Symbol;
	        barsPerst.SecurityName = bars.SecurityName;
	        barsPerst.ScaleInterval = bars.ScaleInterval;

			/// If number of element in block is 100, time series period is 1 day, then
			/// value of maxBlockTimeInterval can be set as 100*(24*60*60*10000000L)*2
			//long maxBlockTimeInterval = (number of elements in block)*(tick interval)*2;
			TICKS_PER_SECOND = bars.ScaleInterval.TimeSpanInSeconds;

	        barsPerst.BarsStored = db.CreateTimeSeries<BarPerst>(N_ELEMS_PER_BLOCK, N_ELEMS_PER_BLOCK*TICKS_PER_SECOND*2);
	        foreach (Bar bar in bars.Values) {
	        	BarPerst barPerst = new BarPerst(bar);
				barsPerst.BarsStored.Add(barPerst);
	        }
	        ret = barsPerst.BarsStored.Count;
	        db.Root = barsPerst;
	        db.Commit();
	        db.Close();
			string msg = "Elapsed time for storing " + ret + " bars: " + (DateTime.Now - start);
			return ret;
		}