public MultiLevelType(IUnityContainer container, ILevel1 one, ILevel2 two) { Level = 2; Container = container; Param1 = one; Param2 = two; }
public Level0(ILevel1 level1, ILevel2 level2, ILevel3 levl3) { if (!object.ReferenceEquals(level1, level2.GetLevel1())) { throw new InvalidServiceTypeException("ReferenceNotEqual"); } }
public Level0(ILevel1 level1, [Internal] ILevel2 level2, [External("C2")] ILevel3 levl3) { if (level1 == null || level2 == null || levl3 == null) { throw new Exception("Internal/External is failed."); } }
public virtual void WhenRegister_ShouldGetLevel1Properly() { // Arrange IIoCContainer target = this.CreateTarget(); RegisterTestObjectContext registration = new RegisterTestObjectContext() { Container = target, Settings = new RegisterLevelContext[] { new RegisterLevelContext() { UseFactory = false, Settings = IocRegisterSettings.None }, new RegisterLevelContext() { UseFactory = false, Settings = IocRegisterSettings.None }, new RegisterLevelContext() { UseFactory = false, Settings = IocRegisterSettings.None } } }; this.Register(registration); // Act ILevel1 actual = target.Resolve <ILevel1>(); // Assert this.AssertProperObjectTree(actual, registration); }
internal CandlestickChart(string file, string sheet, string topLeftCorner, string bottomRightCorner, int timerInterval, int slowLength, ILevel1 level1, TextBox box) { _level1 = level1; _lastVolume = _level1.Volume; Candlesticks = new List <Candlestick>(); var excelApp = new Excel.Application { Visible = true }; var excelWorkbook = excelApp.Workbooks.Open(file, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false); var excelSheets = excelWorkbook.Worksheets; var excelWorksheet = (Excel.Worksheet)excelSheets.Item[sheet]; //notice the cell numbers, change them as required var excelRange = excelWorksheet.Range[topLeftCorner, bottomRightCorner]; for (var i = 1; i <= slowLength; ++i) { Candlesticks.Add(new Candlestick() { IsNull = false, High = (decimal)((Excel.Range)excelRange.Cells[i, 1]).Value2, Low = (decimal)((Excel.Range)excelRange.Cells[i, 3]).Value2, Open = (decimal)((Excel.Range)excelRange.Cells[i, 4]).Value2, Close = (decimal)((Excel.Range)excelRange.Cells[i, 2]).Value2 }); } excelRange = excelWorksheet.Range["Y2", "Y2"]; MarketConditionCoefficient = (decimal)((Excel.Range)excelRange.Cells[1, 1]).Value2; excelWorkbook.Close(); excelApp.Quit(); ReleaseObject(excelWorksheet); ReleaseObject(excelWorkbook); ReleaseObject(excelApp); Candlesticks.Reverse(); CurrentCandlestick = new Candlestick(); //Set up timer _timer = new Timer { Interval = timerInterval, Enabled = false, AutoReset = true }; _timer.Elapsed += TimerOnTick; }
public MultiLevelType(IUnityContainer container, ILevel1 one, ILevel2 two, ILevel3 three) { Level = 3; Container = container; Param1 = one; Param2 = two; Param3 = three; }
public MultiLevelType(IUnityContainer container, ILevel1 one, ILevel2 two, ILevel3 three, ILevel4 four) { Level = 4; Container = container; Param1 = one; Param2 = two; Param3 = three; Param4 = four; }
internal TestTool(IHost host) { _highestBid = 0; _lowestBid = decimal.MaxValue; _highestAsk = 0; _lowestAsk = decimal.MaxValue; #region OUTPUT _stringBuilder = new StringBuilder(); //OUTPUT RELATED #endregion InitializeComponent(); _host = host; _position = _host.GetPosition(Product); _level1 = _host.GetLevel1(Product); //initialize candlestickCharts here //notice the first 4 values are the excel file, sheet, upper right corner of values and lower left corner of values //we always need 4 columns: High, Last, Low, Open. If High is column K, then we need the last column to be N //the number of the first cell should be the High of the first value you want. //the number of the last cell will end up being (the amount of candlesticks you want + the number of the first cell - 1) //DON'T F**K THIS UP _candlestickChart5 = new CandlestickChart(File, "ES", "K3", "N29", TimerInterval, SlowLength, _level1, tbxAll); var marketConditionCoefficient = _candlestickChart5.MarketConditionCoefficient; _maxDrawdown = (int)Math.Round(MaxDrawdown * marketConditionCoefficient); _dollarProfitTarget = (int)Math.Round(DollarProfitTarget * marketConditionCoefficient); _earned = (int)Math.Round(Earned * marketConditionCoefficient); _percentDown = (int)Math.Round(PercentDown * marketConditionCoefficient); #region OUTPUT tbxAll.AppendText("\r\nCoefficient: " + marketConditionCoefficient.ToString("F")); tbxAll.AppendText("\r\nPoint: " + Point); tbxAll.AppendText("\r\nMax drawdown: " + _maxDrawdown); tbxAll.AppendText("\r\nDollar profit target: " + _dollarProfitTarget); tbxAll.AppendText("\r\nEarned: " + _earned); tbxAll.AppendText("\r\nPercent down: " + _percentDown); #endregion _fast = _candlestickChart5.AverageLast(CandlestickChart.Point.Close, FastLength); _slow = _candlestickChart5.AverageLast(CandlestickChart.Point.Close, SlowLength); _signal = Signals.None; _orderState = OrderStateEnum.FILLED; _candlestickChart5.Start(); _level1.Level1Changed += Level1_Level1Changed; }
public virtual void WhenRegisterAsSingleton_ShouldCreateOnce() { // Arrange IIoCContainer target = this.CreateTarget(); RegisterTestObjectContext registration = new RegisterTestObjectContext() { Container = target, Settings = new RegisterLevelContext[] { new RegisterLevelContext() { UseFactory = false, Settings = IocRegisterSettings.Singleton }, new RegisterLevelContext() { UseFactory = false, Settings = IocRegisterSettings.None }, new RegisterLevelContext() { UseFactory = false, Settings = IocRegisterSettings.None } } }; this.Register(registration); // Act ILevel1 actual1Level1 = target.Resolve <ILevel1>(); ILevel1 actual2Level1 = target.Resolve <ILevel1>(); ILevel2 actual1Level2 = target.Resolve <ILevel2>(); ILevel2 actual2Level2 = target.Resolve <ILevel2>(); ILevel3 actual1Level3 = target.Resolve <ILevel3>(); ILevel3 actual2Level3 = target.Resolve <ILevel3>(); // Assert actual1Level1.Should().BeSameAs(actual2Level1); actual1Level2.Should().NotBeSameAs(actual2Level2); actual1Level3.Should().NotBeSameAs(actual2Level3); }
public Level2(ILevel1 level1) { _level1 = level1; }
public MultiLevelType(IUnityContainer container, ILevel1 one) { Level = 1; Container = container; Param1 = one; }
// This function is called when the information in the SymbolLevel1 changed. private void Level1_Level1Changed(ILevel1 level1) { #region OUTPUT _stringBuilder.Append("\r\nVolume: " + level1.Volume + "\r\n"); #endregion var bid = level1.Bid; if (bid > _highestBid) { _highestBid = bid; } if (bid < _lowestBid) { _lowestBid = bid; } var ask = level1.Ask; if (ask > _highestAsk) { _highestAsk = ask; } if (ask < _lowestAsk) { _lowestAsk = ask; } //Update candlestickCharts here _candlestickChart5.Update(); _fast = _candlestickChart5.AverageLast(CandlestickChart.Point.Close, FastLength); _slow = _candlestickChart5.AverageLast(CandlestickChart.Point.Close, SlowLength); var crossedUp = _fast > _slow && _lastFast < _lastSlow; var crossedDown = _fast <_slow && _lastFast> _lastSlow; if (crossedUp || crossedDown) { _highAtSignal = _candlestickChart5.High(1); _lowAtSignal = _candlestickChart5.Low(1); _signal = crossedUp ? Signals.Buy : Signals.Sell; } _lastFast = _fast; _lastSlow = _slow; #region output var currentTradeOutput = "No current trade"; #endregion if (_trade != null) { var position = _trade.Position; _trade.Drawdown = (position > 0 ? _lastPrice - _lowestBid : _highestAsk - _lastPrice) * Point * DollarPointValue; #region output currentTradeOutput = "Current Trade - Position: " + position + " Open Price: " + _trade.OpenPrice + " @ " + _trade.OpenedAt + " | Drawdown: " + _trade.Drawdown; #endregion } #region output _stringBuilder.Append(currentTradeOutput); #endregion if (_orderState == OrderStateEnum.FILLED) { Algorithm(); if (_position.NetVolume != 0) { CheckStopLoss(); CheckPercentTrailing(); CheckProfitTarget(); } } txbAccounts.Text = _stringBuilder.ToString(); _stringBuilder.Clear(); }