예제 #1
0
		internal SeriesSymbolData(InstrumentDataRequest dataRequest, InstrumentSettings settings = null) {
			this.Id = 0x40000000 | System.Threading.Interlocked.Increment(ref __iLastSeriesId);
			this.Indexer = new SeriesIndexer();
			__cDataRequest = dataRequest;
			__cSettings = ((settings == null) ? new InstrumentSettings(ref __cDataRequest) : settings.Create(ref __cDataRequest));
			__cUpdateTime = DateTime.UtcNow.AddHours(__cSettings.TimeZone);
			
			SessionObject cSession = __cSettings.GetSessionFromToday();
			__iRealtimeCount = (cSession == null) ? 1 : (int) ((cSession.GetCloseTimeForDaylight() - cSession.GetStartTimeForDaylight()).TotalSeconds / dataRequest.Resolution.TotalSeconds + 1);

			Indexer.HistoryIndex = 0;
			Indexer.RealtimeIndex = -1;

			__cOpens = new Series<double>(__iRealtimeCount);
			__cOpens.onRequest += Series_onRequest;

			__cHighs = new Series<double>(__iRealtimeCount);
			__cHighs.onRequest += Series_onRequest;

			__cLows = new Series<double>(__iRealtimeCount);
			__cLows.onRequest += Series_onRequest;

			__cCloses = new Series<double>(__iRealtimeCount);
			__cCloses.onRequest += Series_onRequest;

			__cTimes = new Series<DateTime>(__iRealtimeCount);
			__cTimes.onRequest += Series_onRequest;

			__cVolumes = new Series<double>(__iRealtimeCount);
			__cVolumes.onRequest += Series_onRequest;

			__cDataRequest.Range.Count = 0;  //將資料筆數設定為0(因為一開始沒有請求任何資訊)
		}
예제 #2
0
 public OrderbookPublishingService(
     ILogFactory logFactory,
     OrderbookSettings orderbookSettings,
     RabbitMqSettings rmqSettings,
     InstrumentSettings instrumentSettings)
 {
     _log               = logFactory.CreateLog(this);
     _logFactory        = logFactory;
     _orderbookSettings = orderbookSettings;
     _rmqSettings       = rmqSettings;
     _instruments       = instrumentSettings.Orderbooks;
 }
예제 #3
0
 public void InstrumentInheritingFromIInstrument()
 {
     try
     {
         var instrument = new InterfaceTestInstrument();
         var setting    = new InstrumentSettings();
         setting.Add(instrument);
     }
     catch (Exception ex)
     {
         Assert.Fail("Unit test for instruments inheriting from the IInstrument interface has trown an exception: " + ex.Message);
     }
 }
예제 #4
0
        public static void statictest()
        {
            var             s  = new InstrumentSettings();
            BJSONParameters pa = new BJSONParameters();

            pa.UseExtensions         = false;
            InstrumentSettings.isOk  = true;
            InstrumentSettings.isBad = true;

            var jsonStr = BJSON.ToBJSON(s, pa);

            var o = BJSON.ToObject <InstrumentSettings>(jsonStr);
        }
예제 #5
0
        public override void Run()
        {
            // These settings always exist.
            Log.Info("Component Settings directory={0}", ComponentSettings.SettingsDirectoryRoot);
            Log.Info("Session log Path={0}", EngineSettings.Current.SessionLogPath);
            Log.Info("Result Listener Count={0}", ResultSettings.Current.Count);

            // DUT Setting can be used to find a specific DUT is the default is not desired.
            if (DutSettings.Current.Count > 0)
            {
                string s = DutSettings.GetDefaultOf <Dut>().Name;
                Log.Info("The first DUT found has a name of {0}", s);
            }

            // Similar to DutSettings, can be used to find Instruments other than the default.
            if (InstrumentSettings.Current.Count > 0)
            {
                string s = InstrumentSettings.GetDefaultOf <Instrument>().Name;
                Log.Info("The first instrument found has a name of {0}", s);
            }

            // An example of user defined settings, which show up as individual tabs.
            // Default values will be used, if none exist.
            // Defined in ExampleSettings.cs
            Log.Info("DifferentSettings as string={0}", ExampleSettings.Current.ToString());
            Log.Info("DifferentSettings comment={0}", ExampleSettings.Current.MyComment);

            // An example of custom Bench settings.
            // This is similar to the DUT or Instrument editors.
            // Only use the values if something exists.
            if (CustomBenchSettingsList.Current.Count > 0)
            {
                Log.Info("Custom Bench Settings List Count={0}", CustomBenchSettingsList.Current.Count);
                Log.Info("First instance of Custom Bench setting as string={0}", CustomBenchSettingsList.GetDefaultOf <CustomBenchSettings>());
                foreach (var customBenchSetting in CustomBenchSettingsList.Current)
                {
                    Log.Info("Type={0} Time={1} MyProperty={2}", customBenchSetting.GetType(), customBenchSetting.MyTime,
                             customBenchSetting.MyProperty);
                }
            }
        }
예제 #6
0
        internal SeriesSymbolData(InstrumentDataRequest dataRequest, InstrumentSettings settings = null)
        {
            this.Indexer = new SeriesIndexer();

            __cDataRequest = dataRequest;
            __cSettings    = ((settings == null) ? new InstrumentSettings(ref __cDataRequest) : settings.Create(ref __cDataRequest));
            __cUpdateTime  = DateTime.UtcNow.AddHours(__cSettings.TimeZone);

            SessionObject cSession = __cSettings.GetSessionFromToday();

            __iRealtimeCount = (int)((cSession.EndTime - cSession.StartTime).TotalSeconds / dataRequest.Resolution.TotalSeconds + 1);

            Indexer.HistoryIndex  = 0;
            Indexer.RealtimeIndex = -1;

            __cOpens   = new Series <double>(__iRealtimeCount);
            __cHighs   = new Series <double>(__iRealtimeCount);
            __cLows    = new Series <double>(__iRealtimeCount);
            __cCloses  = new Series <double>(__iRealtimeCount);
            __cTimes   = new Series <DateTime>(__iRealtimeCount);
            __cVolumes = new Series <double>(__iRealtimeCount);

            __cDataRequest.Range.Count = 0;              //將資料筆數設定為0(因為一開始沒有請求任何資訊)
        }
예제 #7
0
        protected override void CreateAxisY(ChartProperty property, Rectangle axisRectangle)
        {
            InstrumentSettings cSettings = __cBars.Info as InstrumentSettings;

            this.AxisY = AbstractPlot.CreateAxisY(this.Painter, this.ChartSetting.Axis, cSettings.Property.PriceScaleRule as IPriceScale, property, axisRectangle);
        }
예제 #8
0
        public static void statictest()
        {
            var s = new InstrumentSettings();
            BJSONParameters pa = new BJSONParameters();
            pa.UseExtensions = false;
            InstrumentSettings.isOk = true;
            InstrumentSettings.isBad = true;

            var jsonStr = BJSON.ToBJSON(s, pa);

            var o = BJSON.ToObject<InstrumentSettings>(jsonStr);
        }
예제 #9
0
		private static DateTime GetExpiration(Instrument bars) {
			InstrumentSettings cSettings = bars.Info as InstrumentSettings;
			cSettings.SetExpirationFromTime(bars.BarUpdateTime);
			return cSettings.Expiration;
		}