NAME
Finance::Alpaca::Struct::TradeUpdate - A Single Streamed Data Object
SYNOPSIS
use Finance::Alpaca;
my $stream = Finance::Alpaca->new( ... )->trade_stream(
sub ($event) {
...
}
);
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
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.
Properties
The fields present in a message depend on the type of event they are communicating. All messages contain an event type
and an 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.
Common events
These are the events that are the expected results of actions you may have taken by sending API requests.
new
- Sent when an order has been routed to exchanges for executionfill
- Sent when your order has been completely filled-
canceled
Sent when your requested cancelation of an order is processedexpired
Sent when an order has reached the end of its lifespan, as determined by the order’s time in force valuedone_for_day
Sent when the order is done executing for the day, and will not receive further updates until the next trading dayreplaced
Sent when your requested replacement of an order is processed
Rarer events
These are events that may rarely be sent due to unexpected circumstances on the exchanges. It is unlikely you will need to design your code around them, but you may still wish to account for the possibility that they will occur.
rejected
- Sent when your order has been rejectedpending_new
- Sent when the order has been received by Alpaca and routed to the exchanges, but has not yet been accepted for executionstopped
- Sent when your order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurredpending_cancel
- Sent when the order is awaiting cancelation. Most cancelations will occur without the order entering this statepending_replace
- Sent when the order is awaiting replacementcalculated
- Sent when the order has been completed for the day - it is either “filled” or “done_for_day” - but remaining settlement calculations are still pendingsuspended
- Sent when the order has been suspended and is not eligible for tradingorder_replace_rejected
- Sent when the order replace has been rejectedorder_cancel_rejected
- Sent when the order cancel has been rejected
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
AUTHOR
Sanko Robinson <sanko@cpan.org>