Esempio n. 1
0
        public void FixtureCleanup()
        {
            Settings.Instance = backupSettings;
            
            CloseBrowser();

            accountMain = null;
            accountToSync = null;
            _monitor = null;
        }
Esempio n. 2
0
        public void FixtureSetup()
        {
            backupSettings = Settings.Clone();
			//Settings.Instance = new StealthSettings();

            Framework.Inst.Configure4Tests();

            accountMain = Framework.Inst.MainAccount = CreateBossaMock();
            _monitor = Framework.Inst.Monitor = new MonitorWww();
        }
Esempio n. 3
0
        private void TestMonitoring_Click(object sender, EventArgs e)
        {
            Framework.CallTrace("Monitoring started!");

            Framework.Inst.OrderingEnabled = true; //!!! WILL PLACE ORDER !!!
            Framework.Inst.SignalsRulesChecking = true; //SKIP CHECKING SIGNALS

            _monitor = Framework.Inst.Monitor;
            _monitor.PositionChangeHandler += new NewPosition(monitor_PositionChangeHandler);
            bool res = _monitor.AreAccountsInSync();
            
            while (Framework.Inst.MonitoringEnabled)
            {
                if (_monitor.DetectChange()) //every 20 seconds
                {
                    for (int i = 0; i < 22; i++ ) //give user a time to react 10sec
                    {
                        Sleep(1);
                        if (Framework.Inst.DecisionMade)
                            break;
                    }
                    
                    if (!Framework.Inst.CancelSynchro) //jesli nie zkancelowano
                    {
                        foreach (AccountBase acc in Framework.Inst.AccountsList)
                        {
                            acc.Login();
                            Position newPosition = new Position(Framework.Inst.MainAccount.Position);
                            Position currentPosition = acc.GetCurrentPosition();

                            if (currentPosition.Direction != newPosition.Direction
                                || currentPosition.Size == 0)
                            {
                                //signal could be greter that position on account size
                                if (currentPosition.Size != 0 
                                    && newPosition.Size / (currentPosition.Size * 2) > 1)
                                {
                                    newPosition.Size = newPosition.Size / 2;
                                    Framework.CallTrace("Position lowered to: " + newPosition.Size);
                                }

                                acc.ChangePositionTo(newPosition);
                                Sleep(2);    
                            }
                            else
                            {
                                Framework.CallTrace("My got, same directions! Updating cancelled!");
                            }

                            acc.Logout();
                        }
                        Framework.Inst.CancelSynchro = false;
                        Framework.Inst.DecisionMade = false;
                    }
                }

                Sleep(1);
            }
        }