Hello,

I'd like to read this file
http://www.dukascopy.com/datafeed/EURUSD/2016/02/14/20h_ticks.bi5
using Julia.

It's a LZMA compressed file.

I can decompressed it using
cp 20h_ticks.bi5 20h_ticks.xz
xz --decompress --format=lzma 20h_ticks.xz

Now, I have a 20h_ticks binary file.

It's a stuctured binary file with array of records 
  Date unsigned integer 4 bytes
  Ask  unsigned integer 4 bytes
  Bid  unsigned integer 4 bytes
  AskVolume float 4 bytes
  BidVolume float 4 bytes


Using Python I'm able to read it and get a Pandas DataFrame

import numpy as np
import pandas as pd
import datetime
symb = "EURUSD"
dt_chunk = datetime.datetime(2016, 2, 14)
record_dtype = np.dtype([
    ('Date', '>u4'),
    ('Ask', '>u4'),
    ('Bid', '>u4'),
    ('AskVolume', '>f4'),
    ('BidVolume', '>f4'),
])

data = np.fromfile("20h_ticks", dtype=record_dtype)
columns = ["Date", "Ask", "Bid", "AskVolume", "BidVolume"]
df = pd.DataFrame(data, columns=columns)
if symb[3:] == "JPY":
    p_digits = 3
else:
    p_digits = 5
for p in ["Ask", "Bid"]:
    df[p] = df[p] / 10**p_digits
df["Date"] = dt_chunk + pd.to_timedelta(df["Date"], unit="ms")
df = df.set_index("Date")

I'd like to do the same using Julia

I did

symb = "EURUSD"
day_chunk = Date(2016, 2, 14)
h_chunk = 20
dt_chunk = DateTime(day_chunk) + Base.Dates.Hour(h_chunk)
filename = @sprintf "%02dh_ticks" h_chunk
println(filename)

immutable TickRecordType
  Date::UInt32
  Ask::UInt32
  Bid::UInt32
  AskVolume::Float32
  BidVolume::Float32
end

f = open(filename)

# ...

close(f)

but I'm blocked now ...

Any help will be great.

Kind regards

Reply via email to