1212 python calculate_technical_indicators.py
1313
1414Input:
15- - CSV file with columns: UNIX_TIMESTAMP, DATETIME, OPEN, HIGH, CLOSE, LOW, VOLUME
15+ - CSV file with columns: UNIX_TIMESTAMP, DATETIME, OPEN, HIGH, CLOSE, LOW, VOLUME (or VOLUME_USD)
1616
1717Output:
1818 - CSV file with OHLCV + 90+ technical indicators
2424
2525
2626def load_ohlcv_data (filepath = 'bitcoin-hourly-ohlcv.csv' ):
27- """
28- Load OHLCV data from CSV file
29-
30- Args:
31- filepath: Path to CSV file with OHLCV data
32-
33- Returns:
34- pandas DataFrame with OHLCV data
35- """
27+ # Load OHLCV data from CSV file
28+
3629 print (f"📥 Loading data from { filepath } ..." )
3730 df = pd .read_csv (filepath )
3831
@@ -45,15 +38,8 @@ def load_ohlcv_data(filepath='bitcoin-hourly-ohlcv.csv'):
4538
4639
4740def calculate_technical_indicators (df ):
48- """
49- Calculate comprehensive technical indicators using TA-Lib
50-
51- Args:
52- df: DataFrame with OHLCV data (columns: OPEN, HIGH, CLOSE, LOW, VOLUME)
53-
54- Returns:
55- DataFrame with all original columns + technical indicators
56- """
41+ # Calculate comprehensive technical indicators using TA-Lib
42+
5743 print ("🔧 Calculating comprehensive technical indicators using TA-Lib..." )
5844
5945 # Convert to numpy arrays for TA-Lib
@@ -252,27 +238,13 @@ def calculate_technical_indicators(df):
252238
253239
254240def save_to_csv (df , filepath = 'bitcoin-hourly-technical-indicators.csv' ):
255- """
256- Save DataFrame to CSV file
257-
258- Args:
259- df: DataFrame to save
260- filepath: Output file path
261- """
241+ # Save DataFrame to CSV file
262242 print (f"💾 Saving to { filepath } ..." )
263243 df .to_csv (filepath , index = False , float_format = '%.8f' )
264244 print (f"✅ Saved { len (df ):,} records to { filepath } " )
265245
266246
267- def main ():
268- """
269- Main function to run the technical indicators calculation
270- """
271- print ("=" * 60 )
272- print ("Bitcoin Technical Indicators Calculator" )
273- print ("=" * 60 )
274- print ()
275-
247+ def main ():
276248 # Step 1: Load OHLCV data
277249 df = load_ohlcv_data ('bitcoin-hourly-ohlcv.csv' )
278250 print ()
@@ -284,20 +256,6 @@ def main():
284256 # Step 3: Save to CSV
285257 save_to_csv (df_with_indicators , 'bitcoin-hourly-technical-indicators.csv' )
286258 print ()
287-
288- print ("=" * 60 )
289- print ("✅ Process Complete!" )
290- print ("=" * 60 )
291- print ()
292- print ("📁 Output Files:" )
293- print (" • bitcoin-hourly-technical-indicators.csv" )
294- print ()
295- print ("📊 Summary:" )
296- print (f" • Total Records: { len (df_with_indicators ):,} " )
297- print (f" • Total Columns: { len (df_with_indicators .columns )} " )
298- print (f" • OHLCV Columns: 7" )
299- print (f" • Technical Indicators: { len (df_with_indicators .columns ) - 7 } " )
300- print ()
301259
302260
303261if __name__ == "__main__" :
0 commit comments