@@ -107,14 +107,24 @@ def loadData(self, dataPath, datetimeFormat, separator):
107
107
108
108
# Python contains
109
109
if not dataPath in self .dataframes :
110
- self .dataframes [fileName ] = pd .read_csv (dataPath ,
111
- sep = separator ,
112
- parse_dates = [0 ],
113
- date_parser = lambda x : pd .to_datetime (x , format = datetimeFormat ),
114
- skiprows = 0 ,
115
- header = 0 ,
116
- names = ["Time" , "Open" , "High" , "Low" , "Close" , "Volume" ],
117
- index_col = 0 )
110
+ if pd .__version__ == '1.4.3' :
111
+ self .dataframes [fileName ] = pd .read_csv (dataPath ,
112
+ sep = separator ,
113
+ parse_dates = [0 ],
114
+ date_parser = lambda x : pd .to_datetime (x , format = datetimeFormat ),
115
+ skiprows = 0 ,
116
+ header = 0 ,
117
+ names = ["Time" , "Open" , "High" , "Low" , "Close" , "Volume" ],
118
+ index_col = 0 )
119
+ else :
120
+ self .dataframes [fileName ] = pd .read_csv (dataPath ,
121
+ sep = separator ,
122
+ parse_dates = [0 ],
123
+ date_format = datetimeFormat ,
124
+ skiprows = 0 ,
125
+ header = 0 ,
126
+ names = ["Time" , "Open" , "High" , "Low" , "Close" , "Volume" ],
127
+ index_col = 0 )
118
128
119
129
except ValueError as err :
120
130
return False , "ValueError error:" + str (err )
@@ -177,21 +187,21 @@ def findTimeFrame(self, df):
177
187
if len (df .index ) > 2 :
178
188
dtDiff = df .index [1 ] - df .index [0 ]
179
189
180
- if dtDiff .seconds == 60 :
190
+ if dtDiff .total_seconds () == 60 :
181
191
return "M1"
182
- elif dtDiff .seconds == 300 :
192
+ elif dtDiff .total_seconds () == 300 :
183
193
return "M5"
184
- elif dtDiff .seconds == 900 :
194
+ elif dtDiff .total_seconds () == 900 :
185
195
return "M15"
186
- elif dtDiff .seconds == 1800 :
196
+ elif dtDiff .total_seconds () == 1800 :
187
197
return "M30"
188
- elif dtDiff .seconds == 3600 :
198
+ elif dtDiff .total_seconds () == 3600 :
189
199
return "H1"
190
- elif dtDiff .seconds == 14400 :
200
+ elif dtDiff .total_seconds () == 14400 :
191
201
return "H4"
192
- elif dtDiff .seconds == 86400 :
202
+ elif dtDiff .total_seconds () == 86400 :
193
203
return "D"
194
- elif dtDiff .seconds == 604800 :
204
+ elif dtDiff .total_seconds () == 604800 :
195
205
return "W"
196
206
197
207
pass
0 commit comments