Convert Dukascopy free historical data to Ctrader format using python full code

Created at 21 Mar 2020, 01:26
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
paolo.panicali's avatar

paolo.panicali

Joined 16.12.2018

Convert Dukascopy free historical data to Ctrader format using python full code
21 Mar 2020, 01:26


Hi, I converted some free historical data downloaded from ducascopy for free to a format compatible with ctrader...they sell an utility for 25 pounds , no way...

it works with 1hour timeframe, dunno with others

 

# -*- coding: utf-8 -*-

"""

Created on Sun Jul  7 20:19:04 2019

Dukascopy to Ctrader 

@author: Paolo Panicali

"""

import pandas as pd

import seaborn as sns

#carica dati dal file in df

path_load='C:\\Users\\Paolo\\Documents\\Python_EURUSD_bar//EURGBP_dukascopy.csv'

path_save='C:\\Users\\Paolo\\Documents\\Python_EURUSD_bar//EURGBP_CTRADER.csv'

df = pd.read_csv(path_load,sep=",",decimal=",", engine='python')

#elimina le rows del finesettimana dove il volume è zero optional

#df = df[df.Volume != 0]

#rinomna la prima colonna come Date

df = df.rename(columns={'Gmt time': 'Date'})

#duplica la colonna datetime e la inserisce nella posizione 2

time=df['Date']

df.insert(loc=1, column='Time', value=time)

#df['Date'] = pd.to_datetime(df['Date'],dayfirst=True).dt.date

df['Date'] = pd.to_datetime(df['Date'],dayfirst=True).dt.strftime('%Y.%m.%d')

df['Time'] = pd.to_datetime(df['Time']).dt.strftime('%H:%M')

# df['Volume']=1  this is optional

#mantiene solo 5 digiti di decimale

df.round(5) 

#seleziona indice combinato data e time

#df2.set_index('Date','Time')

df.to_csv(path_save,index=False,header=False,float_format='%.5f')

#mostra graficamente il risultato dei close ordinati di tutta la serie

sns.set(rc={'figure.figsize':(11, 4)})

x=df["Close"]

x.plot(linewidth=0.7);

 

 

 

 

 

                              


@paolo.panicali