DataLoader

class crypto_env.dataloader.DataLoader(start_idx, end_idx)[source]

Bases: abc.ABC

The DataLoader module is for user to map arbitrary data source to form that the environment can recognize.

abstract __init__(start_idx, end_idx)[source]
Parameters
  • start_idx (int) – Start index

  • end_idx (int) – End index

__iter__()[source]

This object is iterable. See https://www.w3schools.com/python/python_iterators.asp for more details.

abstract __len__()[source]

Return the length of the iterable

Raises

NotImplementedError

abstract __next__()[source]

See https://www.w3schools.com/python/python_iterators.asp for more details

abstract get_duration()[source]

Get length of the data source.

Raises

NotImplementedError

abstract get_feature(feature_name)[source]

Get input variables (features)

Parameters

feature_name (str) – name of the feature

Raises

NotImplementedError

get_idx()[source]

Get current index

Raises

NotImplementedError

get_transaction_fee(idx=None)[source]

Return the transaction fee list

Parameters

idx (int, optional) – Number of transaction fee to return. Defaults to None.

Returns

list

get_transaction_fee_type()[source]

Return the name of transaction fee type

Returns

str

property idx
load_transaction_fee(values, fee_type='percentage')[source]

Load the transaction fee list

Parameters
  • values (list) – Transaction fee list

  • fee_type (str, optional) – ‘percentage’ or ‘fix’. Defaults to ‘percentage’.

abstract reset()[source]

Reset the dataloader

Raises

NotImplementedError

class crypto_env.dataloader.ETHLoader(base_dir, start_idx, end_idx, features: list, dropna=False, download=True, url='https://raw.githubusercontent.com/coinmetrics/data/master/csv/eth.csv')[source]

Bases: crypto_env.dataloader.dataloader.DataLoader

Our example implementation of DataLoader class. We use the Ethereum history data from the coinmetrics repo. See https://raw.githubusercontent.com/coinmetrics/data for more details.

__init__(base_dir, start_idx, end_idx, features: list, dropna=False, download=True, url='https://raw.githubusercontent.com/coinmetrics/data/master/csv/eth.csv')[source]
Parameters
  • base_dir (str) – Directory to save the download data

  • start_idx (int) – Where to start in the data source

  • end_idx (int) – Where to end in the data source

  • features (list) – Input variables for the environment

  • dropna (bool, optional) – Whether to drop lines including empty values. Defaults to False.

  • download (bool, optional) – Whether to re-download the data. Defaults to True.

  • url (str, optional) – Link to the data source. Defaults to “https://raw.githubusercontent.com/coinmetrics/data/master/csv/eth.csv”.

__len__()[source]

Number of items

Returns

int

get_duration()[source]

Get length of the data source.

Raises

NotImplementedError

get_feature(feature_name)[source]

Get input variables (features)

Parameters

feature_name (str) – name of the feature

Raises

NotImplementedError

get_idx()[source]

Get current index

Raises

NotImplementedError

reset()[source]

Reset the dataloader

Raises

NotImplementedError