NAME

Quant::Framework::Document - Binds data with Chronicle

DESCRIPTION

Internal representation of persistend data. Do not create the class directly outside of Quant::Framework, although the usage of public fields outside of Quant::Framework is allowed.

The class is responsible for loading and storing data via Data::Chronicle. The data itself is a hash, which content is provided by users of the class (i.e. by CorporateActions).

# create new (transient / not-yet-persisted) Document

my $document = Quant::Framework::Document->new(
 storage_accessor => $storage_accessor,
 symbol           => 'frxUSDJPY',
 data             => {},
 for_date         => Date::Utility->new,
);

# persist document
$document->save('currency');

# load document
my $document2 = Quant::Framework::Document::load(
 $storage_accessor,
 'currency',
 'frxUSDJPY',
 Date::Utility->new, # optional
)

ATTRIBUTES

storage_accessor

Chronicle assessor

recorded_date

The date of document creation (Date::Utility)

data

Hashref of data. Should be defined by the class, which uses Document. Currently the fields date and symbol are reserved.

namespace

The required namespace of document, e.g. 'corporate_actions'

symbol

The domain-specific name of document; e.g. "USAAPL" for corporate actions

SUBROUTINES

load($storage_accessor, $namespace, $symbol, $for_date)

my $recent_document = Quant::Framework::Document::load($storage_accessor, 'corporate_actions', "USAAPL");

my $event_date = Date::Utility->new('02-02-2016')
my $historical_doc = Quant::Framework::Document::load($storage_accessor, 'corporate_actions', "USAAPL", $event_date);

Loads the document. If the argument for_date is ommitted, then loads the most recent document.

If document is not found, returns undef.

save

$document->save;

Stores (persists) the document in Chronicle database.