forked from alpacahq/alpaca-trade-api-csharp
/
SimpleOrderBase.cs
101 lines (95 loc) · 3.85 KB
/
SimpleOrderBase.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
namespace Alpaca.Markets;
/// <summary>
/// Encapsulates base data for ordinal order types, never used directly by any code.
/// </summary>
public abstract class SimpleOrderBase : OrderBase
{
/// <summary>
/// Creates new instance of the <see cref="SimpleOrderBase"/> class.
/// </summary>
/// <param name="symbol">Alpaca symbol for order.</param>
/// <param name="quantity">Order quantity (absolute value).</param>
/// <param name="side">Order side (buy or sell).</param>
/// <param name="type">Order type (market, limit, stop, stop-limit).</param>
/// <exception cref="ArgumentNullException">
/// The <paramref name="symbol"/> argument is <c>null</c>.
/// </exception>
protected internal SimpleOrderBase(
String symbol,
OrderQuantity quantity,
OrderSide side,
OrderType type)
: base(
symbol,
quantity,
side,
type)
{
}
/// <summary>
/// Creates a new instance of the <see cref="TakeProfitOrder"/> 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>
public TakeProfitOrder TakeProfit(
Decimal takeProfitLimitPrice) =>
new(
this,
takeProfitLimitPrice);
/// <summary>
/// Creates a new instance of the <see cref="StopLossOrder"/> order from the current order.
/// </summary>
/// <param name="stopLossStopPrice">Stop loss order stop price.</param>
/// <returns>New advanced order representing pair of original order and stop loss order.</returns>
public StopLossOrder StopLoss(
Decimal stopLossStopPrice) =>
new(
this,
stopLossStopPrice,
null);
/// <summary>
/// Creates a new instance of the <see cref="StopLossOrder"/> order from the current order.
/// </summary>
/// <param name="stopLossStopPrice">Stop loss order stop price.</param>
/// <param name="stopLossLimitPrice">Stop loss order limit price.</param>
/// <returns>New advanced order representing pair of original order and stop loss order.</returns>
public StopLossOrder StopLoss(
Decimal stopLossStopPrice,
Decimal stopLossLimitPrice) =>
new(
this,
stopLossStopPrice,
stopLossLimitPrice);
/// <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>
/// <param name="stopLossStopPrice">Stop loss order stop price.</param>
/// <returns>New advanced order representing an original order plus pair of take profit and stop loss orders.</returns>
[UsedImplicitly]
public BracketOrder Bracket(
Decimal takeProfitLimitPrice,
Decimal stopLossStopPrice) =>
new(
this,
takeProfitLimitPrice,
stopLossStopPrice,
null);
/// <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>
/// <param name="stopLossStopPrice">Stop loss order stop price.</param>
/// <param name="stopLossLimitPrice">Stop loss order limit price.</param>
/// <returns>New advanced order representing an original order plus pair of take profit and stop loss orders.</returns>
[UsedImplicitly]
public BracketOrder Bracket(
Decimal takeProfitLimitPrice,
Decimal stopLossStopPrice,
Decimal stopLossLimitPrice) =>
new(
this,
takeProfitLimitPrice,
stopLossStopPrice,
stopLossLimitPrice);
}