Ejemplo n.º 1
0
class AuctionSummaryMessage(BasicMessageType):
    name = 'Auction Summary Message'

    timestamp = Field(name='Timestamp',
                      offset=0,
                      length=8,
                      data_type=Numeric(length=8))
    message_type = Field(name='Message Type',
                         offset=8,
                         length=1,
                         data_type=SingleCharacter(character='J'))
    stock_symbol = Field(name='Stock Symbol',
                         offset=9,
                         length=8,
                         data_type=Alpha(length=8))
    auction_type = Field(name='Auction Type',
                         offset=17,
                         length=1,
                         data_type=Alpha(length=1))
    price = Field(name='Price',
                  offset=18,
                  length=10,
                  data_type=Numeric(length=10))
    shares = Field(name='Shares',
                   offset=28,
                   length=10,
                   data_type=Numeric(length=10))
    fields = [
        timestamp, message_type, stock_symbol, auction_type, price, shares
    ]
 def test_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='E'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 12,
             self.DATA_TYPE: Base36Numeric(length=12),
         },
         {
             self.OFFSET: 21,
             self.LENGTH: 6,
             self.DATA_TYPE: Numeric(length=6),
         },
         {
             self.OFFSET: 27,
             self.LENGTH: 12,
             self.DATA_TYPE: Base36Numeric(length=12),
         },
     ]
     self._test_message_type(OrderExecutedMessage, descriptions)
class CharacterTest(DataTypesTestCase, TestCase):
    def setUp(self):
        self.c = SingleCharacter(character='C')

    def test_valid_character(self):
        self.assertTrue(self.c.is_valid('C'))

    def test_invalid_character_wrong_base_set(self):
        self.assertFalse(self.c.is_valid(' '))
        self.assertFalse(self.c.is_valid('0'))
        self.assertFalse(self.c.is_valid('c'))

    def test_invalid_character_wrong_length(self):
        self._test_invalid_length(valid_length=self.c.length,
                                  valid_char='C',
                                  data_type=self.c)
Ejemplo n.º 4
0
 def test_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='J'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 8,
             self.DATA_TYPE: Alpha(length=8),
         },
         {
             self.OFFSET: 17,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
         {
             self.OFFSET: 18,
             self.LENGTH: 10,
             self.DATA_TYPE: Numeric(length=10),
         },
         {
             self.OFFSET: 28,
             self.LENGTH: 10,
             self.DATA_TYPE: Numeric(length=10),
         },
     ]
     self._test_message_type(AuctionSummaryMessage, descriptions)
Ejemplo n.º 5
0
class TradeStatusMessage(BasicMessageType):
    name = 'Trade Status Message'

    timestamp = Field(name='Timestamp',
                      offset=0,
                      length=8,
                      data_type=Numeric(length=8))
    message_type = Field(name='Message Type',
                         offset=8,
                         length=1,
                         data_type=SingleCharacter(character='H'))
    stock_symbol = Field(name='Stock Symbol',
                         offset=9,
                         length=8,
                         data_type=Alpha(length=8))
    halt_status = Field(name='Halt Status',
                        offset=17,
                        length=1,
                        data_type=Alpha(length=1))
    reg_sho_action = Field(name='Reg SHO Action',
                           offset=18,
                           length=1,
                           data_type=Numeric(length=1))
    reserved_1 = Field(name='Reserved1',
                       offset=19,
                       length=1,
                       data_type=Alpha(length=1))
    reserved_2 = Field(name='Reserved2',
                       offset=20,
                       length=1,
                       data_type=Alpha(length=1))
    fields = [
        timestamp, message_type, stock_symbol, halt_status, reg_sho_action,
        reserved_1, reserved_2
    ]
 def test_symbol_clear_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='d'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 12,
             self.DATA_TYPE: Base36Numeric(length=12),
         },
         {
             self.OFFSET: 21,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
         {
             self.OFFSET: 22,
             self.LENGTH: 6,
             self.DATA_TYPE: Numeric(length=6),
         },
         {
             self.OFFSET: 28,
             self.LENGTH: 8,
             self.DATA_TYPE: Alpha(length=8),
         },
         {
             self.OFFSET: 36,
             self.LENGTH: 10,
             self.DATA_TYPE: Numeric(length=10),
         },
         {
             self.OFFSET: 46,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
         {
             self.OFFSET: 47,
             self.LENGTH: 4,
             self.DATA_TYPE: Alpha(length=4),
         },
     ]
     self._test_message_type(AddOrderMessageLong, descriptions)
Ejemplo n.º 7
0
class TradeBreakMessage(BasicMessageType):
    name = 'Trade Break Message'

    timestamp = Field(name='Timestamp',
                      offset=0,
                      length=8,
                      data_type=Numeric(length=8))
    message_type = Field(name='Message Type',
                         offset=8,
                         length=1,
                         data_type=SingleCharacter(character='B'))
    execution_id = Field(name='Execution ID',
                         offset=9,
                         length=12,
                         data_type=Base36Numeric(length=12))
    fields = [timestamp, message_type, execution_id]
 def test_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='P'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 12,
             self.DATA_TYPE: Base36Numeric(length=12),
         },
         {
             self.OFFSET: 21,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
         {
             self.OFFSET: 22,
             self.LENGTH: 6,
             self.DATA_TYPE: Numeric(length=6),
         },
         {
             self.OFFSET: 28,
             self.LENGTH: 6,
             self.DATA_TYPE: Alpha(length=6),
         },
         {
             self.OFFSET: 34,
             self.LENGTH: 10,
             self.DATA_TYPE: Numeric(length=10),
         },
         {
             self.OFFSET: 44,
             self.LENGTH: 12,
             self.DATA_TYPE: Base36Numeric(length=12),
         },
     ]
     self._test_message_type(TradeMessage, descriptions)
 def test_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='B'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 12,
             self.DATA_TYPE: Base36Numeric(length=12),
         },
     ]
     self._test_message_type(TradeBreakMessage, descriptions)
