forked from alpacahq/alpaca-trade-api-csharp
/
StopLossOrder.cs
39 lines (34 loc) · 1.19 KB
/
StopLossOrder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace Alpaca.Markets;
/// <summary>
/// Encapsulates data required for placing stop loss order on the Alpaca REST API.
/// </summary>
public sealed class StopLossOrder : AdvancedOrderBase, IStopLoss
{
internal StopLossOrder(
SimpleOrderBase baseOrder,
Decimal stopPrice,
Decimal? limitPrice)
: base(
baseOrder,
OrderClass.OneTriggersOther)
{
LimitPrice = limitPrice;
StopPrice = stopPrice;
}
/// <inheritdoc />
public Decimal StopPrice { get; }
/// <inheritdoc />
public Decimal? LimitPrice { get; }
/// <summary>
/// Creates a new instance of the <see cref="BracketOrder"/> order from the current order.
/// </summary>
/// <param name="takeProfitLimitPrice">Take profit order limit price.</param>
/// <returns>New advanced order representing pair of original order and take profit order.</returns>
[UsedImplicitly]
public BracketOrder TakeProfit(
Decimal takeProfitLimitPrice) =>
new(BaseOrder, takeProfitLimitPrice, StopPrice, LimitPrice);
internal override JsonNewOrder GetJsonRequest() =>
base.GetJsonRequest()
.WithStopLoss(this);
}