예제 #1
0
 public ProcessNotificationVM()
 {
     m_messages = new ObservableQueue <MessageVM>(100);
     System.Windows.Data.BindingOperations.EnableCollectionSynchronization(m_messages, m_lock);
     m_Progress = 0;
     m_message  = "Loading TaskProcessor...";
 }
예제 #2
0
        public void Setup()
        {
            this.tradingData = new TradingDataContext();
            this.signalQueue = new ObservableQueue <Signal>();

            this.strategyHeader = new StrategyHeader(1, "Description", "ST12345-RF-01", "RTS-9.14", 10);
            this.tradingData.Get <ICollection <StrategyHeader> >().Add(this.strategyHeader);

            this.spSettings = new StopPointsSettings(this.strategyHeader, 100, false);
            this.tradingData.Get <ICollection <StopPointsSettings> >().Add(this.spSettings);

            this.slSettings = new StopLossOrderSettings(this.strategyHeader, 180);
            this.tradingData.Get <ICollection <StopLossOrderSettings> >().Add(this.slSettings);

            this.handler =
                new StrategyStopLossByPointsOnTick(this.strategyHeader, this.tradingData, this.signalQueue, new NullLogger(), true);

            this.buySignal =
                new Signal(this.strategyHeader, DateTime.Now, TradeAction.Buy, OrderType.Market, 125000, 0, 0);
            this.sellSignal =
                new Signal(this.strategyHeader, DateTime.Now, TradeAction.Sell, OrderType.Market, 125000, 0, 0);

            Assert.AreEqual(0, this.tradingData.Get <IEnumerable <Signal> >().Count());
            Assert.AreEqual(0, this.tradingData.Get <IEnumerable <Order> >().Count());
            Assert.AreEqual(0, this.signalQueue.Count);
        }
예제 #3
0
        public RoyalGameModel(int gamersInRoom)
        {
            //инициализируем полей
            Players          = new List <IPlayer>();
            gameObjects      = new Dictionary <ulong, IGameObject>();
            outgoingMessages = new ObservableQueue <IMessage>();
            incomingMessages = new ObservableQueue <IMessage>();

            AABB frameField = new AABB();

            frameField.LowerBound.Set(0, 0);
            frameField.UpperBound.Set(LengthOfSideMap, LengthOfSideMap);
            Field = new World(frameField, new Vec2(0, 0), false);
            var solver = new RoomContactListener();

            Field.SetContactListener(solver);
            CreateFrame();

            DeathZone = BuilderGameObject.CreateDeathZone(this, LengthOfSideMap);

            //создание и добавление в GameObjects и Field статических объектов карты
            List <RectangleF> occupiedArea = new List <RectangleF>();

            CreateDinamicGameObject(occupiedArea);
            CreatePlayers(gamersInRoom, occupiedArea);

            handlerIncomingMessages = new Task(Handler_IncomingMessages);
            handlerIncomingMessages.Start();
        }
        public void Setup()
        {
            this.signalQueue = new ObservableQueue <Signal>();
            this.tradingData = new TradingDataContext();

            this.lLeg = new List <StrategyHeader>();
            this.rLeg = new List <StrategyHeader>();

            this.lStrategy = new StrategyHeader(1, "Left leg strategyHeader", "BP12345-RF-01", "SBRF-3.14_FT", 10);
            this.tradingData.Get <ICollection <StrategyHeader> >().Add(lStrategy);
            this.lLeg.Add(this.lStrategy);

            this.rStrategy = new StrategyHeader(2, "Right leg strategyHeader", "BP12345-RF-01", "SBPR-3.13_FT", 11);
            this.tradingData.Get <ICollection <StrategyHeader> >().Add(rStrategy);
            this.rLeg.Add(this.rStrategy);

            this.arbitrageSettings = new ArbitrageSettings(1, this.lLeg, this.rLeg, new SpreadSettings(1.12, 1.25, 1.01));
            this.tradingData.Get <ICollection <ArbitrageSettings> >().Add(this.arbitrageSettings);

            this.lStrategyVolumeChangeStep = new StrategyVolumeChangeStep(this.lStrategy, 2);
            this.tradingData.Get <ICollection <StrategyVolumeChangeStep> >().Add(this.lStrategyVolumeChangeStep);

            ArbitrageOpenPositionOnSpreadValue handler =
                new ArbitrageOpenPositionOnSpreadValue(this.arbitrageSettings, this.lStrategy, this.tradingData, this.signalQueue, new NullLogger());
        }
 public void EnqueueItem()
 {
   _handle = new EventWaitHandle(false, EventResetMode.ManualReset);
   var test = new ObservableQueue<string>();
   test.ItemEnqueued += Queue_ItemEnqueued;
   test.Enqueue("test");
   Assert.IsTrue(_handle.WaitOne(10));
 }
