diff options
Diffstat (limited to 'python/ops/funds.py')
| -rw-r--r-- | python/ops/funds.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/python/ops/funds.py b/python/ops/funds.py index bfc3750d..aaea047e 100644 --- a/python/ops/funds.py +++ b/python/ops/funds.py @@ -5,6 +5,8 @@ from serenitas.utils.remote import FtpClient, SftpClient from serenitas.utils.exchange import ExchangeMessage, FileAttachment from io import StringIO from typing import Tuple, Union +from serenitas.utils.env import DAILY_DIR +from .file_gen import get_headers, build_line class Fund: @@ -23,8 +25,11 @@ class Fund: def build_buffer(cls, trade_type): buf = StringIO() csvwriter = csv.writer(buf) - csvwriter.writerow(get_headers(trade_type, cls.name)) - csvwriter.writerows(cls.staged_queue) + headers = get_headers(trade_type, cls.name) + csvwriter.writerow(headers) + csvwriter.writerows( + [[obj.get(h) for h in headers] for obj in cls.stating_queue] + ) buf = buf.getvalue().encode() dest = cls.get_filepath(DAILY_DIR, trade_type) dest.parent.mkdir(exist_ok=True) @@ -36,8 +41,8 @@ class Fund: cls.headers = get_headers(trade_type, cls.name) @classmethod - def stage(cls, trade, trade_type): - cls.staged_queue.append(build_line(trade, trade_type, cls.name)) + def stage(cls, trade, *, trade_type, **kwargs): + cls.stating_queue.append(build_line(trade, trade_type, cls.name)) @classmethod def get_filepath( @@ -110,5 +115,5 @@ class Bowdst(Fund, fund_name="BOWDST"): class Selene(Fund, fund_name="ISOSEL"): @classmethod - def stage(cls, trade, action="NEW"): - cls.staged_queue.append(trade.to_citco(action)) + def stage(cls, trade, *, action="NEW", **kwargs): + cls.stating_queue.append(trade.to_citco(action)) |
