18 lines
788 B
Python
18 lines
788 B
Python
|
import pandas as pd
|
||
|
|
||
|
def convert_tick_data(input_file, output_file):
|
||
|
df = pd.read_csv(input_file, skipinitialspace = True)
|
||
|
|
||
|
df['Datetime'] = pd.to_datetime(df['Date'] + ' ' + df['Time'], format = '%Y/%m/%d %H:%M:%S.%f', errors = 'coerce')
|
||
|
df = df.dropna(subset = ['Datetime'])
|
||
|
df['FormattedDatetime'] = df['Datetime'].dt.strftime('%Y%m%d %H%M%S %f')
|
||
|
|
||
|
nt_df = df[['FormattedDatetime', 'Last', 'Volume']]
|
||
|
nt_df.columns = ['Datetime', 'Price', 'Volume']
|
||
|
nt_df.to_csv(output_file, index = False, sep = ';', header = False)
|
||
|
|
||
|
print(f"Tick data conversion complete. The output file has been saved as {output_file}")
|
||
|
|
||
|
sierra_chart_export = 'C:\\SierraChart\\Data\\NQZ20-CME.txt'
|
||
|
output_file = 'NQ 12-20.Last.txt'
|
||
|
convert_tick_data(sierra_chart_export, output_file)
|