Beispiel #1
0
        // get default historical volatility for specified duration [in years]
        public double GetHistoricalVolatility(string ticker, double duration)
        {
            // get historical data
            ArrayList list = GetHistoricalData(ticker, DateTime.Now.AddDays(-duration * 365), DateTime.Now);

            // calculate historical value
            return(100.0 * HistoryVolatility.HighLowParkinson(list));
        }
Beispiel #2
0
        // get default historical volatility for specified duration [in years]
        public double GetHistoricalVolatility(string ticker, double duration)
        {
            Symbol.Type type = Symbol.Type.Unknown;
            ticker = Symbol.CorrectSymbol(ticker, out type);

            // get historical data
            ArrayList list = GetHistoricalData(ticker, DateTime.Now.AddDays(-duration * 365), DateTime.Now);

            // calculate historical value
            return(100.0 * HistoryVolatility.HighLowParkinson(list));
        }
		protected override void Create() {
#if __BACKTEST
			__cCloses = new List<double[]>(1024);
			__cCloses.Add(new double[] {0, 0, 0, 0});
#endif
			__cTWIBars = BarsOfData(3) as Instrument;
			__cSymbolIds = new Dictionary<string, int>(32);

			//讀取未平倉量
			__cOpenInterest = new OpenInterest(this, 2);
			__cOpenInterest.Initialize();

			//讀取三大法人多空與未平倉量
			__cForeignInvestment = new ForeignInvestment(this, 2);
			__cForeignInvestment.Initialize();

			//建立歷史波動率指標
			__cHistoryV = new HistoryVolatility(this, 2);

			//設定計時器(定期抓未平倉量)
			__cTimer = new Timer(1000);
			__cTimer.AutoReset = false;
			__cTimer.Elapsed += Timer_onElapsed;
			__cTimer.Start();
		}