예제 #1
0
    def testExample1(self):
        with common.CopyFiles(
            [os.path.join("testcases", "data", "bitstampUSD-2.csv")],
                "bitstampUSD.csv"):
            code = """import sys
sys.path.append('samples')
import bccharts_example_1
bccharts_example_1.main()
"""
            res = common.run_python_code(code)
            lines = common.get_file_lines("30min-bitstampUSD.csv")
            os.remove("30min-bitstampUSD.csv")

            # Float str doesn't behave the same in Pyhton2 and Python3.
            if six.PY3:
                lines = lines[0:1] + [
                    round_csv_line(line, 5, 8) for line in lines[1:]
                ]

            self.assertTrue(res.exit_ok(), res.get_output())
            self.assertEqual(
                lines[0:10],
                common.head_file("30min-bitstampUSD-2.csv",
                                 10,
                                 path="testcases/data"))
            self.assertEqual(
                lines[-10:],
                common.tail_file("30min-bitstampUSD-2.csv",
                                 10,
                                 path="testcases/data"))
예제 #2
0
    def testMarketTiming(self):
        files = []
        instruments = ["VTI", "VEU", "IEF", "VNQ", "DBC", "SPY"]
        for year in range(2007, 2013+1):
            for symbol in instruments:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        # The differences in the output are related to key ordering in dicts.
        if six.PY3:
            expected_output = "market_timing.output.37"
        else:
            expected_output = "market_timing.output.27"

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import market_timing
market_timing.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-10:],
                common.tail_file(expected_output, 10)
            )
예제 #3
0
 def testTutorial3(self):
     with common.CopyFiles(
         [os.path.join("testcases", "data", "orcl-2000.csv")], "."):
         res = common.run_sample_script("tutorial-3.py")
         self.assertEqual(common.head_file("tutorial-3.output", 30),
                          res.get_output_lines(True)[:30])
         self.assertEqual(common.tail_file("tutorial-3.output", 3),
                          res.get_output_lines(True)[-3:])
         self.assertTrue(res.exit_ok())
예제 #4
0
 def testTutorial3(self):
     with common.CopyFiles(
         [os.path.join("testcases", "data", "WIKI-ORCL-2000-quandl.csv")],
             "."):
         res = common.run_sample_module("tutorial-3")
         self.assertEqual(common.head_file("tutorial-3.output", 30),
                          res.get_output_lines(True)[:30], res.get_output())
         self.assertEqual(common.tail_file("tutorial-3.output", 3),
                          res.get_output_lines(True)[-3:], res.get_output())
         self.assertTrue(res.exit_ok())
예제 #5
0
 def testTutorial2(self):
     with common.CopyFiles([os.path.join("data", "orcl-2000.csv")], "."):
         res = common.run_sample_script("tutorial-2.py")
         self.assertEqual(
             common.head_file("tutorial-2.output", 15, path="../samples"),
             res.get_output_lines(True)[:15]
         )
         self.assertEqual(
             common.tail_file("tutorial-2.output", 3, path="../samples"),
             res.get_output_lines(True)[-3:]
         )
예제 #6
0
 def testTutorial2(self):
     with common.CopyFiles([os.path.join("testcases", "data", "orcl-2000.csv")], "."):
         res = common.run_sample_script("tutorial-2.py")
         self.assertEqual(
             common.head_file("tutorial-2.output", 15),
             res.get_output_lines(True)[:15]
         )
         self.assertEqual(
             common.tail_file("tutorial-2.output", 3),
             res.get_output_lines(True)[-3:]
         )
         self.assertTrue(res.exit_ok())
예제 #7
0
 def testExample2(self):
     with common.CopyFiles([os.path.join("data", "30min-bitstampUSD-2.csv")], "30min-bitstampUSD.csv"):
         from samples import bccharts_example_2
         res = bccharts_example_2.main(False)
         self.assertEqual(
             res.get_output_lines()[0:10],
             common.head_file("bccharts_example_2.output", 10, path="data")
         )
         self.assertEqual(
             res.get_output_lines()[-10:],
             common.tail_file("bccharts_example_2.output", 10, path="data")
         )
