Finance::Contract - represents a contract object for a single bet
version 0.001
use feature qw(say);
use Finance::Contract;
# Create a simple contract
my $contract = Finance::Contract->new(
contract_type => 'CALLE',
duration => '5t',
);
This is a generic abstraction for financial stock market contracts.
Finance::Contract->new({
underlying => 'frxUSDJPY',
contract_type => 'CALL',
date_start => $now,
duration => '5t',
currency => 'USD',
payout => 100,
barrier => 100,
});
All date-related parameters:
are Date::Utility instances. You can provide them as epoch values or Date::Utility objects.
These are the parameters we expect to be passed when constructing a new contract.
(required) The type of this contract as an upper-case string.
Current types include:
- ASIAND
- ASIANU
- CALL
- CALLE
- DIGITDIFF
- DIGITEVEN
- DIGITMATCH
- DIGITODD
- DIGITOVER
- DIGITUNDER
- EXPIRYMISS
- EXPIRYMISSE
- EXPIRYRANGE
- EXPIRYRANGEE
- NOTOUCH
- ONETOUCH
- PUT
- PUTE
- RANGE
- UPORDOWN
(required) The currency of the payout for this contract, e.g. USD
.
(optional) When the contract expires.
One of date_expiry
or "duration" must be provided.
(optional) The date at which we're pricing the contract. Provide undef
to indicate "now".
For American contracts, defines when the contract starts.
For Europeans, this is used to determine the barrier when the requested barrier is relative.
(optional) The requested contract duration, specified as a string indicating value with units. The unit is provided as a single character suffix:
- t - ticks
- s - seconds
- m - minutes
- h - hours
- d - days
Examples would be 5t
for 5 ticks, 3h
for 3 hours.
One of "date_expiry" or duration
must be provided.
True if this contract is considered as forward-starting at "date_pricing".
Payout amount value, see "currency". Optional - only applies to binaries.
Prediction (for tick trades) is what client predicted would happen.
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.
Barrier pip size the minimum fluctuation amount for type of market. It is normally fraction.
One of:
relative
- this is of the formS10P
orS-4P
, which would be 10 pips above the spot or 4 pips below the spot.absolute
- this is a number that can be compared directly with the spot, e.g.103.45
.difference
- a numerical difference from the spot, can be negative, e.g.-0.035
.
For a 2-barrier contract, this is the high barrier string. The meaning of these barrier values is controlled by "supplied_barrier_type".
For a 2-barrier contract, this is the low barrier string.
For a single-barrier contract, this is the barrier string.
Number of ticks in this trade.
The underlying asset, as a string (for example, frxUSDJPY
).
A unique numeric ID.
Used to determine the pricing engine that should be used for this contract. Examples include 'PUT' or 'CALL'.
This is a human-readable name for the contract type, brief description of what it does.
Indicates whether we are speculating on market rise or fall.
Opposite type for this contract - PUT for CALL, etc.
Either binary
or non-binary
.
Indicates when the contract pays out. Can be end
or hit
.
True if we allow forward starting for this contract type.
Boolean which will false if we don't know what the barrier is at the start of the contract (Asian contracts).
The code for this category.
True if this is a path-dependent contract.
Which expiry durations we allow for this category. Values can be:
- intraday
- daily
- tick
True if the contract has two barriers.
Type of barriers we have for this contract, depends on the contract type.
Possible values are:
american
- barrier for American-style contractasian
- Asian-style contracteuro_atm
- at-the-money European contracteuro_non_atm
- non-at-the-money European contractnon_financial
- digits
- For backpricing, this is "date_start".
- For a forward-starting contract, this is "date_start".
- For all other states - i.e. active, non-expired contracts - this is "date_pricing".
A Boolean to determine if this bet has fixed or flexible expiries.
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})
Returns true if the contract is already past the expiry time.
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.
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".
A boolean that indicates if a contract expires after a pre-specified number of ticks.
Contract duration in years.
Contract duration in days.