Recorder

class crypto_env.recorder.Recorder(price_list, crypto_cap=0, fiat_cap=1000)[source]

Bases: object

This is the recorder class. A recorder object is able to record agent’s action in both training and production mod. The data collected can later be used for plotting or analyzing.

__init__(price_list, crypto_cap=0, fiat_cap=1000) None[source]
Parameters
  • price_list (list) – a list of price, the length should be equal to the size of the DataLoader.

  • crypto_cap (int, optional) – initial balance of crypto. Defaults to 0.

  • fiat_cap (int, optional) – initial balance of fiat. Defaults to 1000.

get_crypto_balance(idx=None)[source]

Calculate cryptocurrency balance

Parameters

idx (int, optional) – How many transactions to involve. Defaults to None.

Returns

_description_

Return type

_type_

get_crypto_value(idx=None)[source]

Calculate the value of crypto in balance

Parameters

idx (int, optional) – How many transactions to involve. Defaults to None.

Returns

float

get_expenditure(idx=None)[source]

Calculate how many fiat was used in the investment.

Parameters

idx (int, optional) – Number of transactions to involve. Defaults to None.

Returns

float

get_fiat_balance(idx=None)[source]

Calculate fiat balance

Parameters

idx (int, optional) – How many transactions to involve. Defaults to None.

Returns

float

get_income(idx=None)[source]

Calculate how many value does the agent earn.

Parameters

idx (int, optional) – How many transactions to involve. Defaults to None.

Returns

float

get_info_record(to_dataframe=True)[source]

Return all history market info

Parameters

to_dataframe (bool, optional) – Whether to convert to dataframe. Defaults to True.

Returns

Market information history

Return type

(DataFrame, any)

get_roi(idx=None)[source]

Calculate the return of investment

Parameters

idx (int, optional) – How many transactions to involve. Defaults to None.

Returns

float

get_transaction_record(idx=None)[source]

Return all history buy and sell signals generated by the agent

Parameters

idx (int, optional) – Number of records to print. Defaults to None.

Returns

A pandas.DataFrame containing all history signals.

Return type

DataFrame

insert_info(info)[source]

Insert market information into the record

Parameters

info (array-like) – an array of current market info

insert_transaction(transaction: crypto_env.types.Transaction)[source]

Insert new transaction into the recorder

Parameters

transaction (Transaction) – Transaction object to insert

reset()[source]

Reset the recorder