From f144c8ffc19510c334685a4a744da80231850e26 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Tue, 16 Jun 2015 17:18:48 +0200 Subject: [PATCH] Add view to access to OHLC solds for an account. --- accountant/api/views/entries.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/accountant/api/views/entries.py b/accountant/api/views/entries.py index a5d0062..d29b696 100644 --- a/accountant/api/views/entries.py +++ b/accountant/api/views/entries.py @@ -143,9 +143,28 @@ class CategoriesResource(Resource): def get(self, session): kwargs = range_parser.parse_args() - return Operation.get_categories_for_range(session, **kwargs) + return Operation.get_categories_for_range(session, **kwargs).all() + + +ohlc_resource_fields = { + 'operation_date': fields.DateTime(dt_format='iso8601'), + 'open': fields.Float, + 'high': fields.Float, + 'low': fields.Float, + 'close': fields.Float +} + + +class SoldsResource(Resource): + @session_aware + @marshal_with_field(fields.List(Object(ohlc_resource_fields))) + def get(self, session): + kwargs = range_parser.parse_args() + + return Operation.get_ohlc_per_day_for_range(session, **kwargs).all() api_api.add_resource(EntryListResource, "/entries") api_api.add_resource(EntryResource, "/entries/") api_api.add_resource(CategoriesResource, "/categories") +api_api.add_resource(SoldsResource, "/solds")