summaryrefslogtreecommitdiff
path: root/src/session.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.cc')
-rw-r--r--src/session.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/session.cc b/src/session.cc
index 3b043952..85b5fab2 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -194,12 +194,36 @@ value_t session_t::fn_min(call_scope_t& args)
{
return args[1] < args[0] ? args[1] : args[0];
}
-
value_t session_t::fn_max(call_scope_t& args)
{
return args[1] > args[0] ? args[1] : args[0];
}
+value_t session_t::fn_lot_price(call_scope_t& args)
+{
+ amount_t amt(args.get<amount_t>(1, false));
+ if (amt.has_annotation() && amt.annotation().price)
+ return *amt.annotation().price;
+ else
+ return NULL_VALUE;
+}
+value_t session_t::fn_lot_date(call_scope_t& args)
+{
+ amount_t amt(args.get<amount_t>(1, false));
+ if (amt.has_annotation() && amt.annotation().date)
+ return *amt.annotation().date;
+ else
+ return NULL_VALUE;
+}
+value_t session_t::fn_lot_tag(call_scope_t& args)
+{
+ amount_t amt(args.get<amount_t>(1, false));
+ if (amt.has_annotation() && amt.annotation().tag)
+ return string_value(*amt.annotation().tag);
+ else
+ return NULL_VALUE;
+}
+
option_t<session_t> * session_t::lookup_option(const char * p)
{
switch (*p) {
@@ -252,6 +276,15 @@ expr_t::ptr_op_t session_t::lookup(const symbol_t::kind_t kind,
return MAKE_FUNCTOR(session_t::fn_account);
break;
+ case 'l':
+ if (is_eq(p, "lot_price"))
+ return MAKE_FUNCTOR(session_t::fn_lot_price);
+ else if (is_eq(p, "lot_date"))
+ return MAKE_FUNCTOR(session_t::fn_lot_date);
+ else if (is_eq(p, "lot_tag"))
+ return MAKE_FUNCTOR(session_t::fn_lot_tag);
+ break;
+
case 'm':
if (is_eq(p, "min"))
return MAKE_FUNCTOR(session_t::fn_min);