Exemple #1
0
def buy_option(buy_close, credit_debit, symbol, price, symbol, option_type, date, strike):

    # Covert date
    if len(date.split('/')[0]) == 1:
        month = '0' + date.split('/')[0]
    else:
        month = date.split('/')[0]
    if len(date.split('/')[1]) == 1:
        day = '0' + date.split('/')[0]
    else:
        day = date.split('/')[0]
    today = datetime.today()
    exp_date = f'{month}/{day}/{str(today.year)}'

    # Convert position_effect
    if buy_close == 'BTO':
        position_effect = 'buy'
    elif buy_close == 'BTC':
        position_effect == 'close'
    else:
        print('Invalid position effect')

    # Convert option_type
    if option_type == 'C':
        call_put = 'call'
    elif option_type == 'P':
        call_put == 'put'
    else:
        print('Invalid option type')

    #EXAMPLE = BTO GME 50 P 2/12 4.85
    result = rh.order_buy_option_limit(position_effect, credit_debit(?), price, quantity = 1, strike, exp_date)
    ui.chec_ref(result)
Exemple #2
0
def sell(quantity, symbol, limit):
    if limit is not None:
        ui.success(f"\nSelling {quantity} of {symbol} at ${limit}\n")
        result = rh.order_sell_limit(symbol, quantity, limit)
    else:
        ui.success(f'\nSelling {quantity} of {symbol} at market price....\n')
        result = rh.order_sell_market(symbol, quantity)
    ui.chec_ref(result)
Exemple #3
0
def buy_doge(amount):
    ui.success(f'Ordering ${amount} of DOGE....\n')
    # Doge error workaround
    price = float(rh.get_crypto_quote('DOGE').get('ask_price'))
    shares = round(amount/price, 0)
    result = rh.order_buy_crypto_by_quantity('DOGE', shares)

    ui.chec_ref(result)
Exemple #4
0
def buy(quantity, symbol, limit):
    if limit is not None:
        ui.success(f"Bying {quantity} of {symbol} at ${limit}")
        result = rh.order_buy_limit(symbol, quantity, limit)
    else:
        ui.success(f'Bying {quantity} of {symbol} at market price....\n')
        result = rh.order_buy_market(symbol, quantity)

    ui.chec_ref(result)
Exemple #5
0
def buy_frac(amount, symbol):
    ui.success(f'\nBuying ${amount} of {symbol}....\n')
    result = rh.order_buy_fractional_by_price(symbol, amount)
    ui.chec_ref(result)
Exemple #6
0
def buy_crypto(symbol, amount):
    ui.success(f'Ordering ${amount} of {symbol}....\n')
    result = rh.order_buy_crypto_by_price(symbol, amount)
    ui.chec_ref(result)