The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Finance::Contract - represents a contract object for a single bet

VERSION

version 0.001

SYNOPSIS

use feature qw(say);
use Finance::Contract;
# Create a simple contract
my $contract = Finance::Contract->new(
    contract_type => 'CALLE',
    duration      => '5t',
);

DESCRIPTION

This is a generic abstraction for financial stock market contracts.

Construction

Finance::Contract->new({
    underlying    => 'frxUSDJPY',
    contract_type => 'CALL',
    date_start    => $now,
    duration      => '5t',
    currency      => 'USD',
    payout        => 100,
    barrier       => 100,
});

Dates

All date-related parameters:

are Date::Utility instances. You can provide them as epoch values or Date::Utility objects.

ATTRIBUTES

These are the parameters we expect to be passed when constructing a new contract.

bet_type

(required) The type of this contract as an upper-case string.

Current types include:

currency

(required) The currency of the payout for this contract, e.g. USD.

date_expiry

(optional) When the contract expires.

One of date_expiry or "duration" must be provided.

date_pricing

(optional) The date at which we're pricing the contract. Provide undef to indicate "now".

date_start

For American contracts, defines when the contract starts.

For Europeans, this is used to determine the barrier when the requested barrier is relative.

duration

(optional) The requested contract duration, specified as a string indicating value with units. The unit is provided as a single character suffix:

Examples would be 5t for 5 ticks, 3h for 3 hours.

One of "date_expiry" or duration must be provided.

is_forward_starting

True if this contract is considered as forward-starting at "date_pricing".

payout

Payout amount value, see "currency". Optional - only applies to binaries.

prediction

Prediction (for tick trades) is what client predicted would happen.

starts_as_forward_starting

This attribute tells us if this contract was initially bought as a forward starting contract. This should not be mistaken for "is_forward_starting" attribute as that could change over time.

pip_size

Barrier pip size the minimum fluctuation amount for type of market. It is normally fraction.

absolute_barrier_multiplier

True if barrier multiplier should be applied for absolute barrier(s) on this market

supplied_barrier_type

One of:

supplied_high_barrier

For a 2-barrier contract, this is the high barrier string. The meaning of these barrier values is controlled by "supplied_barrier_type".

supplied_low_barrier

For a 2-barrier contract, this is the low barrier string.

supplied_barrier

For a single-barrier contract, this is the barrier string.

tick_count

Number of ticks in this trade.

underlying_symbol

The underlying asset, as a string (for example, frxUSDJPY).

ATTRIBUTES - From contract_types.yml

id

A unique numeric ID.

pricing_code

Used to determine the pricing engine that should be used for this contract. Examples include 'PUT' or 'CALL'.

display_name

This is a human-readable name for the contract type, brief description of what it does.

sentiment

Indicates whether we are speculating on market rise or fall.

other_side_code

Opposite type for this contract - PUT for CALL, etc.

payout_type

Either binary or non-binary.

payouttime

Indicates when the contract pays out. Can be end or hit.

ATTRIBUTES - From contract_categories.yml

allow_forward_starting

True if we allow forward starting for this contract type.

barrier_at_start

Boolean which will false if we don't know what the barrier is at the start of the contract (Asian contracts).

category_code

The code for this category.

is_path_dependent

True if this is a path-dependent contract.

supported_expiries

Which expiry durations we allow for this category. Values can be:

two_barriers

True if the contract has two barriers.

METHODS

barrier_category

Type of barriers we have for this contract, depends on the contract type.

Possible values are:

effective_start

fixed_expiry

A Boolean to determine if this bet has fixed or flexible expiries.

get_time_to_expiry

Returns a TimeInterval to expiry of the bet. For a forward start bet, it will NOT return the bet lifetime, but the time till the bet expires.

If you want to get the contract life time, use:

$contract->get_time_to_expiry({from => $contract->date_start})

is_after_expiry

Returns true if the contract is already past the expiry time.

is_atm_bet

Is this contract meant to be ATM or non ATM at start? The status will not change throughout the lifetime of the contract due to differences in offerings for ATM and non ATM contracts.

shortcode

This is a compact string representation of a Finance::Contract object. It includes all data needed to reconstruct a contract, with the exception of "currency".

tick_expiry

A boolean that indicates if a contract expires after a pre-specified number of ticks.

timeinyears

Contract duration in years.

timeindays

Contract duration in days.

NAME

Finance::Contract::Category

SYNOPSYS

my $contract_category = Finance::Contract::Category->new("callput");

DESCRIPTION

This class represents available contract categories.

ATTRIBUTES

get_all_contract_types

Returns a list of all loaded contract types

get_all_barrier_categories

Returns a list of all available barrier categories

get_all_contract_categories

Returns a list of all loaded contract categories

code

Our internal code (callput, touchnotouch, ...)

display_name

What is the name of this bet as an action?

display_order

In which order should these be preferred for display in a UI?

explanation

How do we explain this contract category to a client?

METHODS

barrier_at_start

When is the barrier determined, at the start of the contract or after contract expiry.

AUTHOR

RMG Tech (Malaysia) Sdn Bhd

LICENSE AND COPYRIGHT

Copyright 2013- RMG Technology (M) Sdn Bhd