Exemplo n.º 1
0
def findEquity(market_value, crypto, total_equity, change, show_all_equity=True):
    message = None
    if show_all_equity:
        message = create_simple_message('Total Equity', '${:,.2f}'.format(float(total_equity)), embed=message)
        message = create_simple_message('Stock Value', '${:,.2f}'.format(float(market_value)), embed=message)
        message = create_simple_message('Crypto Value', '${:,.2f}'.format(float(crypto)), embed=message)
    message = create_simple_message('Daily Change', '{:,.5f}%'.format(float(change)), embed=message)
    return message
Exemplo n.º 2
0
    async def run(self):
        r.login(os.getenv('ROBINHOOD_USERNAME'),
                os.getenv('ROBINHOOD_PASSWORD'))
        stock = self.content.replace('$price ', '').upper().split()

        # message = create_simple_message('self', self.content)
        # message = create_simple_message('title', self.content, embed=message)

        for s in stock:
            dict = r.stocks.find_instrument_data(stock)
            for d in dict:
                if None in [d]:
                    message = "❌ '" + s + "' stock symbol doesn't exist."
                    self.response.add_response(message)
                    continue

                message = create_simple_message(
                    s, '$' + r.stocks.get_latest_price(s)[0])
                name = (d['simple_name'])
                stock = (d['symbol'])
                message = name + ' (' + stock + ')' + ' is currently worth ' + '${:,.2f}'.format(
                    float(r.stocks.get_latest_price(stock)[0]))
        # message = create_simple_message('AAPL', '<a href="https://robinhood.com/stocks/aapl">APPL stock</a>', embed=message)
        self.response.add_response(message, True)

        if len(self.response.response) == 0:
            self.response.set_error_response(0)
        self.response.done = True
Exemplo n.º 3
0
    async def run(self):
        message = create_simple_message(
            '$help', 'Gives a brief description of each command')
        message = create_simple_message('$price [SYMBOL]',
                                        'Gives the current price of the stock',
                                        embed=message)
        message = create_simple_message(
            '$info [SYMBOL]',
            "Gives some general information about the stock and it's company",
            embed=message)
        message = create_simple_message(
            '$trade_info [SYMBOL]',
            "Gives detailed information about the stock",
            embed=message)
        message = create_simple_message(
            '$deposit [USD]',
            "Allows you to deposit money from your connected bank account",
            embed=message)
        message = create_simple_message(
            '$withdraw [USD]',
            "Allows you to withdraw money to your connected bank account",
            embed=message)
        message = create_simple_message(
            '$equity',
            "Gives you information about your total portfolio's equity, including daily gains/losses",
            embed=message)
        message = create_simple_message(
            '$add_bank',
            "Connects your capital one bank account to the bot",
            embed=message)
        message = create_simple_message(
            '$trade_help',
            'Gives detailed information about trading commands',
            embed=message)
        message = create_simple_message(
            '$stocks_from_market [MARKET TAG]',
            'Possible Tags: https://mattrode.com/blog/robinhood-collections-list/',
            embed=message)
        self.response.set_state(True)
        self.response.add_response(message)

        if len(self.response.response) == 0:
            self.response.set_error_response(0)
        self.response.done = True
Exemplo n.º 4
0
def company_stock_info(name, symbol, price, market, details, industry, link):
    message = create_simple_message('Company', name)
    message = create_simple_message('Symbol', symbol, embed=message)
    message = create_simple_message('Price per share',
                                    '${:,.2f}'.format(float(price)),
                                    embed=message)
    message = create_simple_message('Market cap',
                                    '${:,.2f}'.format(float(market)),
                                    embed=message)
    message = create_simple_message('About',
                                    f'{cut_off_sentence(details)}',
                                    embed=message)
    message = create_simple_message('Industry', industry, embed=message)
    message = create_simple_message('More info', link, embed=message)
    return message