예제 #6
0
 public MessagingViewModel(MessageManager msgMgr)
 {
     m_MsgQ               = new ObservableQueue <IBasicMessage>();
     m_MsgMgr             = msgMgr;
     m_CmdHandlers        = new Dictionary <MessageType, ICommand>();
     m_MsgSenderId        = msgMgr.RegisterMessageQueue(m_MsgQ);
     m_MsgQ.ItemEnqueued += OnExternalMsgReceived;
 }
예제 #7
0
        public void Collections_SetUp()
        {
            this.queue = new ObservableQueue <string>();

            this.observer = new MockQueueObserver(this.queue);

            this.queue.RegisterObserver(this.observer);
        }
예제 #8
0
 public StrategyStopLossByPointsOnTick(StrategyHeader strategyHeader,
                                       IDataContext tradingData,
                                       ObservableQueue <Signal> signalQueue,
                                       ILogger logger,
                                       bool measureFromSignalPrice = false)
     : base(strategyHeader, tradingData, signalQueue, logger, measureFromSignalPrice)
 {
 }
예제 #9
0
        public void Save(ObservableQueue <ActivityMessage> queue)
        {
            var list = queue.ToList();

            var serializator = new SerializatorIso <List <ActivityMessage> >();

            serializator.Serialize(FileName, list);
        }
예제 #10
0
 public PlaceStrategyTakeProfitByPointsOnTrade(StrategyHeader strategyHeader,
                                               IDataContext tradingData,
                                               ObservableQueue <Signal> signalQueue,
                                               ILogger logger,
                                               bool measureFromSignalPrice = false)
     : base(strategyHeader, tradingData, signalQueue, logger, measureFromSignalPrice)
 {
 }
예제 #11
0
        private string GetSendJson(ObservableQueue <ActivityMessage> pendingData)
        {
            var messageMapper  = new MessageMapper(encryptor);
            var messages       = messageMapper.MapCollection(pendingData.ToList());
            var jsonSerializer = new JsonSerializer();

            return(jsonSerializer.Serialize(messages));
        }
예제 #12
0
        private bool DispatchAll(ObservableQueue <ActivityMessage> pendingData)
        {
            string sendJson = GetSendJson(pendingData);
            string userName = GetUserName();
            bool   result   = SendData(userName, sendJson);

            return(result);
        }
예제 #13
0
파일: BuyOnTick.cs 프로젝트: w1r2p1/TRx
 public BuyOnTick(StrategyHeader strategyHeader, IDataContext tradingData, ObservableQueue <Signal> signalQueue, ILogger logger)
     : base(tradingData.Get <ObservableCollection <Tick> >())
 {
     this.strategyHeader = strategyHeader;
     this.tradingData    = tradingData;
     this.signalQueue    = signalQueue;
     this.logger         = logger;
 }
        public void Setup()
        {
            this.tradingData  = new TradingDataContext();
            this.signalQueue  = new ObservableQueue <Signal>();
            this.orderQueue   = new ObservableQueue <Order>();
            this.orderManager = new MockOrderManager();

            TraderBase traderBase = new TraderBase(this.tradingData, this.signalQueue, this.orderQueue, this.orderManager, new AlwaysTimeToTradeSchedule(), new NullLogger());
        }
예제 #15
0
        public OrderQueueProcessor(IOrderManager manager, IDataContext tradingData, ObservableQueue <Order> orderQueue, ILogger logger)
        {
            this.manager     = manager;
            this.tradingData = tradingData;
            this.orderQueue  = orderQueue;
            this.logger      = logger;

            this.orderQueue.RegisterObserver(this);
        }
