mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-07-03 04:38:38 -04:00
Add security prices
* Import them from Gnucash's pricedb * Add support for querying prices from lua for reports * Add documentation for lua reports
This commit is contained in:
@ -135,6 +135,8 @@ func luaSecurity__index(L *lua.LState) int {
|
||||
L.Push(lua.LNumber(float64(a.Precision)))
|
||||
case "Type", "type":
|
||||
L.Push(lua.LNumber(float64(a.Type)))
|
||||
case "ClosestPrice", "closestprice":
|
||||
L.Push(L.NewFunction(luaClosestPrice))
|
||||
default:
|
||||
L.ArgError(2, "unexpected security attribute: "+field)
|
||||
}
|
||||
@ -142,6 +144,21 @@ func luaSecurity__index(L *lua.LState) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func luaClosestPrice(L *lua.LState) int {
|
||||
s := luaCheckSecurity(L, 1)
|
||||
c := luaCheckSecurity(L, 2)
|
||||
date := luaCheckTime(L, 3)
|
||||
|
||||
p, err := GetClosestPrice(s, c, date)
|
||||
if err != nil {
|
||||
L.Push(lua.LNil)
|
||||
} else {
|
||||
L.Push(PriceToLua(L, p))
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
func luaSecurity__tostring(L *lua.LState) int {
|
||||
s := luaCheckSecurity(L, 1)
|
||||
|
||||
|
Reference in New Issue
Block a user