Ejemplo n.º 1
0
        public override async Task <IReadOnlyCollection <PositionModel> > GetPositionsAsync(TimeSpan timeout)
        {
            var request = new RequestForPositions
            {
                PosReqID   = new PosReqID(nameof(RequestForPositions) + Guid.NewGuid()),
                PosReqType = new PosReqType(PosReqType.POSITIONS),
                SubscriptionRequestType = new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT),
                NoPartyIDs           = new NoPartyIDs(1),
                Account              = new Account("account"),
                AccountType          = new AccountType(AccountType.ACCOUNT_IS_CARRIED_ON_CUSTOMER_SIDE_OF_BOOKS),
                ClearingBusinessDate = new ClearingBusinessDate(DateTimeConverter.ConvertDateOnly(DateTime.UtcNow.Date)),
                TransactTime         = new TransactTime(DateTime.UtcNow)
            };

            var partyGroup = new RequestForPositions.NoPartyIDsGroup
            {
                PartyID   = new PartyID("FB"),
                PartyRole = new PartyRole(PartyRole.CLIENT_ID)
            };

            request.AddGroup(partyGroup);
            var cts = new CancellationTokenSource(timeout);

            var resp = await _tradeSessionConnector.GetPositionsAsync(request, cts.Token);

            return(_converter.ConvertPositionReport(resp));
        }
        public IcmPositionsStateMachine RegisterMessage(RequestForPositions request, CancellationToken cancellationToken)
        {
            var or = new IcmPositionsStateMachine(request, cancellationToken, this, Log);

            Requests[or.Id] = or;
            return(or);
        }
Ejemplo n.º 3
0
        public async Task ShouldGetPositions()
        {
            _connector.Start();
            WaitForState(FixConnectorState.Connected, 30);

            var request = new RequestForPositions
            {
                PosReqID   = new PosReqID(nameof(RequestForPositions) + Guid.NewGuid()),
                PosReqType = new PosReqType(PosReqType.POSITIONS),
                SubscriptionRequestType = new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT),
                NoPartyIDs           = new NoPartyIDs(1),
                Account              = new Account("account"),
                AccountType          = new AccountType(AccountType.ACCOUNT_IS_CARRIED_ON_CUSTOMER_SIDE_OF_BOOKS),
                ClearingBusinessDate = new ClearingBusinessDate(DateTimeConverter.ConvertDateOnly(DateTime.UtcNow.Date)),
                TransactTime         = new TransactTime(DateTime.UtcNow)
            };

            var partyGroup = new RequestForPositions.NoPartyIDsGroup
            {
                PartyID   = new PartyID("FB"),
                PartyRole = new PartyRole(PartyRole.CLIENT_ID)
            };

            request.AddGroup(partyGroup);

            var resp = await _connector.GetPositionsAsync(request, CancellationToken.None);

            Assert.NotEmpty(resp);
        }
 public Task <IReadOnlyCollection <PositionReport> > GetPositionsAsync(RequestForPositions positionRequest, CancellationToken cancellationToken)
 {
     EnsureCanHandleRequest();
     lock (RejectLock)
     {
         var request = _jfdPositionsHandler.RegisterMessage(positionRequest, cancellationToken);
         SendRequest(request.Message);
         RegisterForRejectResponse(request);
         var result = request.Send();
         return(result);
     }
 }
Ejemplo n.º 5
0
        private static RequestForPositions Create(ZonedDateTime timeNow, int reqType, AccountNumber account, bool subscribe)
        {
            Debug.NotDefault(timeNow, nameof(timeNow));

            var message = new RequestForPositions();

            message.SetField(new PosReqID($"RP_{timeNow.TickOfDay}"));
            message.SetField(new PosReqType(reqType));
            message.SetField(new Account(account.Value));
            message.SetField(new AccountType(AccountType.ACCOUNT_IS_CARRIED_ON_NON_CUSTOMER_SIDE_OF_BOOKS_AND_IS_CROSS_MARGINED));
            message.SetField(new TradingSessionID(Broker));
            message.SetField(new TransactTime(timeNow.ToDateTimeUtc()));
            message.SetField(subscribe is true
                ? new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES)
                : new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT));

            return(message);
        }
        public override async Task <IReadOnlyCollection <PositionModel> > GetPositions(TimeSpan timeout)
        {
            var pr = new RequestForPositions
            {
                PosReqType   = new PosReqType(PosReqType.POSITIONS),
                NoPartyIDs   = new NoPartyIDs(1),
                TransactTime = new TransactTime(DateTime.UtcNow)
            };
            var partyGroup = new RequestForPositions.NoPartyIDsGroup
            {
                PartyID = new PartyID("*")
            };

            pr.AddGroup(partyGroup);
            var cts     = new CancellationTokenSource(timeout);
            var reports = await _connector.GetPositionsAsync(pr, cts.Token);

            return(_modelConverter.ConvertPositionReport(reports));
        }
        public async Task ShouldGetPositions()
        {
            _connector.Start();
            WaitForState(FixConnectorState.Connected, 30);

            var pr = new RequestForPositions()
            {
                PosReqType   = new PosReqType(PosReqType.POSITIONS),
                NoPartyIDs   = new NoPartyIDs(1),
                TransactTime = new TransactTime(DateTime.UtcNow)
            };
            var partyGroup = new RequestForPositions.NoPartyIDsGroup
            {
                PartyID = new PartyID("8")
            };

            pr.AddGroup(partyGroup);

            var resp = await _connector.GetPositionsAsync(pr, CancellationToken.None);

            Assert.NotEmpty(resp);
        }
Ejemplo n.º 8
0
 public virtual void onMessage(RequestForPositions message, QuickFix.SessionID session)
 {
     throw new QuickFix.UnsupportedMessageType();
 }
 public IcmPositionsStateMachine(RequestForPositions positionsRequest, CancellationToken cancellationToken, IMessageHandler messageHandler, ILog log) : base(positionsRequest, cancellationToken, messageHandler, log)
 {
     positionsRequest.PosReqID = new PosReqID(Id);
 }