Exemplo n.º 1
0
 def testInvalidClientID(self):
   try:
     TradeDataHolder.recordAcquisitionTransaction(robot=None,bullish=self.bull_i_cID,bearish=self.bear_i_cID)
   except InvalidTradeDataHolderException:
     self.assertEqual(True,True)
   else:
     self.assertEqual(False,True)
Exemplo n.º 2
0
 def testNegativePrice(self):
   try:
     TradeDataHolder.recordAcquisitionTransaction(robot=None,bullish=self.bull_n_p,bearish=self.bear_n_p)
   except InvalidTradeDataHolderException:
     self.assertEqual(True,True)
   else:
     self.assertEqual(False,True)
Exemplo n.º 3
0
 def testEmptySymbol(self):
   try:
     TradeDataHolder.recordAcquisitionTransaction(robot=None,bullish=self.bull_empty,bearish=self.bear_empty)
   except InvalidTradeDataHolderException:
     self.assertEqual(True,True)
   else:
     self.assertEqual(False,True)
Exemplo n.º 4
0
  def testBuyPairSellBull(self):
    bull_data = TradeDataHolder.objects.get(buy_order_client_id=self.bullish["bull_buy_order_client_id"])    
    bear_data = TradeDataHolder.objects.get(buy_order_client_id=self.bearish["bear_buy_order_client_id"])
    self.assertEqual(bear_data.isValid(),True) 
    self.assertEqual(bull_data.isValid(),True)     
    
    sale_order = dict()
    sale_order['sell_order_client_id']= bull_data.getSellClientOrderID()
    sale_order['buy_order_client_id']= bull_data.getBuyClientOrderID()
    sale_order['sell_date'] = datetime.datetime.now(getTimeZoneInfo())
    sale_order['sell_price'] = 126.95
    bull_data = TradeDataHolder.recordDispositionTransaction(robot=None,order=sale_order)
    self.assertEqual(bull_data.isValidAfterSale(),True) 
    self.assertEqual(bull_data.isRealized(), True) 
    self.assertEqual(bull_data.isUnRealized(), False) 
    self.assertEqual(bear_data.isRealized(), False) 
    self.assertEqual(bear_data.isUnRealized(), True) 

    sale_order = dict()
    sale_order['sell_order_client_id']= bear_data.getSellClientOrderID()
    sale_order['buy_order_client_id']= bear_data.getBuyClientOrderID()
    sale_order['sell_date'] = datetime.datetime.now(getTimeZoneInfo())
    sale_order['sell_price'] = 6.95

    bear_data = TradeDataHolder.recordDispositionTransaction(robot=None,order=sale_order)
    self.assertEqual(bear_data.isValidAfterSale(),True) 
    self.assertEqual(bear_data.isRealized(), True) 
    self.assertEqual(bear_data.isUnRealized(), False) 
Exemplo n.º 5
0
  def setUpTestData(self):
    if shouldUsePrint():
      print("Setting up {0}".format(self.testname))

    self.buy_order_ids=TradeDataHolder.generateBuyOrderClientIDs(project_root='project_name',
          bull_symbol=self.bull_symbol,bear_symbol=self.bear_symbol)

    self.sell_order_ids=TradeDataHolder.generateSellOrderClientIDs(project_root='project_name',
          bull_symbol=self.bull_symbol,bear_symbol=self.bear_symbol)
Exemplo n.º 6
0
  def setUpTestData(self):
    if shouldUsePrint():
      print("Setting up {0}".format(self.testname))

    index = 0
    self.bullish = dict()
    self.bearish = dict()
    for x in self.current_times:
      self.bullish['symbol']=self.bull_symbol
      self.bullish['price']=self.bull_prices[index]
      self.bullish['qty']=10
      self.bullish['date']=self.current_times[index]

      self.bearish['symbol']=self.bear_symbol
      self.bearish['price']=self.bear_prices[index]
      self.bearish['qty']=170
      self.bearish['date']=self.current_times[index]
      order_ids = TradeDataHolder.generateBuyOrderClientIDs(bear_symbol=self.bear_symbol,bull_symbol=self.bull_symbol,
                                project_root='HelloWorld')
      self.bullish['bull_buy_order_client_id']= order_ids['bull_buy_order_client_id']
      self.bearish['bear_buy_order_client_id']= order_ids['bear_buy_order_client_id']
      TradeDataHolder.recordAcquisitionTransaction(robot=None,bullish=self.bullish,bearish=self.bearish)
      index = index+1
Exemplo n.º 7
0
 def setUpTestData(self):
   if shouldUsePrint():
     print("Setting up {0}".format(self.testname))
   TradeDataHolder.recordAcquisitionTransaction(robot=None,bullish=self.bull1,bearish=self.bear1)
   TradeDataHolder.recordAcquisitionTransaction(robot=None,bullish=self.bull2,bearish=self.bear2)
   TradeDataHolder.recordAcquisitionTransaction(robot=None,bullish=self.bull3,bearish=self.bear3)