Exemplo n.º 5
0
def order_information(symbol,
                      quantity,
                      buy_sell=None,
                      limit_price=None,
                      stop_price=None,
                      timeout_code=None):

    message = create_simple_message('Company', symbol)
    message = create_simple_message('Symbol', symbol, embed=message)
    message = create_simple_message('Quantity', quantity, embed=message)
    message = create_simple_message('Buy or Sell', buy_sell, embed=message)
    message = create_simple_message('Limit Price', limit_price, embed=message)
    message = create_simple_message('Stop Price', stop_price, embed=message)
    message = create_simple_message('Timeout Code',
                                    timeout_code,
                                    embed=message)
    message.title = '✅ Order Placed - Details:'
    return message
Exemplo n.º 6
0
def company_trading_info(name, symbol, open, high, low, volume,
                         average_volume_2_weeks, high52weeks, low52weeks,
                         dividend_yield, floatt, market, pb_ratio, pe_ratio,
                         shares_outstanding, link):
    message = create_simple_message('Company', name)
    message = create_simple_message('Symbol', symbol, embed=message)
    message = create_simple_message('Open price',
                                    '${:,.2f}'.format(float(open)),
                                    embed=message)
    message = create_simple_message('High price',
                                    '${:,.2f}'.format(float(high)),
                                    embed=message)
    message = create_simple_message('Low price',
                                    '${:,.2f}'.format(float(low)),
                                    embed=message)
    message = create_simple_message('High price average (52 weeks)',
                                    '${:,.2f}'.format(float(high52weeks)),
                                    embed=message)
    message = create_simple_message('Low price average (52 weeks)',
                                    '${:,.2f}'.format(float(low52weeks)),
                                    embed=message)
    message = create_simple_message('Volume',
                                    '{:,.2f}'.format(float(volume)),
                                    embed=message)
    message = create_simple_message('Average Volume (2 weeks)',
                                    '{:,.2f}'.format(
                                        float(average_volume_2_weeks)),
                                    embed=message)
    message = create_simple_message('Dividend Yield',
                                    dividend_yield,
                                    embed=message)
    message = create_simple_message('Float',
                                    '{:,.2f}'.format(float(floatt)),
                                    embed=message)
    message = create_simple_message('Market cap',
                                    '${:,.2f}'.format(float(market)),
                                    embed=message)
    message = create_simple_message('pb ratio',
                                    '{:,.4f}'.format(float(pb_ratio)),
                                    embed=message)
    message = create_simple_message('pe ratio',
                                    '{:,.4f}'.format(float(pe_ratio)),
                                    embed=message)
    message = create_simple_message('Shares outstanding',
                                    '{:,.2f}'.format(
                                        float(shares_outstanding)),
                                    embed=message)
    message = create_simple_message('More info', link, embed=message)
    return message
