Finance-Alpaca
view release on metacpan or search on metacpan
lib/Finance/Alpaca/Struct/TradeUpdate.pm view on Meta::CPAN
package Finance::Alpaca::Struct::TradeUpdate 0.9904 {
use strictures 2;
use feature 'signatures';
no warnings 'experimental::signatures';
#
use Type::Library 0.008 -base, -declare => qw[TradeUpdate];
use Type::Utils;
use Types::Standard qw[Enum Num Ref Str];
use Types::TypeTiny 0.004 StringLike => { -as => "Stringable" };
class_type TradeUpdate, { class => __PACKAGE__ };
coerce( TradeUpdate, from Ref() => __PACKAGE__ . q[->new($_)] );
#
use Moo;
use Types::UUID;
use lib './lib';
use Finance::Alpaca::Types;
use Finance::Alpaca::Struct::Order qw[Order];
has event => (
is => 'ro',
isa => Enum [
qw[
new fill partial_fill canceled expired done_for_day replaced
rejected pending_new stopped pending_cancel pending_replace
calculated suspended
order_replace_rejected order_cancel_rejected]
],
required => 1
);
has order => ( is => 'ro', isa => Order, required => 1, coerce => 1 );
has timestamp => ( is => 'ro', isa => Timestamp, predicate => 1, coerce => 1 );
has [qw[position_qty price qty]] => ( is => 'ro', isa => Num, predicate => 1 );
}
1;
__END__
=encoding utf-8
=head1 NAME
Finance::Alpaca::Struct::TradeUpdate - A Single Streamed Data Object
=head1 SYNOPSIS
use Finance::Alpaca;
my $stream = Finance::Alpaca->new( ... )->trade_stream(
sub ($event) {
...
}
);
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
=head1 DESCRIPTION
Alpacaâs API offers WebSocket streaming for account and order updates. When
subscribed, events returned from Alpaca will be coerced into
Finance::Alpaca::Struct::Stream objects.
=head1 Properties
The fields present in a message depend on the type of event they are
communicating. All messages contain an event C<type> and an C<order> field,
which is the same as the order object that is returned from the REST API.
Potential event types and additional fields that will be in their messages are
listed below.
=head2 Common events
These are the events that are the expected results of actions you may have
taken by sending API requests.
=over
=item C<new> - Sent when an order has been routed to exchanges for execution
=item C<fill> - Sent when your order has been completely filled
=over
=item C<timestamp> - The time at which the order was filled
=item C<price> The average price per share at which the order was filled
=item C<position_qty> The size of your total position, after this fill event, in shares. Positive for long positions, negative for short positions
=back
=item C<partial_fill> Sent when a number of shares less than the total remaining quantity on your order has been filled.
=over
=item C<timestamp> The time at which the shares were filled
=item C<price> The average price per share at which the shares were filled
=item C<position_qty> The size of your total position, after this fill event, in shares. Positive for long positions, negative for short positions
=back
=item C<canceled> Sent when your requested cancelation of an order is processed
=over
=item C<timestamp> The time at which the order was canceled
=back
=item C<expired> Sent when an order has reached the end of its lifespan, as determined by the orderâs time in force value
=over
=item C<timestamp> The time at which the order expired
=back
( run in 0.443 second using v1.01-cache-2.11-cpan-5b529ec07f3 )