예제 #16
0
 public SendItemOnSignal(ObservableQueue <Signal> signalQueue)
 {
     this.signalQueue = signalQueue;
     this.signalQueue.RegisterObserver(this);
     //this.orderQueue = orderQueue;
     //this.tradingData = tradingData;
     //this.schedule = schedule;
     //this.logger = logger;
 }
예제 #17
0
        public void EnqueueItem()
        {
            _handle = new EventWaitHandle(false, EventResetMode.ManualReset);
            var test = new ObservableQueue <string>();

            test.ItemEnqueued += Queue_ItemEnqueued;
            test.Enqueue("test");
            Assert.IsTrue(_handle.WaitOne(10));
        }
예제 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InputStream{TFrame}"/> class.
        /// </summary>
        /// <param name="stream">The multimedia stream.</param>
        /// <param name="owner">The container that owns the stream.</param>
        public InputStream(AVStream *stream, InputContainer owner)
            : base(stream)
        {
            OwnerFile   = owner;
            PacketQueue = new ObservableQueue <MediaPacket>();

            Type = typeof(TFrame) == typeof(VideoFrame) ? MediaType.Video : MediaType.None;
            Info = new StreamInfo(stream, owner);
        }
예제 #19
0
 public Caffe()
 {
     VisitorsQueue = new ObservableQueue <Visitor>();
     Tables        = new Table[Constants.tablesCount];
     for (var i = 0; i < Tables.Length; i++)
     {
         Tables[i] = new Table(string.Format("столик №{0}", i + 1));
     }
 }
예제 #20
0
 public MainWindowViewModel()
 {
     Window            = null;
     _logs             = new ObservableQueue <string>(MaxLogNum);
     _videoConverter   = new ObservableCollection <VideoConvert>();
     _progressBarValue = 0;
     _ctsGetDisk       = new CancellationTokenSource();
     StartGetDiskUsage(_ctsGetDisk.Token);
     InitRooms(CurrentConfig.Rooms);
 }
예제 #21
0
        public void Inputs_Setup()
        {
            this.tradingData = new TradingDataContext();
            this.signalQueue = new ObservableQueue <Signal>();

            this.strategyHeader = new StrategyHeader(1, "Strategy 1", "BP12345-RF-01", "RTS-9.13_FT", 10);
            this.tradingData.Get <ICollection <StrategyHeader> >().Add(this.strategyHeader);

            BuyOnTick handler = new BuyOnTick(this.strategyHeader, this.tradingData, this.signalQueue, new NullLogger());
        }
예제 #22
0
        public void ShouldNotDequeueItemWhenEmpty()
        {
            // arrange
            var target = new ObservableQueue<string>();

            // act
            Assert.Throws<InvalidOperationException>( () => target.Dequeue() );

            // assert
        }
예제 #23
0
        public BreakOutOnTick(StrategyHeader strategyHeader, IDataContext tradingData, ObservableQueue <Signal> signalQueue, ILogger logger)
            : base(tradingData.Get <ObservableCollection <Tick> >())
        {
            this.strategyHeader = strategyHeader;
            this.tradingData    = tradingData;
            this.signalQueue    = signalQueue;
            this.logger         = logger;

            this.barSettings = this.tradingData.Get <IEnumerable <BarSettings> >().SingleOrDefault(s => s.StrategyId == this.strategyHeader.Id);
        }
예제 #24
0
        public TransferManager(ITransferAuthenticator authenticator)
        {
            //Set authenticator:
            auth = authenticator;

            _queued = new ObservableQueue <Transfer>();
            _active = new ObservableCollection <Transfer>();
            _queued.CollectionChanged += OnQueuedChanged;
            _active.CollectionChanged += OnInvokedChanged;
        }
예제 #25
0
        public ReversMaOnBar0(StrategyHeader strategyHeader, IDataContext tradingData, ObservableQueue <Signal> signalQueue, ILogger logger)
            : base(tradingData.Get <ObservableCollection <Bar> >())
        {
            this.strategyHeader = strategyHeader;
            this.tradingData    = tradingData;
            this.signalQueue    = signalQueue;
            this.logger         = logger;

            this.Ma1Handlers = new List <ItemAddedNotification <double> >();
            this.Ma2Handlers = new List <ItemAddedNotification <double> >();
        }
