Fix data

In some data providers there could be holes in the data. For various reasons somes dates could be missing in your data. For exemple what can you do if your data looks like :

data

date

open

high

low

close

volume

2015-01-08

11.01

10.81

11.30

10.75

1433300

2015-01-09

10.96

10.98

11.18

10.72

18536300

2015-01-12

11.06

11.32

11.42

10.88

31410200

2015-01-13

11.47

10.68

11.48

10.52

27751100

The module FillPolicy helps you to fill the missing dates. By default if you don’t choose a fill policy, if hmile detects missing dates it will raises a NoFillPolicySet exception.

FillPolicyAkima

class hmile.FillPolicy.FillPolicyAkima(interval)

Fill policy that use akima interpolation to fill missing dates

Example :

from hmile.FillPolicy import FillPolicyAkima
from hmile.DataProvider import CSVDataProvider

# Create a data provider
data_provider = CSVDataProvider([PAIR], START, END, DATA_DIR, interval=INTERVAL)
# We set the fill policy
data_provider.fill_policy = FillPolicyAkima(INTERVAL)
# We get the data, the fill policy will be applied automatically
data = fill_policy.get_data()

Remark :

The FillPolicyAkima class is based on the Akima interpolation method. So missing data will be generated from a statistical method.

FillPolicyClip

class hmile.FillPolicy.FillPolicyClip(interval)

Fill policy that juste ignore missing dates

Example :

from hmile.FillPolicy import FillPolicyClip
from hmile.DataProvider import CSVDataProvider

# Create a data provider
data_provider = CSVDataProvider([PAIR], START, END, DATA_DIR, interval=INTERVAL)
# We set the fill policy
data_provider.fill_policy = FillPolicyClip(INTERVAL)
# We get the data, the fill policy will be applied automatically
data = fill_policy.get_data()

Remark : This method will just ignore if there is missing data.

FillPolicyError

Example :

from hmile.FillPolicy import FillPolicyError
from hmile.DataProvider import CSVDataProvider

# Create a data provider
data_provider = CSVDataProvider([PAIR], START, END, DATA_DIR, interval=INTERVAL)
# We set the fill policy
data_provider.fill_policy = FillPolicyError(INTERVAL)
# We get the data, the fill policy will be applied automatically
data = fill_policy.get_data()

Remark : If there is missing data, this fill policy will raised an exception. This is the default fill policy.