예제 #8
0
 def testTutorial3(self):
     with common.CopyFiles([os.path.join("testcases", "data", "WIKI-ORCL-2000-quandl.csv")], "."):
         res = common.run_sample_module("tutorial-3")
         self.assertEqual(
             common.head_file("tutorial-3.output", 30),
             res.get_output_lines(True)[:30]
         )
         self.assertEqual(
             common.tail_file("tutorial-3.output", 3),
             res.get_output_lines(True)[-3:]
         )
         self.assertTrue(res.exit_ok())
예제 #9
0
 def testCSVFeed(self):
     with common.CopyFiles([os.path.join("..", "samples", "data", "quandl_gold_2.csv")], "."):
         res = common.run_sample_script("csvfeed_1.py")
         lines = res.get_output_lines(True)
         self.assertEqual(
             common.head_file("csvfeed_1.output", 10, path="../samples"),
             lines[0:10]
         )
         self.assertEqual(
             common.tail_file("csvfeed_1.output", 10, path="../samples"),
             lines[-10:]
         )
예제 #10
0
    def testSMACrossOver(self):
        files = []
        for year in range(2011, 2013):
            for symbol in ["aapl"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("..", "samples", "data", fileName))

        with common.CopyFiles(files, "."):
            res = common.run_sample_script("sma_crossover_sample.py")

            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("sma_crossover.output", 1)
            )
예제 #11
0
    def testCSVFeed(self):
        with common.CopyFiles(
            [os.path.join("samples", "data", "quandl_gold_2.csv")], "."):
            code = """import sys
sys.path.append('samples')
import csvfeed_1
"""
            res = common.run_python_code(code)
            lines = res.get_output_lines(True)
            self.assertEqual(common.head_file("csvfeed_1.output", 10),
                             lines[0:10])
            self.assertEqual(common.tail_file("csvfeed_1.output", 10),
                             lines[-10:])
            self.assertTrue(res.exit_ok())
예제 #12
0
    def testBBands(self):
        files = []
        for year in range(2011, 2013):
            for symbol in ["yhoo"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("..", "samples", "data", fileName))

        with common.CopyFiles(files, "."):
            from samples import bbands
            res = bbands.main(False)
            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("bbands.output", 1, path="../samples")
            )
예제 #13
0
    def testVWAPMomentum(self):
        files = []
        for year in range(2011, 2013):
            for symbol in ["aapl"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("..", "samples", "data", fileName))

        with common.CopyFiles(files, "."):
            res = common.run_sample_script("vwap_momentum.py")

            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("vwap_momentum.output", 1, path="../samples")
            )
예제 #14
0
    def testErnieChanGldVsGdx(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["gld", "gdx"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("..", "samples", "data", fileName))

        with common.CopyFiles(files, "."):
            res = common.run_sample_script("statarb_erniechan.py")

            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("statarb_erniechan.output", 1, path="../samples")
            )
예제 #15
0
    def testEventStudy(self):
        files = []
        for year in range(2008, 2010):
            for symbol in ["AA", "AES", "AIG"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("..", "samples", "data", fileName))

        with common.CopyFiles(files, "."):
            from samples import eventstudy
            res = eventstudy.main(False)

            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("eventstudy.output", 1, path="../samples")
            )