예제 #26
0
        public void Setup()
        {
            this.tradingData = new TradingDataContext();
            this.signalQueue = new ObservableQueue <Signal>();
            this.orderQueue  = new ObservableQueue <Order>();
            this.schedule    = new AlwaysTimeToTradeSchedule();

            SignalQueueProcessor processor = new SignalQueueProcessor(this.signalQueue, this.orderQueue, this.tradingData, this.schedule, new NullLogger());

            AddStrategies();
        }
예제 #27
0
        public ArbitrageOpenPositionOnSpreadValue(ArbitrageSettings arbitrageSettings, StrategyHeader strategyHeader, IDataContext tradingData, ObservableQueue <Signal> signalQueue, ILogger logger)
            : base(tradingData.Get <ObservableCollection <SpreadValue> >())
        {
            this.arbitrageSetings = arbitrageSettings;
            this.strategyHeader   = strategyHeader;
            this.tradingData      = tradingData;
            this.signalQueue      = signalQueue;
            this.logger           = logger;

            this.isLeftLegStrategy = arbitrageSettings.LeftLeg.Any(s => s.Id == strategyHeader.Id);
        }
예제 #28
0
        public DriveThruViewModel()
        {
            _items             = new ObservableCollection <string>();
            _orders            = new ObservableQueue <OrderViewModel>();
            SubmitOrderCommand = new SubmitOrderCommand(this);
            GiveOrderCommand   = new GiveOrderCommand(this);

            _items.Add("Chicken");
            _items.Add("Salad");
            _items.Add("Fruit Cup");
        }
예제 #29
0
        public void ConstructorShouldCopySequence()
        {
            // arrange
            var expected = new[] { "1", "2", "3" };

            // act
            var target = new ObservableQueue<string>( expected );

            // assert
            Assert.Equal( 3, target.Count );
            Assert.True( expected.All( i => target.Contains( i ) ) );
        }
예제 #30
0
        public void Setup()
        {
            this.tradingData  = new TradingDataContext();
            this.signalQueue  = new ObservableQueue <Signal>();
            this.orderQueue   = new ObservableQueue <Order>();
            this.orderManager = new MockOrderManager();

            TraderBase traderBase = new TraderBase(this.tradingData, this.signalQueue, this.orderQueue, this.orderManager, new AlwaysTimeToTradeSchedule(), new NullLogger());

            this.strategyHeader = new StrategyHeader(1, "strategyHeader", "BP12345-RF-01", "RTS-9.13_FT", 10);
            AddStrategy(this.strategyHeader);
        }
예제 #31
0
 public ViewBase(int viewId,
                 string viewName,
                 MessageManager msgMgr)
 {
     m_ViewId             = viewId;
     m_ViewName           = viewName;
     m_ViewMsgMgr         = msgMgr;
     m_MsgQ               = new ObservableQueue <IBasicMessage>();
     m_CmdHandlers        = new Dictionary <MessageType, ICommand>();
     m_SenderId           = msgMgr.RegisterMessageQueue(m_MsgQ);
     m_MsgQ.ItemEnqueued += OnExternalMsgReceived;
 }
예제 #32
0
파일: StopLossOnBar.cs 프로젝트: w1r2p1/TRx
 public StopLossOnBar(StrategyHeader strategyHeader,
                      double points,
                      IDataContext tradingData,
                      ObservableQueue <Signal> signalQueue,
                      ILogger logger)
     : base(strategyHeader,
            points,
            tradingData,
            signalQueue,
            logger)
 {
 }
        public StrategiesPlaceTakeProfitByPointsOnTradeHandlers(IDataContext tradingData,
                                                                ObservableQueue <Signal> signalQueue,
                                                                ILogger logger,
                                                                bool measureStopFromSignal = false)
        {
            this.tradingData           = tradingData;
            this.signalQueue           = signalQueue;
            this.logger                = logger;
            this.measureStopFromSignal = measureStopFromSignal;

            ActivateHandlers();
        }
예제 #34
0
        public void ShouldEnqueueItemWithEvents()
        {
            // arrange
            var expected = "1";
            var target = new ObservableQueue<string>();

            // act
            Assert.PropertyChanged( target, "Count", () => target.Enqueue( expected ) );

            // assert
            Assert.Equal( 1, target.Count );
            Assert.Equal( expected, target.Peek() );
        }
