@@ -6,6 +6,8 @@ mutable struct Order{OData,IData}
66 const date:: DateTime
77 const price:: Price
88 const quantity:: Quantity # negative = short selling
9+ take_profit:: Price
10+ stop_loss:: Price
911 metadata:: OData
1012
1113 function Order (
@@ -15,9 +17,20 @@ mutable struct Order{OData,IData}
1517 price:: Price ,
1618 quantity:: Quantity
1719 ;
20+ take_profit:: Price = Price (NaN ),
21+ stop_loss:: Price = Price (NaN ),
1822 metadata:: OData = nothing
1923 ) where {OData,IData}
20- new {OData,IData} (oid, inst, date, price, quantity, metadata)
24+ new {OData,IData} (
25+ oid,
26+ inst,
27+ date,
28+ price,
29+ quantity,
30+ take_profit,
31+ stop_loss,
32+ metadata,
33+ )
2134 end
2235end
2336
2740
2841function Base. show (io:: IO , o:: Order{O,I} ) where {O,I}
2942 date_formatter = x -> Dates. format (x, " yyyy-mm-dd HH:MM:SS" )
43+ tp_str = isnan (o. take_profit) ? " —" : " $(format_quote (o. inst, o. take_profit)) $(o. inst. quote_symbol) "
44+ sl_str = isnan (o. stop_loss) ? " —" : " $(format_quote (o. inst, o. stop_loss)) $(o. inst. quote_symbol) "
3045 print (io, " [Order] $(o. inst. symbol) " *
3146 " date=$(date_formatter (o. date)) " *
3247 " price=$(format_quote (o. inst, o. price)) $(o. inst. quote_symbol) " *
33- " quantity=$(format_base (o. inst, o. quantity)) $(o. inst. base_symbol) " )
48+ " quantity=$(format_base (o. inst, o. quantity)) $(o. inst. base_symbol) " *
49+ " tp=$(tp_str) " *
50+ " sl=$(sl_str) " )
3451end
3552
3653Base. show (order:: Order{O,I} ) where {O,I} = Base. show (stdout , order)
0 commit comments