Add view to access to OHLC solds for an account.

This commit is contained in:
Alexis Lahouze 2015-06-16 17:18:48 +02:00
parent 66a635669a
commit f144c8ffc1

View File

@ -143,9 +143,28 @@ class CategoriesResource(Resource):
def get(self, session): def get(self, session):
kwargs = range_parser.parse_args() 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(EntryListResource, "/entries")
api_api.add_resource(EntryResource, "/entries/<int:entry_id>") api_api.add_resource(EntryResource, "/entries/<int:entry_id>")
api_api.add_resource(CategoriesResource, "/categories") api_api.add_resource(CategoriesResource, "/categories")
api_api.add_resource(SoldsResource, "/solds")