예제 #1
0
 def setUpClass(self):
     self.pyTradeMonster = PyTradeMonster('../cred.dat')
     self.quotesService = QuotesService(self.pyTradeMonster)
     self.symbolDict = {
         'SPY': TradeMonsterConstants.INSTRUMENTS.EQUITY,
         'SPYX1517C300000': TradeMonsterConstants.INSTRUMENTS.OPTION
     }
예제 #2
0
class TestQuotesService(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.pyTradeMonster = PyTradeMonster('../cred.dat')
        self.quotesService = QuotesService(self.pyTradeMonster)
        self.symbolDict = {
            'SPY': TradeMonsterConstants.INSTRUMENTS.EQUITY,
            'SPYX1517C300000': TradeMonsterConstants.INSTRUMENTS.OPTION
        }

    def testQuoteRetrieval(self):
        results = self.quotesService.getParsedOptionChain('SPY')
        self.assertGreater(len(results), 1)

    def testQuotePayload(self):
        xmlStr = self.quotesService.quoteRequests.createQuotesPayload(
            self.symbolDict)
        xmlObj = xmltodict.parse(xmlStr)
        self.assertEqual(xmlObj['getQuotes']['item'][0]['symbol'], 'SPY')

    def testQuoteSymbol(self):
        results = self.quotesService.getParsedQuotes(self.symbolDict)
        self.assertTrue(len(results) == 2)
        spyEquity = results['SPY'].instrumentType
        self.assertEquals(spyEquity, TradeMonsterConstants.INSTRUMENTS.EQUITY)
class TestQuotesService(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        self.pyTradeMonster = PyTradeMonster('../cred.dat')
        self.quotesService = QuotesService(self.pyTradeMonster)
        self.symbolDict = {'SPY' : TradeMonsterConstants.INSTRUMENTS.EQUITY, 'SPYX1517C300000' : TradeMonsterConstants.INSTRUMENTS.OPTION}


    def testQuoteRetrieval(self):
        results = self.quotesService.getParsedOptionChain('SPY')
        self.assertGreater(len(results), 1)

    def testQuotePayload(self):
        xmlStr = self.quotesService.quoteRequests.createQuotesPayload(self.symbolDict)
        xmlObj = xmltodict.parse(xmlStr)
        self.assertEqual(xmlObj['getQuotes']['item'][0]['symbol'],'SPY')


    def testQuoteSymbol(self):
        results = self.quotesService.getParsedQuotes(self.symbolDict)
        self.assertTrue(len(results) == 2)
        spyEquity = results['SPY'].instrumentType
        self.assertEquals(spyEquity,TradeMonsterConstants.INSTRUMENTS.EQUITY)
 def setUpClass(self):
     self.pyTradeMonster = PyTradeMonster('../cred.dat')
     self.quotesService = QuotesService(self.pyTradeMonster)
     self.symbolDict = {'SPY' : TradeMonsterConstants.INSTRUMENTS.EQUITY, 'SPYX1517C300000' : TradeMonsterConstants.INSTRUMENTS.OPTION}