Exemplo n.º 7
0
    async def run(self):
        r.login(os.getenv('ROBINHOOD_USERNAME'),
                os.getenv('ROBINHOOD_PASSWORD'))
        limit_price, stop_price, quantity, amountInDollars = 1.0, 1.0, 1, 1.0
        buy_sell = 'N/A'
        if '$order ' in self.content:
            stock = self.content.replace('$order ', '').upper().split()
            symbol, quantity, buy_sell, limit_price, stop_price, timeout_code = stock
            confirmation = r.order(str(symbol), int(quantity),
                                   (str(buy_sell)).lower(), float(limit_price),
                                   float(stop_price),
                                   (str(timeout_code)).lower())

        elif '$order_buy_market ' in self.content:
            stock = self.content.replace('$order_buy_market ',
                                         '').upper().split()
            symbol, quantity, timeout_code = stock
            confirmation = r.order_buy_market(str(symbol), int(quantity),
                                              str(timeout_code).lower())

        elif '$order_sell_market ' in self.content:
            stock = self.content.replace('$order_sell_market ',
                                         '').upper().split()
            symbol, quantity, buy_sell, limit_price, stop_price, timeout_code = stock
            confirmation = r.order_sell_market(str(symbol), int(quantity),
                                               str(timeout_code).lower())

        elif '$order_buy_limit ' in self.content:
            stock = self.content.replace('$order_buy_limit ',
                                         '').upper().split()
            symbol, quantity, limit_price, timeout_code = stock
            confirmation = r.order_buy_limit(str(symbol), int(quantity),
                                             float(limit_price),
                                             str(timeout_code).lower())

        elif '$order_sell_limit ' in self.content:
            stock = self.content.replace('$order_sell_limit ',
                                         '').upper().split()
            symbol, quantity, limit_price, timeout_code = stock
            confirmation = r.order_sell_limit(str(symbol), int(quantity),
                                              float(limit_price),
                                              str(timeout_code).lower())

        elif '$order_buy_stop_loss ' in self.content:
            stock = self.content.replace('$order_buy_stop_loss ',
                                         '').upper().split()
            symbol, quantity, stop_price, timeout_code = stock
            confirmation = r.order_buy_stop_loss(str(symbol), int(quantity),
                                                 float(stop_price),
                                                 str(timeout_code).lower())

        elif '$order_sell_stop_loss ' in self.content:
            stock = self.content.replace('$order_sell_stop_loss ',
                                         '').upper().split()
            symbol, quantity, stop_price, timeout_code = stock
            confirmation = r.order_sell_stop_loss(str(symbol), int(quantity),
                                                  float(stop_price),
                                                  str(timeout_code).lower())

        elif '$order_buy_trailing_stop ' in self.content:
            stock = self.content.replace('$order_buy_trailing_stop ',
                                         '').upper().split()
            symbol, quantity, trailAmount, trailType, timeout_code = stock
            confirmation = r.order_buy_trailing_stop(str(symbol),
                                                     int(quantity),
                                                     float(trailAmount),
                                                     (str(trailType)).lower(),
                                                     str(timeout_code).lower())

        elif '$order_sell_trailing_stop ' in self.content:
            stock = self.content.replace('$order_sell_trailing_stop ',
                                         '').upper().split()
            symbol, quantity, trailAmount, trailType, timeout_code = stock
            confirmation = r.order_sell_trailing_stop(
                str(symbol), int(quantity), float(trailAmount), str(trailType),
                str(timeout_code).lower())

        elif '$order_sell_stop_limit ' in self.content:
            stock = self.content.replace('$order_sell_stop_limit ',
                                         '').upper().split()
            symbol, quantity, limit_price, stop_price, timeout_code = stock
            confirmation = r.order_sell_stop_limit(str(symbol), int(quantity),
                                                   float(limit_price),
                                                   float(stop_price),
                                                   (str(timeout_code)).lower())

        elif '$order_buy_crypto_limit_by_price ' in self.content:
            stock = self.content.replace('$order_buy_crypto_limit_by_price ',
                                         '').upper().split()
            symbol, amountInDollars, limit_price, timeout_code = stock
            print(str(symbol), float(amountInDollars), float(limit_price),
                  (str(timeout_code)).lower())
            confirmation = r.order_buy_crypto_limit_by_price(
                str(symbol), float(amountInDollars), float(limit_price),
                (str(timeout_code)).lower())

        elif '$order_buy_crypto_by_quantity ' in self.content:
            stock = self.content.replace('$order_buy_crypto_by_quantity ',
                                         '').upper().split()
            symbol, quantity, timeout_code = stock
            confirmation = r.order_buy_crypto_by_quantity(
                str(symbol), int(quantity), (str(timeout_code)).lower())

        elif '$order_sell_crypto_limit_by_price ' in self.content:
            stock = self.content.replace('$order_sell_crypto_limit_by_price ',
                                         '').upper().split()
            symbol, amountInDollars, limit_price, timeout_code = stock
            confirmation = r.order_sell_crypto_limit_by_price(
                str(symbol), float(amountInDollars), float(limit_price),
                (str(timeout_code)).lower())

        elif 'order_sell_crypto_limit ' in self.content:
            stock = self.content.replace('$order_buy_crypto_by_quantity ',
                                         '').upper().split()
            symbol, quantity, limit_price, timeout_code = stock
            confirmation = r.order_sell_crypto_limit(
                str(symbol), int(quantity), float(limit_price),
                (str(timeout_code)).lower())
        print(confirmation)
        message = order_information(symbol, quantity, buy_sell, limit_price,
                                    stop_price, timeout_code)

        if 'id' not in confirmation:
            message = create_simple_message(
                '❌ Order Failed - Details',
                [j for i, j in confirmation.items()])

        self.response.add_response(message)

        if len(self.response.response) == 0:
            self.response.set_error_response(0)
        self.response.done = True
