Uncategorised

Code Snippet on how to import time series into R

This is a code snippet on how to import Multicharts data into R for analysis. The CSV-File is exported from Multicharts Quote Manager in an ASCII format.

 

# Import xts package
library(xts)
# Load data file
data <- read.csv("EURUSD1M.csv", stringsAsFactors = F)
# Rename columns
colnames(data) <- c("Date", "Time", "Open", "High", "Low", "Close", "Vol")
# Combine date and time in one column and change format
data$Date <- as.POSIXct(paste(data$Date, data$Time), format="%d.%m.%Y %H:%M:%S")
# Change to xts format
data <- as.xts(x = data[3:6], order.by = data$Date, dateFormat = "%d.%m.%Y %H:%M:%S")
# Print summary of data
summary(data)

Feel free to do anything with the data you just imported.

 

 

Disclaimer:

This content is purely informative in nature and does not constitute any offer, inducement, recommendation, or legal or financial advice by the author. In particular, the published information is not to be understood to be an offer of sale of any registered or unregistered securities or an investment proposal of any kind. It is general information provided purely for information purposes and is based on proprietary knowledge, information furnished by third parties, and publicly accessible sources considered reliable by the author.

Leave a Reply

Your email address will not be published. Required fields are marked *