Ejemplo n.º 1
0
def make_contract(symbol,
                  secType,
                  exchange,
                  primaryExchange,
                  currency,
                  lastTradeDateOrContractMonth=None,
                  strike=None,
                  right=None,
                  multiplier=None,
                  tradingClass=None):
    contract = Contract()
    contract.symbol = symbol
    contract.secType = secType
    contract.exchange = exchange
    contract.primaryExchange = primaryExchange
    contract.currency = currency
    if lastTradeDateOrContractMonth is not None:
        contract.lastTradeDateOrContractMonth = lastTradeDateOrContractMonth
    if strike is not None:
        contract.strike = strike
    if right is not None:
        contract.right = strike
    if multiplier is not None:
        contract.multiplier = multiplier
    if tradingClass is not None:
        contract.tradingClass = tradingClass

    return contract
Ejemplo n.º 2
0
    def basic_order(self, order_id: int):
        contract_aapl = self.contract_aapl()

        parent = Order()
        parent.orderId = order_id
        parent.action = "buy"
        parent.orderType = "LMT"
        parent.totalQuantity = 1
        parent.lmtPrice = 8
        parent.transmit = False

        option_contract = Contract()
        option_contract.symbol = 'TSLA'
        option_contract.secType = "OPT"
        option_contract.exchange = "SMART"
        option_contract.primaryExchange = "SMART"
        option_contract.currency = "USD"
        option_contract.strike = 310.0
        option_contract.lastTradeDateOrContractMonth = "20190315"
        option_contract.right = "P"

        pp33_order_builder = PP33BracketOrderBuilder(order_id, parent)

        for order_in_bracket in pp33_order_builder.bracket_order_list():
            self.placeOrder(order_in_bracket.orderId, option_contract,
                            order_in_bracket)
Ejemplo n.º 3
0
 def contract_amzn_opt(self):
     incomplete_contract = Contract()
     incomplete_contract.symbol = 'AMZN'
     incomplete_contract.secType = "OPT"
     incomplete_contract.exchange = "SMART"
     incomplete_contract.currency = "USD"
     incomplete_contract.strike = 1900
     incomplete_contract.lastTradeDateOrContractMonth = "20190719"
     incomplete_contract.right = "C"
     return incomplete_contract
Ejemplo n.º 4
0
 def contract_spx_option(self):
     contract = Contract()
     contract.symbol = 'SPX'
     contract.secType = "OPT"
     contract.exchange = "SMART"
     contract.primaryExchange = "SMART"
     contract.currency = "USD"
     contract.strike = 2800
     contract.lastTradeDateOrContractMonth = "20190329"
     contract.right = "C"
     return contract
Ejemplo n.º 5
0
def OptionAtBOX():
    #! [optcontract]
    contract = Contract()
    contract.symbol = "AMZN"
    contract.secType = "OPT"
    contract.exchange = "SMART"
    contract.currency = "USD"
    contract.lastTradeDateOrContractMonth = "20190125"
    contract.strike = 1570
    contract.right = "C"
    contract.multiplier = "100"
    #! [optcontract]
    return contract
Ejemplo n.º 6
0
def OptionWithTradingClass():
    contract = Contract()
    contract.symbol = "SPX"
    contract.secType = "OPT"
    contract.exchange = "SMART"
    contract.primaryExchange = "SMART"
    contract.currency = "USD"
    contract.lastTradeDateOrContractMonth = "20190219"
    contract.strike = 2520
    contract.right = "C"
    contract.multiplier = "100"
    contract.tradingClass = "SPX"
    return contract
Ejemplo n.º 7
0
 def contract_bidu_option(self):
     # ! [optcontract]
     contract = Contract()
     contract.symbol = "BIDU"
     contract.secType = "OPT"
     contract.exchange = "SMART"
     contract.currency = "USD"
     contract.lastTradeDateOrContractMonth = "20190322"
     contract.strike = 165
     contract.right = "PUT"
     contract.multiplier = "100"
     # ! [optcontract]
     return contract
Ejemplo n.º 8
0
def Dict_to_Contract(data: dict):
    con = Contract()
    con.symbol = data['symbol']
    con.conId = data['conID']
    con.secType = data['secType']
    con.currency = data['currency']
    con.exchange = data['exchange']
    con.primaryExchange = data['primaryExchange']
    con.multiplier = data['multiplier']
    con.tradingClass = data['tradingClass']
    con.localSymbol = data['localSymbol']
    con.right = data['right']
    con.lastTradeDateOrContractMonth = data['lastTradeDateOrContractMonth']
    con.strike = data['strike']
    return con