Exemplo n.º 8
0
 async def run(self):
     message = create_simple_message("Suhanan", "Says Hello")
     self.response.add_response(message, True)
Exemplo n.º 9
0
    async def run(self):
        message = create_simple_message(
            'Stocks:', 'Gives a brief description of each stock command. ')
        message = create_simple_message(
            'Generic Order',
            '$order [SYMBOL] [QUANTITY] ["BUY" OR "SELL"] [LIMIT PRICE] [STOP PRICE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Market Buy',
            '$order_buy_market [SYMBOL] [QUANTITY] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Market Sell',
            '$order_sell_market [SYMBOL] [QUANTITY] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Limit Buy',
            '$order_buy_limit [SYMBOL] [QUANTITY] [LIMIT PRICE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Limit Sell',
            '$order_sell_limit [SYMBOL] [QUANTITY] [LIMIT PRICE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Stop Loss Buy',
            '$order_buy_stop_loss [SYMBOL] [QUANTITY] [STOP PRICE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Stop Loss Sell',
            '$order_sell_stop_loss [SYMBOL] [QUANTITY] [STOP PRICE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Trailing Stop Buy',
            '$order_buy_trailing_stop [SYMBOL] [QUANTITY] [TRAIL AMOUNT] [TRAIL TYPE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Trailing Stop Sell',
            '$order_sell_trailing_stop [SYMBOL] [QUANTITY] [TRAIL AMOUNT] [TRAIL TYPE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Stop Limit Sell',
            '$order_sell_stop_limit [SYMBOL] [QUANTITY] [LIMIT PRICE] [STOP PRICE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Notes:',
            'Timeout codes: gtc’ = good until cancelled.‘gfd’ = good for the day.‘ioc’ = immediate or cancel.‘opg’ execute at opening.\nTrailType: could be “amount” or “percentage"',
            embed=message)

        message = create_simple_message(
            '\nCrypto:',
            'Gives a brief description of each crypto command. ',
            embed=message)
        message = create_simple_message(
            'Buy Crypto Limit By Price',
            '$order_buy_crypto_limit_by_price [SYMBOL] [QUANTITY] [STOP PRICE] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Buy Crypto By Quantity',
            '$order_buy_crypto_by_quantity [SYMBOL] [QUANTITY] [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Sell Crypto Limit',
            '$order_sell_crypto_limit [SYMBOL] [QUANTITY] [LIMIT PRICE]  [TIMEOUT CODE]',
            embed=message)
        message = create_simple_message(
            'Sell Crypto Limit By Price',
            '$order_sell_crypto_limit [SYMBOL] [AMOUNT] [LIMIT PRICE]  [TIMEOUT CODE]',
            embed=message)

        self.response.set_state(True)
        self.response.add_response(message)

        if len(self.response.response) == 0:
            self.response.set_error_response(0)
        self.response.done = True
Exemplo n.º 10
0
 async def run(self):
     message = create_simple_message("Suhanan", "Says Hello")
     message = create_simple_message("AMZN", '$' + r.stocks.get_latest_price('Amzn')[0])
     self.response.add_response(message, True)