예제 #16
0
    def testExample2(self):
        with common.CopyFiles(
            [os.path.join("testcases", "data", "30min-bitstampUSD-2.csv")],
                "30min-bitstampUSD.csv"):
            code = """import sys
sys.path.append('samples')
import bccharts_example_2
bccharts_example_2.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok(), res.get_output())
            self.assertEqual(res.get_output_lines()[0:10],
                             common.head_file("bccharts_example_2.output", 10))
            self.assertEqual(res.get_output_lines()[-10:],
                             common.tail_file("bccharts_example_2.output", 10))
예제 #17
0
    def testRSI2(self):
        files = []
        for year in range(2009, 2013):
            for symbol in ["DIA"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("..", "samples", "data", fileName))

        with common.CopyFiles(files, "."):
            from samples import rsi2_sample
            res = rsi2_sample.main(False)

            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("rsi2_sample.output", 1, path="../samples")
            )
예제 #18
0
    def testExample1(self):
        with common.CopyFiles([os.path.join("data", "bitstampUSD-2.csv")], "bitstampUSD.csv"):
            from samples import bccharts_example_1
            bccharts_example_1.main()

            lines = common.get_file_lines("30min-bitstampUSD.csv")
            os.remove("30min-bitstampUSD.csv")

            self.assertEqual(
                lines[0:10],
                common.head_file("30min-bitstampUSD-2.csv", 10, path="data")
            )
            self.assertEqual(
                lines[-10:],
                common.tail_file("30min-bitstampUSD-2.csv", 10, path="data")
            )
예제 #19
0
    def testVWAPMomentum(self):
        files = []
        for year in range(2011, 2013):
            for symbol in ["AAPL"]:
                fileName = "WIKI-%s-%d-quandl.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import vwap_momentum
vwap_momentum.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok(), res.get_output())
            self.assertEqual(res.get_output_lines()[-1:],
                             common.tail_file("vwap_momentum.output", 1))
예제 #20
0
    def testErnieChanGldVsGdx(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["gld", "gdx"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """
from samples import statarb_erniechan
statarb_erniechan.main(False)
"""
            res = common.run_python_code(code)

            self.assertTrue(res.exit_ok(), res.get_output())
            self.assertEqual(res.get_output_lines()[-1:],
                             common.tail_file("statarb_erniechan.output", 1))
예제 #21
0
    def testExample2(self):
        with common.CopyFiles([os.path.join("testcases", "data", "30min-bitstampUSD-2.csv")], "30min-bitstampUSD.csv"):
            code = """import sys
sys.path.append('samples')
import bccharts_example_2
bccharts_example_2.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok(), res.get_output())
            self.assertEqual(
                res.get_output_lines()[0:10],
                common.head_file("bccharts_example_2.output", 10, path="testcases/data")
            )
            self.assertEqual(
                res.get_output_lines()[-10:],
                common.tail_file("bccharts_example_2.output", 10, path="testcases/data")
            )
예제 #22
0
    def testCSVFeed(self):
        with common.CopyFiles([os.path.join("samples", "data", "quandl_gold_2.csv")], "."):
            code = """import sys
sys.path.append('samples')
import csvfeed_1
"""
            res = common.run_python_code(code)
            lines = res.get_output_lines(True)
            self.assertEqual(
                common.head_file("csvfeed_1.output", 10),
                lines[0:10]
            )
            self.assertEqual(
                common.tail_file("csvfeed_1.output", 10),
                lines[-10:]
            )
            self.assertTrue(res.exit_ok())
예제 #23
0
    def testEventStudy(self):
        files = []
        for year in range(2008, 2010):
            for symbol in ["AA", "AES", "AIG"]:
                fileName = "%s-%d-googlefinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import eventstudy
eventstudy.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(res.get_output_lines()[-1:],
                             common.tail_file("eventstudy.output", 1))
예제 #24
0
    def testBBands(self):
        files = []
        for year in range(2011, 2013):
            for symbol in ["yhoo"]:
                fileName = "%s-%d-googlefinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import bbands
bbands.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(res.get_output_lines()[-1:],
                             common.tail_file("bbands.output", 1))
