From 9e62731f75c3dd5e4247ce490ed9c37aa22fdaaf Mon Sep 17 00:00:00 2001 From: Rob Carver Date: Tue, 19 Mar 2024 15:05:52 +0000 Subject: [PATCH] infrastructure for comissoin --- sysbrokers/broker_contract_commission_data.py | 20 +++++++++++++++++++ sysbrokers/broker_factory.py | 3 +++ sysproduction/data/broker.py | 7 +++++++ 3 files changed, 30 insertions(+) diff --git a/sysbrokers/broker_contract_commission_data.py b/sysbrokers/broker_contract_commission_data.py index e69de29bb2..f993ed5200 100644 --- a/sysbrokers/broker_contract_commission_data.py +++ b/sysbrokers/broker_contract_commission_data.py @@ -0,0 +1,20 @@ + + +from sysdata.futures.contracts import futuresContractData +from sysdata.data_blob import dataBlob +from sysobjects.contracts import futuresContract + +from syslogging.logger import * + + +class brokerFuturesContractCommissionData(futuresContractData): + def __init__(self, data: dataBlob, log=get_logger("brokerFuturesContractCommissionData")): + super().__init__(log=log) + self._data = data + + def get_commission_for_contract(self, contract: futuresContract) -> float: + raise NotImplementedError + + @property + def data(self): + return self._data diff --git a/sysbrokers/broker_factory.py b/sysbrokers/broker_factory.py index be4eaabe44..fc7dbd1ac9 100644 --- a/sysbrokers/broker_factory.py +++ b/sysbrokers/broker_factory.py @@ -7,6 +7,8 @@ from sysbrokers.IB.ib_orders import ibExecutionStackData from sysbrokers.IB.ib_static_data import ibStaticData from sysbrokers.IB.ib_fx_handling import ibFxHandlingData +from sysbrokers.IB.ib_broker_commissions import ibFuturesContractCommissionData + from syscore.objects import resolve_function from sysdata.data_blob import dataBlob @@ -43,4 +45,5 @@ def get_ib_class_list(): ibCapitalData, ibFuturesInstrumentData, ibFxHandlingData, + ibFuturesContractCommissionData ] diff --git a/sysproduction/data/broker.py b/sysproduction/data/broker.py index c6b1607111..a217df204f 100644 --- a/sysproduction/data/broker.py +++ b/sysproduction/data/broker.py @@ -1,5 +1,6 @@ from copy import copy +from sysbrokers.broker_contract_commission_data import brokerFuturesContractCommissionData from sysbrokers.broker_factory import get_broker_class_list from sysbrokers.broker_fx_handling import brokerFxHandlingData from sysbrokers.broker_static_data import brokerStaticData @@ -93,11 +94,17 @@ def broker_fx_handling_data(self) -> brokerFxHandlingData: def broker_static_data(self) -> brokerStaticData: return self.data.broker_static + @property + def broker_futures_contract_commission(self) -> brokerFuturesContractCommissionData: + return self.data.broker_futures_contract_commission + @property def diag_controls(self) -> diagControlProcess: return self._diag_controls ## Methods + def get_commission_for_contract(self, contract: futuresContract) -> float: + return self.broker_futures_contract_commission.get_commission_for_contract(contract) def get_list_of_contract_dates_for_instrument_code( self, instrument_code: str, allow_expired: bool = False