Finance-Alpaca
view release on metacpan or search on metacpan
lib/Finance/Alpaca/Struct/Order.pm view on Meta::CPAN
package Finance::Alpaca::Struct::Order 0.9902 {
use strictures 2;
use feature 'signatures';
no warnings 'experimental::signatures';
#
use Type::Library 0.008 -base, -declare => qw[Order];
use Type::Utils;
use Types::Standard qw[ArrayRef Bool Enum InstanceOf Int Maybe Num Ref Str];
use Types::TypeTiny 0.004 StringLike => { -as => "Stringable" };
class_type Order, { class => __PACKAGE__ };
coerce( Order, from Ref() => __PACKAGE__ . q[->new($_)] );
#
use Moo;
use Types::UUID;
use lib './lib';
use Finance::Alpaca::Types;
has [qw[id asset_id]] => ( is => 'ro', isa => Uuid, required => 1 );
has client_order_id => ( is => 'ro', isa => Str, required => 1 );
has created_at => ( is => 'ro', isa => Timestamp, required => 1, coerce => 1 );
has [qw[updated_at submitted_at filled_at expired_at canceled_at failed_at replaced_at]] =>
( is => 'ro', isa => Maybe [Timestamp], predicate => 1, coerce => 1 );
has [qw[replaced_by replaces]] => ( is => 'ro', isa => Maybe [Uuid], predicate => 1 );
has [qw[symbol asset_class]] => ( is => 'ro', isa => Str, required => 1 ); # If from stream
has [qw[notional qty filled_avg_price limit_price stop_price trail_percent trail_price hwm]] =>
( is => 'ro', isa => Maybe [Num], predicate => 1 );
has filled_qty => ( is => 'ro', isa => Num, required => 1 );
has order_class =>
( is => 'ro', isa => Enum [ '', qw[simple bracket oco oto] ], required => 1 );
has type =>
( is => 'ro', isa => Enum [qw[market limit stop stop_limit trailing_stop]], required => 1 );
has side => ( is => 'ro', isa => Enum [qw[buy sell]], required => 1 );
has time_in_force => ( is => 'ro', isa => Enum [qw[day gtc opg cls ioc fok]], required => 1 );
has status => (
is => 'ro',
isa => Enum [
qw[new partially_filled filled done_for_day canceled expired replaced pending_cancel pending_replace accepted pending_new accepted_for_bidding stopped rejected suspended calculated held]
],
required => 1
);
has extended_hours => ( is => 'ro', isa => Bool, required => 1, coerce => 1 );
has legs => ( is => 'ro', isa => Maybe [ ArrayRef [Order] ], coerce => 1 );
}
1;
__END__
=encoding utf-8
=head1 NAME
Finance::Alpaca::Struct::Order - A Single Order Object
=head1 SYNOPSIS
use Finance::Alpaca;
my @orders = Finance::Alpaca->new( ... )->orders( status => 'all' );
say $orders[0]->id;
=head1 DESCRIPTION
The orders API allows a user to monitor, place and cancel their orders with
Alpaca. Each order has a unique identifier provided by the client. This
client-side unique order ID will be automatically generated by the system if
not provided by the client, and will be returned as part of the order object
along with the rest of the fields described below. Once an order is placed, it
can be queried using the client-side order ID to check the status. Updates on
open orders at Alpaca will also be sent over the streaming interface, which is
the recommended method of maintaining order state.
=head1 Properties
The following properties are contained in the object.
$trade->id();
=over
=item C<id> - Order ID; UUID
=item C<client_order_id> - Client unique order ID
=item C<created_at> - Timestamp as Time::Moment object
=item C<updated_at> - Timestamp as Time::Moment object if available
=item C<submitted_at> - Timestamp as Time::Moment object if available
=item C<filled_at> - Timestamp as Time::Moment object if available
=item C<expired_at> - Timestamp as Time::Moment object if available
=item C<canceled_at> - Timestamp as Time::Moment object if available
=item C<failed_at> - Timestamp as Time::Moment object if available
=item C<replaced_at> - Timestamp as Time::Moment object if available
=item C<replaced_by> - The order ID that this order was replaced by if available; UUID
=item C<replaces> - The order ID that this order replaces if available; UUID
=item C<asset_id> - Asset ID; UUID
( run in 4.711 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )