From bbc4611af34945af1b47e4e00fec29687848c4df Mon Sep 17 00:00:00 2001 From: Andrew Dinh Date: Sun, 21 Apr 2019 22:16:55 -0700 Subject: [PATCH] Error-handling for plotting linear regression Moved copyright info to top of files Changed links to relative --- CONTRIBUTING.md | 4 +- Functions.py | 34 ++++++++-------- README.md | 4 +- main.py | 106 +++++++++++++++++++++++++++--------------------- 4 files changed, 81 insertions(+), 67 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fa5b131..ff942cf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,8 +27,8 @@ There are a few things you might consider when filing your issue: To develop on fund-indicators you'll probably want to: -1. Read the [code of conduct](https://github.com/andrewkdinh/fund-indicators/blob/master/CODE-OF-CONDUCT.md) -2. Install normally, as documented in the [README](https://github.com/andrewkdinh/fund-indicators#quickstart) +1. Read the [code of conduct](./CODE-OF-CONDUCT.md) +2. Install normally, as documented in the [README](./README.md#quickstart) 3. Read the [documentation](https://github.com/andrewkdinh/fund-indicators/wiki) (although it's not much) 4. Read the section above to understand the ways you could best help this project diff --git a/Functions.py b/Functions.py index 77644f9..dee9a0c 100644 --- a/Functions.py +++ b/Functions.py @@ -1,3 +1,20 @@ +''' +Copyright (C) 2019 Andrew Dinh + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +''' + # Python file for general functions import sys @@ -256,20 +273,3 @@ def main(): if __name__ == "__main__": main() - -''' -Copyright (C) 2019 Andrew Dinh - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -''' diff --git a/README.md b/README.md index ba92c4b..3a8351a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # fund-indicators -[![License](https://img.shields.io/github/license/andrewkdinh/fund-indicators.svg)](https://raw.githubusercontent.com/andrewkdinh/fund-indicators/master/LICENSE) +[![License](https://img.shields.io/github/license/andrewkdinh/fund-indicators.svg)](./LICENSE) [![Latest Commits](https://img.shields.io/github/last-commit/andrewkdinh/fund-indicators.svg)](https://github.com/andrewkdinh/fund-indicators/commits/master) ![](https://img.shields.io/github/languages/top/andrewkdinh/fund-indicators.svg) ![](https://img.shields.io/github/languages/code-size/andrewkdinh/fund-indicators.svg) @@ -45,7 +45,7 @@ python main.py ## Contributing -Want to help? Great! Check out the [CONTRIBUTING.md](https://github.com/andrewkdinh/fund-indicators/blob/master/CONTRIBUTING.md) file! +Want to help? Great! Check out the [CONTRIBUTING.md](./CONTRIBUTING.md) file! ## Credits diff --git a/main.py b/main.py index daffb8b..635ad3b 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,29 @@ -# https://github.com/andrewkdinh/fund-indicators -# Determine indicators of overperforming mutual funds -# Andrew Dinh -# Python 3.6.7 +''' + __ _ _ _ _ _ + / _| | | (_) | (_) | | +| |_ _ _ _ __ __| | ______ _ _ __ __| |_ ___ __ _| |_ ___ _ __ ___ +| _| | | | '_ \ / _` | |______| | | '_ \ / _` | |/ __/ _` | __/ _ \| '__/ __| +| | | |_| | | | | (_| | | | | | | (_| | | (_| (_| | || (_) | | \__ \ +|_| \__,_|_| |_|\__,_| |_|_| |_|\__,_|_|\___\__,_|\__\___/|_| |___/ + +Project homepage: https://github.com/andrewkdinh/fund-indicators +Author: Andrew Dinh + +Copyright (C) 2019 Andrew Dinh + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +''' # PYTHON FILES import Functions @@ -551,17 +573,24 @@ class Stock: plt.ylabel('Close Values') # function to show plot - plt.show(block=False) - for i in range(3, 0, -1): - if i == 1: - sys.stdout.write('Keeping plot open for ' + - str(i) + ' second \r') - else: - sys.stdout.write('Keeping plot open for ' + - str(i) + ' seconds \r') - plt.pause(1) + try: + t = Stock.timePlotIndicatorRegression + plt.show(block=False) + for i in range(t, 0, -1): + if i == 1: + sys.stdout.write('Keeping plot open for ' + + str(i) + ' second \r') + else: + sys.stdout.write('Keeping plot open for ' + + str(i) + ' seconds \r') + plt.pause(1) + sys.stdout.flush() + sys.stdout.write(' \r') + sys.stdout.flush() + plt.close() + except: + sys.stdout.write(' \r') sys.stdout.flush() - plt.close() def scrapeYahooFinance(self): # Determine if ETF, Mutual fund, or stock @@ -1394,21 +1423,24 @@ def plot_regression_line(x, y, b, i): plt.ylabel(listOfReturnStrings[i]) # function to show plot - t = Stock.timePlotIndicatorRegression - plt.show(block=False) - for i in range(t, 0, -1): - if i == 1: - sys.stdout.write('Keeping plot open for ' + - str(i) + ' second \r') - else: - sys.stdout.write('Keeping plot open for ' + - str(i) + ' seconds \r') - plt.pause(1) + try: + t = Stock.timePlotIndicatorRegression + plt.show(block=False) + for i in range(t, 0, -1): + if i == 1: + sys.stdout.write('Keeping plot open for ' + + str(i) + ' second \r') + else: + sys.stdout.write('Keeping plot open for ' + + str(i) + ' seconds \r') + plt.pause(1) + sys.stdout.flush() + sys.stdout.write(' \r') + sys.stdout.flush() + plt.close() + except: + sys.stdout.write(' \r') sys.stdout.flush() - sys.stdout.write( - ' \r') - sys.stdout.flush() - plt.close() def persistenceTimeFrame(): @@ -1612,7 +1644,6 @@ def main(): runningProgram = True while runningProgram is True: - if Stock.config == 'N/A': # Check that all required packages are installed packagesInstalled = Functions.checkPackages( @@ -1739,20 +1770,3 @@ def main(): if __name__ == "__main__": main() - -''' -Copyright (C) 2019 Andrew Dinh - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -'''