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 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 ## account?!s 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_order( self, contract_object_with_ib_data, trade_list, account="", order_type="market", limit_price=None, ): if contract_object_with_ib_data.is_spread_contract(): ibcontract_with_legs = self.ib_futures_contract( contract_object_with_ib_data, trade_list_for_multiple_legs=trade_list, return_leg_data=True, ) ibcontract = ibcontract_with_legs.ibcontract else: ibcontract = self.ib_futures_contract(contract_object_with_ib_data) ibcontract_with_legs = ibcontractWithLegs(ibcontract) if ibcontract is missing_contract: return missing_order ib_BS_str, ib_qty = resolveBS_for_list(trade_list) if order_type == "market": ib_order = MarketOrder(ib_BS_str, ib_qty) elif order_type == "limit": if limit_price is None: self.log.critical("Need to have limit price with limit order!") return missing_order else: ib_order = LimitOrder(ib_BS_str, ib_qty, limit_price) else: self.log.critical("Order type %s not recognised!" % order_type) return missing_order if account != "": ib_order.account = account order_object = self.ib.placeOrder(ibcontract, ib_order) # for consistency with spread orders trade_with_contract = tradeWithContract(ibcontract_with_legs, order_object) return trade_with_contract
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
def ib_submit_calendar_leg_market_order(self, contract_object_with_ib_data, trade_list, account=""): ibcontract_with_legs = self.ib_futures_contract( contract_object_with_ib_data, trade_list_for_multiple_legs=trade_list, return_leg_data=True) ibcontract = ibcontract_with_legs.ibcontract if ibcontract is missing_contract: return missing_order ib_BS_str, ib_qty = resolveBS_for_list(trade_list) ib_order = MarketOrder(ib_BS_str, ib_qty) if account != '': ib_order.account = account order_object = self.ib.placeOrder(ibcontract, ib_order) placed_broker_trade_object = tradeWithContract(ibcontract_with_legs, order_object) return placed_broker_trade_object