def test_graph4(self): """ This test is failing with Python 3.4 if many pictures are drawn. """ fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") if is_travis_or_appveyor() == "appveyor": return fix_tkinter_issues_virtualenv() from matplotlib import pyplot as plt cache = os.path.abspath(os.path.split(__file__)[0]) cache = os.path.join(cache, "temp_cache4") stock = StockPrices("BNP.PA", folder=cache) ret = stock.returns()["2012-04-01":"2014-04-15"] fig, ax = plt.subplots(figsize=(16, 8)) ax = stock.plot(ax=ax) ax = ret.plot(ax=ax, axis=2) img = os.path.abspath( os.path.join( os.path.split(__file__)[0], "temp_image4.png")) if os.path.exists(img): os.remove(img) fig.savefig(img) plt.close('all') assert os.path.exists(img)
def test_save_stock_datetime(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_save_stock_datetime") cache = temp stock = StockPrices(TestStockFileDatetime.tick, use_dtime=True, folder=cache, end=datetime.datetime(2014, 1, 15), url=TestStockFileDatetime.source) file = os.path.join(cache, "save.txt") if os.path.exists(file): os.remove(file) stock.to_csv(file) self.assertTrue(os.path.exists(file)) stock2 = StockPrices(file, sep="\t", use_dtime=True) self.assertEqual(stock.dataframe.shape, stock2.dataframe.shape) df = stock2.dataframe file = os.path.join(cache, "out_excel.xlsx") if os.path.exists(file): os.remove(file) df.to_excel(file) self.assertTrue(os.path.exists(file)) ret = stock2.returns() df.loc["2013-04-01":"2013-04-30", "Close"] = 0 ret.dataframe.loc["2013-04-01":"2013-04-30", "Close"] = 0
def test_graph4(self): """ This test is failing with Python 3.4 if many pictures are drawn. """ fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") if is_travis_or_appveyor() == "appveyor": return fix_tkinter_issues_virtualenv() from matplotlib import pyplot as plt cache = os.path.abspath(os.path.split(__file__)[0]) cache = os.path.join(cache, "temp_cache4") stock = StockPrices("BNP.PA", folder=cache) ret = stock.returns()["2012-04-01":"2014-04-15"] fig, ax = plt.subplots(figsize=(16, 8)) ax = stock.plot(ax=ax) ax = ret.plot(ax=ax, axis=2) img = os.path.abspath( os.path.join(os.path.split(__file__)[0], "temp_image4.png")) if os.path.exists(img): os.remove(img) fig.savefig(img) plt.close('all') assert os.path.exists(img)