예제 #1
0
 def testCustomLoader(self):
     from dynts.conf import settings
     settings.default_loader = CustomLoader
     dynts.evaluate('BLT:google').unwind()
     data = CustomLoader.data
     self.assertTrue(data)
     self.assertTrue('BLT:GOOGLE' in data)
예제 #2
0
파일: api.py 프로젝트: OspreyX/flow
def get_analysis(code = None, start = None, end = None, format = None, **kwargs):
    '''Econometric analysis'''
    res = dynts.evaluate(code, start = start, end = end)
    if format:
        return res.dump(format = format)
    else:
        return res
예제 #3
0
def get_analysis(code=None, start=None, end=None, format=None, **kwargs):
    '''Econometric analysis'''
    res = dynts.evaluate(code, start=start, end=end)
    if format:
        return res.dump(format=format)
    else:
        return res
예제 #4
0
 def testVbaJson(self):
     ts = dynts.evaluate('AMZN, AAPL').dump('jsonvba')
     self.assertTrue(isinstance(ts, list))
     head = ts[0]
     self.assertEqual(['Date', 'AMZN', 'AAPL'], head)
     for row in ts[1:]:
         self.assertTrue(isinstance(row[0], int))
         self.assertEqual(len(row), 3)
예제 #5
0
 def testVbaJson(self):
     ts = dynts.evaluate("AMZN,AAPL").dump("jsonvba")
     self.assertTrue(isinstance(ts, list))
     head = ts[0]
     self.assertEqual(["Date", "AMZN", "AAPL"], head)
     for row in ts[1:]:
         self.assertTrue(isinstance(row[0], int))
         self.assertEqual(len(row), 3)
예제 #6
0
파일: tests.py 프로젝트: pombredanne/dynts
 def testVbaJson(self):
     ts = dynts.evaluate('AMZN,AAPL').dump('jsonvba')
     self.assertTrue(isinstance(ts,list))
     head = ts[0]
     self.assertEqual(['Date','AMZN','AAPL'],head)
     for row in ts[1:]:
         self.assertTrue(isinstance(row[0],int))
         self.assertEqual(len(row),3)
예제 #7
0
 def testNoParameters(self):
     '''Test mean function with zero parameters'''
     expression = '%s(GOOG)' % self.function
     result = dynts.evaluate(expression)
     self.assertEqual(str(result),expression)
     self.assertEqual(len(result.data),1)
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(),1)
예제 #8
0
파일: tests.py 프로젝트: pombredanne/dynts
 def testFlot1(self):
     ts = dynts.evaluate('YHOO,GOOG').dump('flot')
     dts = ts.todict()
     self.assertEqual(dts['type'],'multiplot')
     self.assertEqual(len(dts['plots']),1)
     plot = dts['plots'][0]
     self.assertEqual(plot['type'],'timeseries')
     self.assertEqual(len(plot['series']),2)
     data = json.dumps(dts)
예제 #9
0
 def testScatter(self):
     ts = dynts.evaluate('scatter(YHOO, GOOG)').dump('flot')
     dts = ts.todict()
     self.assertEqual(dts['type'], 'multiplot')
     self.assertEqual(len(dts['plots']), 1)
     plot = dts['plots'][0]
     self.assertEqual(plot['type'], 'xy')
     self.assertEqual(len(plot['series']), 1)
     serie = plot['series'][0]
예제 #10
0
 def testTwoSeries(self):
     e = '%s(GOOG,YHOO)' % self.function
     result = dynts.evaluate(e)
     symbols = result.expression.symbols()
     self.assertEqual(len(symbols), 2)
     self.assertEqual(len(result.data), 2)
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(), 2)
예제 #11
0
 def testNoParameters(self):
     '''Test mean function with zero parameters'''
     expression = '%s(GOOG)' % self.function
     result = dynts.evaluate(expression)
     self.assertEqual(str(result), expression)
     self.assertEqual(len(result.data), 1)
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(), 1)
예제 #12
0
 def testTwoSeries(self):
     e = '%s(GOOG, YHOO)' % self.function
     result = dynts.evaluate(e)
     symbols = result.expression.symbols()
     self.assertEqual(len(symbols), 2)
     self.assertEqual(len(result.data), 2)
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(), 2)
예제 #13
0
 def testFlot1(self):
     ts = dynts.evaluate("YHOO,GOOG").dump("flot")
     dts = ts.todict()
     self.assertEqual(dts["type"], "multiplot")
     self.assertEqual(len(dts["plots"]), 1)
     plot = dts["plots"][0]
     self.assertEqual(plot["type"], "timeseries")
     self.assertEqual(len(plot["series"]), 2)
     data = json.dumps(dts)
예제 #14
0
 def testFlot1(self):
     ts = dynts.evaluate('YHOO, GOOG').dump('flot')
     dts = ts.todict()
     self.assertEqual(dts['type'], 'multiplot')
     self.assertEqual(len(dts['plots']), 1)
     plot = dts['plots'][0]
     self.assertEqual(plot['type'], 'timeseries')
     self.assertEqual(len(plot['series']), 2)
     data = json.dumps(dts)
예제 #15
0
파일: tests.py 프로젝트: pombredanne/dynts
 def testScatter(self):
     ts = dynts.evaluate('scatter(YHOO,GOOG)').dump('flot')
     dts = ts.todict()
     self.assertEqual(dts['type'],'multiplot')
     self.assertEqual(len(dts['plots']),1)
     plot = dts['plots'][0]
     self.assertEqual(plot['type'],'scatter')
     self.assertEqual(len(plot['series']),1)
     serie = plot['series'][0]