예제 #35
0
        public void ShouldPeekItem()
        {
            // arrange
            var target = new ObservableQueue<string>();

            target.Enqueue( "2" );
            target.Enqueue( "1" );
            target.Enqueue( "3" );

            // act
            var actual = target.Peek();

            // assert
            Assert.Equal( "2", actual );
        }
예제 #36
0
        public void ShouldDequeueItemWithEvents()
        {
            // arrange
            var expected = "1";
            string actual = null;
            var target = new ObservableQueue<string>();

            target.Enqueue( expected );

            // act
            Assert.PropertyChanged( target, "Count", () => actual = target.Dequeue() );

            // assert
            Assert.Equal( 0, target.Count );
            Assert.Equal( expected, actual );
        }
예제 #37
0
        public void ShouldContainItem( string value, bool expected )
        {
            // arrange
            var target = new ObservableQueue<string>();
            
            target.Enqueue( "One" );
            target.Enqueue( "Two" );
            target.Enqueue( "Three" );
            
            // act
            var actual = target.Contains( value );

            // assert
            Assert.Equal( expected, actual );
        }
예제 #38
0
        public void ShouldCopyToLargeArray()
        {
            // arrange
            var expected = new[] { "1", "2" };
            var target = new ObservableQueue<string>( expected );

            target.Enqueue( "1" );
            target.Enqueue( "2" );

            var actual = new string[4];

            // act
            target.CopyTo( actual, 2 );

            // assert
            Assert.True( actual.Skip( 2 ).SequenceEqual( expected ) );
        }
예제 #39
0
        public void ShouldConvertToArray()
        {
            // arrange
            var target = new ObservableQueue<string>();
            var expected = new[] { "1", "2", "3" };

            target.Enqueue( "1" );
            target.Enqueue( "2" );
            target.Enqueue( "3" );

            // act
            var actual = target.ToArray();

            // assert
            Assert.True( expected.SequenceEqual( actual ) );
        }
예제 #40
0
        public void ShouldTrimExcess()
        {
            // arrange
            var target = new ObservableQueue<string>( 10 );
            
            target.Enqueue( "1" );
            target.Enqueue( "2" );
            target.Enqueue( "3" );

            // act
            target.TrimExcess();

            // assert
            // no exception
        }
예제 #41
0
        public void ShouldCopyToSizedArray()
        {
            // arrange
            var expected = new[] { "1", "2" };
            var target = new ObservableQueue<string>( expected );
            
            target.Enqueue( "1" );
            target.Enqueue( "2" );

            var actual = new string[2];

            // act
            target.CopyTo( actual, 0 );

            // assert
            Assert.True( expected.SequenceEqual( actual ) );
        }
예제 #42
0
        public void ShouldGrowAutomatically()
        {
            var target = new ObservableQueue<string>( 3 );

            for ( var i = 0; i < 10; i++ )
                target.Enqueue( ( i + 1 ).ToString() );

            target.Clear();
            target.TrimExcess();
        }
예제 #43
0
        public void ShouldEnumerate()
        {
            var target = new ObservableQueue<string>();

            target.Enqueue( "1" );
            target.Enqueue( "2" );
            target.Enqueue( "3" );

            var items1 = (IEnumerable<string>) target;

            foreach ( var item in items1 )
                Console.WriteLine( item );

            var items2 = (IEnumerable) target;

            foreach ( string item in items2 )
                Console.WriteLine( item );
        }
예제 #44
0
        public void ShouldClearWithEvents()
        {
            // arrange
            var target = new ObservableQueue<string>();

            target.Enqueue( "1" );

            // act
            Assert.PropertyChanged( target, "Count", target.Clear );

            // assert
            Assert.Equal( 0, target.Count );
        }
예제 #45
0
        public void ShouldCopyToWhenICollection()
        {
            // arrange
            var target = new ObservableQueue<string>();
            var collection = (ICollection) target;
            var expected = new[] { "1", "2" };
            var actual = new string[2];

            target.Enqueue( "1" );
            target.Enqueue( "2" );

            // act
            collection.CopyTo( actual, 0 );

            // assert
            Assert.True( expected.SequenceEqual( actual ) );
        }