class AuctionUpdateMessage(BasicMessageType):
    name = 'Auction Update Message'

    timestamp = Field(name='Timestamp',
                      offset=0,
                      length=8,
                      data_type=Numeric(length=8))
    message_type = Field(name='Message Type',
                         offset=8,
                         length=1,
                         data_type=SingleCharacter(character='I'))
    stock_symbol = Field(name='Stock Symbol',
                         offset=9,
                         length=8,
                         data_type=Alpha(length=8))
    auction_type = Field(name='Auction Type',
                         offset=17,
                         length=1,
                         data_type=Alpha(length=1))
    reference_price = Field(name='Reference Price',
                            offset=18,
                            length=10,
                            data_type=Numeric(length=10))
    buy_shares = Field(name='Buy Shares',
                       offset=28,
                       length=10,
                       data_type=Numeric(length=10))
    sell_shares = Field(name='Sell Shares',
                        offset=38,
                        length=10,
                        data_type=Numeric(length=10))
    indicative_price = Field(name='Indicative Price',
                             offset=48,
                             length=10,
                             data_type=Numeric(length=10))
    auction_only_price = Field(name='Auction Only Price',
                               offset=58,
                               length=10,
                               data_type=Numeric(length=10))
    fields = [
        timestamp, message_type, stock_symbol, auction_type, reference_price,
        buy_shares, sell_shares, indicative_price, auction_only_price
    ]
Ejemplo n.º 11
0
class TradeMessage(BasicMessageType):
    name = 'Trade Message'

    timestamp = Field(name='Timestamp',
                      offset=0,
                      length=8,
                      data_type=Numeric(length=8))
    message_type = Field(name='Message Type',
                         offset=8,
                         length=1,
                         data_type=SingleCharacter(character='P'))
    order_id = Field(name='Order ID',
                     offset=9,
                     length=12,
                     data_type=Base36Numeric(length=12))
    side_indicator = Field(name='Side Indicator',
                           offset=21,
                           length=1,
                           data_type=Alpha(length=1))
    shares = Field(name='Shares',
                   offset=22,
                   length=6,
                   data_type=Numeric(length=6))
    stock_symbol = Field(name='Stock Symbol',
                         offset=28,
                         length=6,
                         data_type=Alpha(length=6))
    price = Field(name='Price',
                  offset=34,
                  length=10,
                  data_type=Numeric(length=10))
    execution_id = Field(name='Execution ID',
                         offset=44,
                         length=12,
                         data_type=Base36Numeric(length=12))
    fields = [timestamp,
              message_type,
              order_id,
              side_indicator,
              shares,
              stock_symbol,
              price,
              execution_id]
 def test_symbol_clear_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='s'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 8,
             self.DATA_TYPE: Alpha(length=8),
         },
     ]
     self._test_message_type(SymbolClearMessage, descriptions)
Ejemplo n.º 13
0
class RetailPriceImprovementMessage(BasicMessageType):
    name = 'Retail Price Improvement Message'

    timestamp = Field(name='Timestamp',
                      offset=0,
                      length=8,
                      data_type=Numeric(length=8))
    message_type = Field(name='Message Type',
                         offset=8,
                         length=1,
                         data_type=SingleCharacter(character='R'))
    stock_symbol = Field(name='Stock Symbol',
                         offset=9,
                         length=8,
                         data_type=Alpha(length=8))
    retail_price_improvement = Field(name='Retail Price Improvement',
                                     offset=17,
                                     length=1,
                                     data_type=Alpha(length=1))
    fields = [timestamp, message_type, stock_symbol, retail_price_improvement]
 def test_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='H'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 8,
             self.DATA_TYPE: Alpha(length=8),
         },
         {
             self.OFFSET: 17,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
         {
             self.OFFSET: 18,
             self.LENGTH: 1,
             self.DATA_TYPE: Numeric(length=1),
         },
         {
             self.OFFSET: 19,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
         {
             self.OFFSET: 20,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
     ]
     self._test_message_type(TradeStatusMessage, descriptions)
class OrderExecutedMessage(BasicMessageType):
    name = 'Order Executed Message'

    timestamp = Field(name='Timestamp',
                      offset=0,
                      length=8,
                      data_type=Numeric(length=8))
    message_type = Field(name='Message Type',
                         offset=8,
                         length=1,
                         data_type=SingleCharacter(character='E'))
    order_id = Field(name='Order ID',
                     offset=9,
                     length=12,
                     data_type=Base36Numeric(length=12))
    executed_shares = Field(name='Executed Shares',
                            offset=21,
                            length=6,
                            data_type=Numeric(length=6))
    execution_id = Field(name='Execution ID',
                         offset=27,
                         length=12,
                         data_type=Base36Numeric(length=12))
    fields = [timestamp, message_type, order_id, executed_shares, execution_id]
 def test_message(self):
     descriptions = [
         {
             self.OFFSET: 0,
             self.LENGTH: 8,
             self.DATA_TYPE: Numeric(length=8),
         },
         {
             self.OFFSET: 8,
             self.LENGTH: 1,
             self.DATA_TYPE: SingleCharacter(character='R'),
         },
         {
             self.OFFSET: 9,
             self.LENGTH: 8,
             self.DATA_TYPE: Alpha(length=8),
         },
         {
             self.OFFSET: 17,
             self.LENGTH: 1,
             self.DATA_TYPE: Alpha(length=1),
         },
     ]
     self._test_message_type(RetailPriceImprovementMessage, descriptions)
 def setUp(self):
     self.c = SingleCharacter(character='C')