예제 #25
0
    def testRSI2(self):
        files = []
        for year in range(2009, 2013):
            for symbol in ["DIA"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import rsi2_sample
rsi2_sample.main(False)
"""
            res = common.run_python_code(code)

            self.assertTrue(res.exit_ok(), res.get_output())
            self.assertEqual(res.get_output_lines()[-4:],
                             common.tail_file("rsi2_sample.output", 4))
예제 #26
0
    def testMarketTiming(self):
        init_data_path()
        files = []
        instruments = ["VTI", "VEU", "IEF", "VNQ", "DBC", "SPY"]
        for year in range(2007, 2013 + 1):
            for symbol in instruments:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("..", "samples", "data", fileName))

        with common.CopyFiles(files, "data"):
            from samples import market_timing
            res = market_timing.main(False)

            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-10:],
                common.tail_file("market_timing.output", 10, path="../samples")
            )
예제 #27
0
    def testQuandl(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["GORO"]:
                fileName = "WIKI-%s-%d-quandl.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))
        files.append(os.path.join("..", "samples", "data", "quandl_gold_2.csv"))

        with common.CopyFiles(files, "."):
            from samples import quandl_sample
            res = quandl_sample.main(False)
            self.assertEqual(
                res.get_output_lines()[0:10],
                common.head_file("quandl_sample.output", 10, path="../samples")
            )
            self.assertEqual(
                res.get_output_lines()[-10:],
                common.tail_file("quandl_sample.output", 10, path="../samples")
            )
예제 #28
0
    def testErnieChanGldVsGdx(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["gld", "gdx"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """
from samples import statarb_erniechan
statarb_erniechan.main(False)
"""
            res = common.run_python_code(code)

            self.assertTrue(res.exit_ok(), res.get_output())
            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("statarb_erniechan.output", 1)
            )
예제 #29
0
    def testMarketTiming(self):
        init_data_path()
        files = []
        instruments = ["VTI", "VEU", "IEF", "VNQ", "DBC", "SPY"]
        for year in range(2007, 2013 + 1):
            for symbol in instruments:
                fileName = "%s-%d-googlefinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "data"):
            code = """import sys
sys.path.append('samples')
import market_timing
market_timing.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(res.get_output_lines()[-10:],
                             common.tail_file("market_timing.output", 10))
예제 #30
0
    def testErnieChanGldVsGdx(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["gld", "gdx"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import statarb_erniechan
statarb_erniechan.main(False)
"""
            res = common.run_python_code(code)
            obtained = res.get_output_lines()[-2]
            expected = common.tail_file("statarb_erniechan.output", 1)[0]
            self.assertEquals(expected, obtained, "Got this lines %s instead" % (res.get_output_lines()))
            # self.assertTrue(common.compare_tail("statarb_erniechan.output", res.get_output_lines()[-2:-1]))
            self.assertTrue(res.exit_ok())
예제 #31
0
    def testEventStudy(self):
        files = []
        for year in range(2008, 2010):
            for symbol in ["IBM", "AES", "AIG"]:
                fileName = "WIKI-%s-%d-quandl.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import eventstudy
eventstudy.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("eventstudy.output", 1)
            )
예제 #32
0
    def testBBands(self):
        files = []
        for year in range(2011, 2013):
            for symbol in ["yhoo"]:
                fileName = "WIKI-%s-%d-quandl.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import bbands
bbands.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-10:],
                common.tail_file("bbands.output", 10)
            )
예제 #33
0
    def testQuandl(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["GORO"]:
                fileName = "WIKI-%s-%d-quandl.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))
        files.append(os.path.join("samples", "data", "quandl_gold_2.csv"))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import quandl_sample
quandl_sample.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(res.get_output_lines()[0:10],
                             common.head_file("quandl_sample.output", 10))
            self.assertEqual(res.get_output_lines()[-10:],
                             common.tail_file("quandl_sample.output", 10))
예제 #34
0
    def testSMACrossOver(self):
        files = []
        for year in range(2011, 2013):
            for symbol in ["aapl"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import sma_crossover_sample
sma_crossover_sample.main(False)
"""
            res = common.run_python_code(code)

            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-1:],
                common.tail_file("sma_crossover.output", 1)
            )
예제 #35
0
    def testExample1(self):
        with common.CopyFiles([os.path.join("testcases", "data", "bitstampUSD-2.csv")], "bitstampUSD.csv"):
            code = """import sys
sys.path.append('samples')
import bccharts_example_1
bccharts_example_1.main()
"""
            res = common.run_python_code(code)
            lines = common.get_file_lines("30min-bitstampUSD.csv")
            os.remove("30min-bitstampUSD.csv")

            self.assertTrue(res.exit_ok())
            self.assertEqual(
                lines[0:10],
                common.head_file("30min-bitstampUSD-2.csv", 10, path="testcases/data")
            )
            self.assertEqual(
                lines[-10:],
                common.tail_file("30min-bitstampUSD-2.csv", 10, path="testcases/data")
            )
예제 #36
0
    def testRSI2(self):
        files = []
        for year in range(2009, 2013):
            for symbol in ["DIA"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import rsi2_sample
rsi2_sample.main(False)
"""
            res = common.run_python_code(code)

            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-4:],
                common.tail_file("rsi2_sample.output", 4)
            )
예제 #37
0
    def testMarketTiming(self):
        init_data_path()
        files = []
        instruments = ["VTI", "VEU", "IEF", "VNQ", "DBC", "SPY"]
        for year in range(2007, 2013+1):
            for symbol in instruments:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "data"):
            code = """import sys
sys.path.append('samples')
import market_timing
market_timing.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[-10:],
                common.tail_file("market_timing.output", 10)
            )
예제 #38
0
    def testErnieChanGldVsGdx(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["gld", "gdx"]:
                fileName = "%s-%d-yahoofinance.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import statarb_erniechan
statarb_erniechan.main(False)
"""
            res = common.run_python_code(code)
            obtained = res.get_output_lines()[-2]
            expected = common.tail_file("statarb_erniechan.output", 1)[0]
            self.assertEquals(
                expected, obtained,
                "Got this lines %s instead" % (res.get_output_lines()))
            # self.assertTrue(common.compare_tail("statarb_erniechan.output", res.get_output_lines()[-2:-1]))
            self.assertTrue(res.exit_ok())
예제 #39
0
    def testExample1(self):
        with common.CopyFiles([os.path.join("testcases", "data", "bitstampUSD-2.csv")], "bitstampUSD.csv"):
            code = """import sys
sys.path.append('samples')
import bccharts_example_1
bccharts_example_1.main()
"""
            res = common.run_python_code(code)
            lines = common.get_file_lines("30min-bitstampUSD.csv")
            os.remove("30min-bitstampUSD.csv")

            # Float str doesn't behave the same in Pyhton2 and Python3.
            if six.PY3:
                lines = lines[0:1] + [round_csv_line(line, 5, 8) for line in lines[1:]]

            self.assertTrue(res.exit_ok())
            self.assertEqual(
                lines[0:10],
                common.head_file("30min-bitstampUSD-2.csv", 10, path="testcases/data")
            )
            self.assertEqual(
                lines[-10:],
                common.tail_file("30min-bitstampUSD-2.csv", 10, path="testcases/data")
            )
예제 #40
0
    def testQuandl(self):
        files = []
        for year in range(2006, 2013):
            for symbol in ["GORO"]:
                fileName = "WIKI-%s-%d-quandl.csv" % (symbol, year)
                files.append(os.path.join("samples", "data", fileName))
        files.append(os.path.join("samples", "data", "quandl_gold_2.csv"))

        with common.CopyFiles(files, "."):
            code = """import sys
sys.path.append('samples')
import quandl_sample
quandl_sample.main(False)
"""
            res = common.run_python_code(code)
            self.assertTrue(res.exit_ok())
            self.assertEqual(
                res.get_output_lines()[0:10],
                common.head_file("quandl_sample.output", 10)
            )
            self.assertEqual(
                res.get_output_lines()[-10:],
                common.tail_file("quandl_sample.output", 10)
            )