@@ -135,46 +135,49 @@ def timeFrame(datapath):
135
135
"""
136
136
Select the write compression and timeframe.
137
137
"""
138
- if datapath [- 8 :- 4 ] == '1mth' :
138
+ sepdatapath = datapath [5 :- 4 ].split (sep = '-' ) # ignore name file 'data/' and '.csv'
139
+ tf = sepdatapath [3 ]
140
+
141
+ if tf == '1mth' :
139
142
compression = 1
140
143
timeframe = bt .TimeFrame .Months
141
- elif datapath [ - 7 : - 4 ] == '12h' :
144
+ elif tf == '12h' :
142
145
compression = 720
143
146
timeframe = bt .TimeFrame .Minutes
144
- elif datapath [ - 7 : - 4 ] == '15m' :
147
+ elif tf == '15m' :
145
148
compression = 15
146
149
timeframe = bt .TimeFrame .Minutes
147
- elif datapath [ - 7 : - 4 ] == '30m' :
150
+ elif tf == '30m' :
148
151
compression = 30
149
152
timeframe = bt .TimeFrame .Minutes
150
- elif datapath [ - 6 : - 4 ] == '1d' :
153
+ elif tf == '1d' :
151
154
compression = 1
152
155
timeframe = bt .TimeFrame .Days
153
- elif datapath [ - 6 : - 4 ] == '1h' :
156
+ elif tf == '1h' :
154
157
compression = 60
155
158
timeframe = bt .TimeFrame .Minutes
156
- elif datapath [ - 6 : - 4 ] == '3m' :
159
+ elif tf == '3m' :
157
160
compression = 3
158
161
timeframe = bt .TimeFrame .Minutes
159
- elif datapath [ - 6 : - 4 ] == '2h' :
162
+ elif tf == '2h' :
160
163
compression = 120
161
164
timeframe = bt .TimeFrame .Minutes
162
- elif datapath [ - 6 : - 4 ] == '3d' :
165
+ elif tf == '3d' :
163
166
compression = 3
164
167
timeframe = bt .TimeFrame .Days
165
- elif datapath [ - 6 : - 4 ] == '1w' :
168
+ elif tf == '1w' :
166
169
compression = 1
167
170
timeframe = bt .TimeFrame .Weeks
168
- elif datapath [ - 6 : - 4 ] == '4h' :
171
+ elif tf == '4h' :
169
172
compression = 240
170
173
timeframe = bt .TimeFrame .Minutes
171
- elif datapath [ - 6 : - 4 ] == '5m' :
174
+ elif tf == '5m' :
172
175
compression = 5
173
176
timeframe = bt .TimeFrame .Minutes
174
- elif datapath [ - 6 : - 4 ] == '6h' :
177
+ elif tf == '6h' :
175
178
compression = 360
176
179
timeframe = bt .TimeFrame .Minutes
177
- elif datapath [ - 6 : - 4 ] == '8h' :
180
+ elif tf == '8h' :
178
181
compression = 480
179
182
timeframe = bt .TimeFrame .Minutes
180
183
else :
0 commit comments