Example #1
0
 def _test_order(self):
     "Generate a test order"
     market_id, contract_ids = self.get_market(0)
     contract_id = contract_ids[0]
     order = Order()
     order.quantity = 400000
     order.price = 2500
     order.side = Order.BUY
     order.market = market_id
     order.contract = contract_id
     order.validate_new()
     return order
Example #2
0
 def test_order(self):
     "Test the `Smarkets.order` method"
     market_id = self.client.str_to_uuid128('1c024')
     contract_id = self.client.str_to_uuid128('1cccc')
     with self._clear_send():
         order = Order()
         order.price = 2500
         order.quantity = 10000
         order.side = Order.BUY
         order.market = market_id
         order.contract = contract_id
         order.validate_new()
         self.client.order(order)
Example #3
0
 def test_quote1(self):
     order_accepted_msg = self._simple_cb(
         self.clients[0], 'seto.order_accepted')
     order_cancelled_msg = self._simple_cb(
         self.clients[0], 'seto.order_cancelled')
     market_quotes_msg = self._simple_cb(
         self.clients[0], 'seto.market_quotes')
     contract_quotes_msg = self._simple_cb(
         self.clients[0], 'seto.contract_quotes')
     market_id, contract_ids = self.get_market(0)
     contract_id = contract_ids[0]
     self.clients[0].subscribe(market_id)
     self.clients[0].read() # read the market quotes
     self.assertEquals(
         market_quotes_msg.type,
         seto.PAYLOAD_MARKET_QUOTES)
     start_qty = 0
     for contract_quotes in market_quotes_msg.market_quotes.contract_quotes:
         if contract_quotes.contract == contract_id:
             start_qty = contract_quotes.bids[0].quantity
     order = Order()
     order.quantity = 100000
     order.price = 2500
     order.side = Order.BUY
     order.market = market_id
     order.contract = contract_id
     order.validate_new()
     self.clients[0].order(order)
     self.clients[0].read(2) # could be accepted or market quotes
     self.assertEquals(
         order_accepted_msg.type,
         seto.PAYLOAD_ORDER_ACCEPTED)
     self.assertEquals(
         contract_quotes_msg.type,
         seto.PAYLOAD_CONTRACT_QUOTES)
     self.assertEquals(
         contract_quotes_msg.contract_quotes.bids[0].quantity,
         start_qty + order.quantity)
     contract_quotes_msg.Clear()
     self.clients[0].order_cancel(order_accepted_msg.order_accepted.order)
     self.clients[0].read(2) # could be accepted or market quotes
     self.assertEquals(
         order_cancelled_msg.type,
         seto.PAYLOAD_ORDER_CANCELLED)
     self.assertEquals(
         order_cancelled_msg.order_cancelled.order,
         order_accepted_msg.order_accepted.order)
     self.assertEquals(
         contract_quotes_msg.contract_quotes.bids[0].quantity,
         start_qty)