fix bug
This commit is contained in:
@@ -186,6 +186,24 @@ class HoldingHandler(BaseHandler):
|
||||
holding = format_holding(positions)
|
||||
self.write_json({"data": holding})
|
||||
|
||||
class OrgHandler(BaseHandler):
|
||||
def get(self, handler_type):
|
||||
result = safe_call(
|
||||
get_trade_detail_data, self.acc(), 'stock', handler_type
|
||||
) or []
|
||||
|
||||
data = []
|
||||
for item in result:
|
||||
fields = {}
|
||||
for name in dir(item):
|
||||
if name.startswith('_'):
|
||||
continue
|
||||
value = getattr(item, name)
|
||||
if not callable(value):
|
||||
fields[name] = value
|
||||
data.append(fields)
|
||||
self.write_json({"data": data})
|
||||
|
||||
# get_trade_detail_data('account') - Query account assets
|
||||
class AssetsHandler(BaseHandler):
|
||||
def get(self):
|
||||
@@ -318,6 +336,7 @@ def format_holding(positions):
|
||||
'Direction': position.m_nDirection,
|
||||
'Volume': position.m_nVolume,
|
||||
'OpenPrice': position.m_dOpenPrice,
|
||||
'OpenCost':position.m_dOpenCost,
|
||||
'FloatProfit': position.m_dFloatProfit,
|
||||
'MarketValue': position.m_dMarketValue,
|
||||
'StockHolder': position.m_strStockHolder,
|
||||
@@ -372,6 +391,7 @@ def make_app():
|
||||
# Portfolio
|
||||
(r"/api/portfolio", PortfolioHandler),
|
||||
(r"/api/portfolio/positions", HoldingHandler),
|
||||
(r"/api/portfolio/org/(account|order|deal|position)",OrgHandler),
|
||||
(r"/api/portfolio/assets", AssetsHandler),
|
||||
(r"/api/portfolio/order", OrderHandler),
|
||||
(r"/api/portfolio/deal", DealHandler),
|
||||
|
||||
Reference in New Issue
Block a user