def broker_fx_market_order(self, trade, ccy1, account=arg_not_supplied, ccy2="USD"): """ Get some spot fx data :param ccy1: first currency in pair :param ccy2: second currency in pair :param qty: :return: broker order object """ ccy_code = ccy1 + ccy2 specific_log = self.log.setup(currency_code=ccy_code) ibcontract = self.ib_spotfx_contract(ccy1, ccy2=ccy2, log=specific_log) if ibcontract is missing_contract: return missing_contract ib_BS_str, ib_qty = resolveBS(trade) ib_order = MarketOrder(ib_BS_str, ib_qty) if account != "": ib_order.account = account order_object = self.ib.placeOrder(ibcontract, ib_order) # for consistency with spread orders trade_with_contract = tradeWithContract(ibcontractWithLegs(ibcontract), order_object) return trade_with_contract
def _create_fx_market_order_for_submission( self, trade: float, account_id: str = arg_not_supplied) -> MarketOrder: ib_BS_str, ib_qty = resolveBS(trade) ib_order = MarketOrder(ib_BS_str, ib_qty) if account_id is not arg_not_supplied: ib_order.account = account_id return ib_order
def _get_ib_combo_leg(ratio, resolved_leg): leg = ComboLeg() leg.conId = int(resolved_leg.conId) leg.exchange = str(resolved_leg.exchange) action, size = resolveBS(ratio) leg.ratio = int(size) leg.action = str(action) return leg
def ib_submit_single_leg_market_order(self, contract_object_with_ib_data, trade, account=""): ibcontract = self.ib_futures_contract(contract_object_with_ib_data) if ibcontract is missing_contract: return missing_order ib_BS_str, ib_qty = resolveBS(trade) ib_order = MarketOrder(ib_BS_str, ib_qty) if account != '': ib_order.account = account trade = self.ib.placeOrder(ibcontract, ib_order) return trade
def ib_submit_single_leg_market_order(self, contract_object_with_ib_data, trade, account=""): ibcontract = self.ib_futures_contract(contract_object_with_ib_data) if ibcontract is missing_contract: return missing_order ib_BS_str, ib_qty = resolveBS(trade) ib_order = MarketOrder(ib_BS_str, ib_qty) if account != '': ib_order.account = account order_object = self.ib.placeOrder(ibcontract, ib_order) # for consistency with spread orders trade_with_contract = tradeWithContract(ibcontractWithLegs(ibcontract), order_object) return trade_with_contract