File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 77
77
# #############################################################################
78
78
# Retrieve the data from Internet
79
79
80
+ def retry (f , n_retry = 3 ):
81
+ """Define wrapper function to retry function calls in case of Exceptions
80
82
83
+ Parameters
84
+ -----------
85
+ f: function
86
+ Function that will be wrapped
87
+ n_retry: int
88
+ Number of retries of function call
89
+
90
+ Returns
91
+ -------
92
+ f : function
93
+ Wrapped input function
94
+
95
+ """
96
+ def wrapper (* args , ** kwargs ):
97
+ exception = None
98
+ for i in range (n_retry ):
99
+ try :
100
+ return f (* args , ** kwargs )
101
+ except Exception as e :
102
+ exception = e
103
+ raise exception
104
+ return wrapper
105
+
106
+
107
+ @retry
81
108
def quotes_historical_google (symbol , date1 , date2 ):
82
109
"""Get the historical data from Google finance.
83
110
You can’t perform that action at this time.
0 commit comments