Example #1
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);
        }
Example #2
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));
        }
Example #3
0
        public void DateOnlyConverterTest()
        {
            // DateTime types to string
            Assert.That(DateTimeConverter.ConvertDateOnly(new DateTime(2002, 12, 01, 11, 03, 05, 321)), Is.EqualTo("20021201"));

            // string-to-DateTime but time is zero
            Assert.That(DateTimeConverter.ConvertToDateOnly("20100912"), Is.EqualTo(new DateTime(2010, 9, 12, 0, 0, 0, DateTimeKind.Utc)));

            // invalid string-to-DateTime formats
            Assert.Throws(typeof(FieldConvertError), delegate { DateTimeConverter.ConvertToDateOnly(""); });
            Assert.Throws(typeof(FieldConvertError), delegate { DateTimeConverter.ConvertToDateOnly("20021201-11:03:00"); });
        }