예제 #16
0
 def testScatter(self):
     ts = dynts.evaluate("scatter(YHOO,GOOG)").dump("flot")
     dts = ts.todict()
     self.assertEqual(dts["type"], "multiplot")
     self.assertEqual(len(dts["plots"]), 1)
     plot = dts["plots"][0]
     self.assertEqual(plot["type"], "xy")
     self.assertEqual(len(plot["series"]), 1)
     serie = plot["series"][0]
예제 #17
0
 def testWindowParameter(self):
     '''Test mean function with one parameter'''
     e = '%(f)s(GOOG,window=30),%(f)s(GOOG,window=60)' % {'f':self.function}
     result = dynts.evaluate(e)
     symbols = result.expression.symbols()
     self.assertEqual(len(symbols),1)
     self.assertEqual(len(result.data),1)
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(),2)
예제 #18
0
파일: tests.py 프로젝트: pombredanne/dynts
 def testDataProvider(self):
     result = dynts.evaluate('2*GOOG,GOOG')
     self.assertEqual(len(result.data),1)
     self.assertEqual(result.expression,dynts.parse('2*GOOG,GOOG'))
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(),2)
     ts1 = data.serie(0)
     ts2 = data.serie(1)
     for v1,v2 in zip(ts1,ts2):
         self.assertAlmostEqual(v1,2.*v2)
예제 #19
0
파일: dsl.py 프로젝트: arjunpmm/dynts
 def testDataProvider(self):
     result = dynts.evaluate('2*GOOG, GOOG')
     self.assertEqual(len(result.data), 1)
     self.assertEqual(result.expression, dynts.parse('2*GOOG, GOOG'))
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(), 2)
     ts1 = data.serie(0)
     ts2 = data.serie(1)
     for v1, v2 in zip(ts1, ts2):
         self.assertAlmostEqual(v1, 2. * v2)
예제 #20
0
파일: tests.py 프로젝트: pombredanne/dynts
 def testBinOpSerieFunction(self):
     '''Get a timeseries and a function and check for consistency'''
     res = dynts.parse('goog:yahoo-ma(goog:yahoo,window=30)')
     self.assertEqual(res.symbols(),['GOOG:YAHOO'])
     self.assertEqual(len(res),2)
     self.assertEqual(str(res[0]),'GOOG:YAHOO')
     self.assertEqual(str(res[1]),'ma(GOOG:YAHOO,window=30)')
     result = dynts.evaluate(res)
     self.assertEqual(len(result.data),1)
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(),1)
예제 #21
0
파일: dsl.py 프로젝트: arjunpmm/dynts
 def testBinOpSerieFunction(self):
     '''Get a timeseries and a function and check for consistency'''
     res = dynts.parse('goog:yahoo-ma(goog:yahoo, window=30)')
     self.assertEqual(res.symbols(), ['GOOG:YAHOO'])
     self.assertEqual(len(res), 2)
     self.assertEqual(str(res[0]), 'GOOG:YAHOO')
     self.assertEqual(str(res[1]), 'ma(GOOG:YAHOO, window=30)')
     result = dynts.evaluate(res)
     self.assertEqual(len(result.data), 1)
     data = result.ts()
     self.assertTrue(dynts.istimeseries(data))
     self.assertEqual(data.count(), 1)
예제 #22
0
 def testWindowParameter(self):
     '''Test mean function with one parameter'''
     e = '%(f)s(GOOG,window=30),%(f)s(GOOG,window=60)' % {'f':self.function}
     result = dynts.evaluate(e)
     symbols = result.expression.symbols()
     self.assertEqual(len(symbols),1)
     self.assertEqual(len(result.data),1)
     ts = result.ts()
     self.assertTrue(dynts.istimeseries(ts))
     self.assertEqual(ts.count(),2)
     back = ts[-1]
     self.assertEqual(len(back),2)
     self.assertEqual(back[0],back[0])
     self.assertEqual(back[-1],back[-1])
예제 #23
0
 def testWindowParameter(self):
     '''Test mean function with one parameter'''
     e = ('%(f)s(GOOG, window=30), %(f)s(GOOG, window=60)' % {
         'f': self.function
     })
     result = dynts.evaluate(e)
     symbols = result.expression.symbols()
     self.assertEqual(len(symbols), 1)
     self.assertEqual(len(result.data), 1)
     ts = result.ts()
     self.assertTrue(dynts.istimeseries(ts))
     self.assertEqual(ts.count(), 2)
     back = ts[-1]
     self.assertEqual(len(back), 2)
     self.assertEqual(back[0], back[0])
     self.assertEqual(back[-1], back[-1])
예제 #24
0
 def testTSName(self):
     '''
     The dslresult should include an attribute 'name' 
     which is the equivalent to the expression passed.
     In situations where multiple timeseries are returned 
     the name should be the concatenation of all the names 
     joined by "__".
     '''
     expressions = ['GOOG+YHOO',
                    '2*GOOG',
                    'GOOG,YHOO',
                    ]
     for expr in expressions:
         result = dynts.evaluate(expr)
         ts = result.ts()
         name = ts.name
         
         expected_name = '__'.join(expr.split(','))
         self.assertEqual(name, expected_name)
예제 #25
0
파일: views.py 프로젝트: GunioRobot/dynts
 def getdata(self, request, expression, start, end, **kwargs):
     res = dynts.evaluate(expression, start=start, end=end)
     return res.dump('flot')
예제 #26
0
파일: views.py 프로젝트: GunioRobot/dynts
 def getdata(self, request, expression, start, end, **kwargs):
     res = dynts.evaluate(expression, start = start, end = end)
     return res.dump('flot')
예제 #27
0
 def testyahoo(self):
     ts = dynts.evaluate('GOOG:yahoo')
     self.assertTrue(ts)