Gets a stock quote.

    Syntax: {command} [symbol]
    Powered by markit on demand (http://dev.markitondemand.com)
16793
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('stock', nargs='?', default=random_stock())
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    send(gen_stock(cmdargs.stock))
1177819
def quote(bot, mask, target, args):
    
    msg = ' '.join(args['<args>'])
    bot.log.info('quote> %r', msg)
    bot.send(msg)
925127
def get_command(self, ctx, cmd_name):
        """"""
        path = "%s.%s" % (__name__, cmd_name)
        path = path.replace("-", "_")
        module = importlib.import_module(path)
        return getattr(module, 'cli')
1039430
def get_stock_market(symbol='', string=False):
    """'"""
    assert isinstance(symbol, str), 'stock code need str type'

    if symbol.startswith(('sh', 'sz')):
        market = symbol[:2]

    if symbol.startswith(('50', '51', '60', '90', '110', '113', '132', '204')):
        market = 'sh'

    if symbol.startswith(
        ('00',
         '13',
         '18',
         '15',
         '16',
         '18',
         '20',
         '30',
         '39',
         '115',
         '1318')):
        market = 'sz'

    if symbol.startswith(('5', '6', '9', '7')):
        market = 'sh'

    if string is False:
        return 0 if market == 'sz' else 1

    return market
722652
def _example_get_market_snapshot(quote_ctx):
    
    ret_status, ret_data = quote_ctx.get_market_snapshot(["US.AAPL", "HK.00700"])
    if ret_status != ft.RET_OK:
        print(ret_data)
        exit()
    print("market_snapshot")
    print(ret_data)
528635
private Tick getLtpQuote(byte[] bin, int x, int dec1){
        Tick tick1 = new Tick();
        tick1.setMode(modeLTP);
        tick1.setTradable(true);
        tick1.setInstrumentToken(x);
        tick1.setLastTradedPrice(convertToDouble(getBytes(bin, 4, 8)) / dec1);
        return tick1;
    }
517808
def _getch():
    '''  '''
    import tty

    with TermStack() as fd:
        tty.setraw(fd)
        return sys.stdin.read(1)
1011394
function (quoteSmart, tagName) {
            var start, state, done, quote, ch, end, comment, mCursor = this.cursor, mPage = this.page;
            start = mCursor.position;
            state = 0;
            done = false;
            quote = '';
            comment = false;
            while (!done) {
                ch = mPage.getChar(mCursor);
                switch (state) {
                case 0:
                    // prior to ETAGO
                    switch (ch) {
                    case -1:
                        done = true;
                        break;
                    case '\'':
                        if (quoteSmart && !comment) {
                            if ('' === quote) {
                                quote = '\'';    // enter quoted state
                            } else // enter quoted state
                            if ('\'' === quote) {
                                quote = '';    // exit quoted state
                            }
                        }
                        // exit quoted state
                        break;
                    case '"':
                        if (quoteSmart && !comment) {
                            if ('' === quote) {
                                quote = '"';    // enter quoted state
                            } else // enter quoted state
                            if ('"' === quote) {
                                quote = '';    // exit quoted state
                            }
                        }
                        // exit quoted state
                        break;
                    case '\\':
                        if (quoteSmart) {
                            if ('' !== quote) {
                                ch = mPage.getChar(mCursor);    // try to consume escaped character
                                // try to consume escaped character
                                if (NEGATIVE_1 === ch) {
                                    done = true;
                                } else if (ch !== '\\' && ch !== quote) {
                                    // unconsume char if character was not an escapable char.
                                    mPage.ungetChar(mCursor);
                                }
                            }
                        }
                        break;
                    case '/':
                        if (quoteSmart) {
                            if ('' === quote) {
                                // handle multiline and double slash comments (with a quote)
                                ch = mPage.getChar(mCursor);
                                if (NEGATIVE_1 === ch) {
                                    done = true;
                                } else if ('/' === ch) {
                                    comment = true;
                                } else if ('*' === ch) {
                                    do {
                                        do {
                                            ch = mPage.getChar(mCursor);
                                        } while (NEGATIVE_1 !== ch && '*' !== ch);
                                        ch = mPage.getChar(mCursor);
                                        if (ch === '*') {
                                            mPage.ungetChar(mCursor);
                                        }
                                    } while (NEGATIVE_1 !== ch && '/' !== ch);
                                } else {
                                    mPage.ungetChar(mCursor);
                                }
                            }
                        }
                        break;
                    case '\n':
                        comment = false;
                        break;
                    case '<':
                        if (quoteSmart) {
                            if ('' === quote) {
                                state = 1;
                            }
                        } else {
                            state = 1;
                        }
                        break;
                    default:
                        break;
                    }
                    break;
                case 1:
                    // <
                    switch (ch) {
                    case -1:
                        done = true;
                        break;
                    case '/':
                        // tagName = 'textarea'
                        // <textarea><div></div></textarea>
                        /*
                             8.1.2.6 Restrictions on the contents of raw text and RCDATA elements

                             The text in raw text and RCDATA elements must not contain any occurrences
                             of the string '</' (U+003C LESS-THAN SIGN, U+002F SOLIDUS)
                             followed by characters that case-insensitively match the tag name of the element
                             followed by one of U+0009 CHARACTER TABULATION (tab),
                             U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR),
                             U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or U+002F SOLIDUS (/).
                             */
                        if (!tagName || mPage.getText(mCursor.position, mCursor.position + tagName.length) === tagName && !mPage.getText(mCursor.position + tagName.length, mCursor.position + tagName.length + 1).match(/\w/)) {
                            state = 2;
                        } else {
                            state = 0;
                        }
                        break;
                    case '!':
                        ch = mPage.getChar(mCursor);
                        if (NEGATIVE_1 === ch) {
                            done = true;
                        } else if ('-' === ch) {
                            ch = mPage.getChar(mCursor);
                            if (NEGATIVE_1 === ch) {
                                done = true;
                            } else if ('-' === ch) {
                                state = 3;
                            } else {
                                state = 0;
                            }
                        } else {
                            state = 0;
                        }
                        break;
                    default:
                        state = 0;
                        break;
                    }
                    break;
                case 2:
                    // </
                    comment = false;
                    if (NEGATIVE_1 === ch) {
                        done = true;
                    } else if (Utils.isLetter(ch)) {
                        // 严格 parser 遇到 </x lexer 立即结束
                        // 浏览器实现更复杂点，可能 lexer 和 parser 混合了
                        done = true;    // back up to the start of ETAGO
                        // back up to the start of ETAGO
                        mPage.ungetChar(mCursor);
                        mPage.ungetChar(mCursor);
                        mPage.ungetChar(mCursor);
                    } else {
                        state = 0;
                    }
                    break;
                case 3:
                    // <!
                    comment = false;
                    if (NEGATIVE_1 === ch) {
                        done = true;
                    } else if ('-' === ch) {
                        ch = mPage.getChar(mCursor);
                        if (NEGATIVE_1 === ch) {
                            done = true;
                        } else if ('-' === ch) {
                            ch = mPage.getChar(mCursor);
                            if (NEGATIVE_1 === ch) {
                                done = true;
                            } else if ('>' === ch) {
                                // <!----> <!-->
                                state = 0;
                            } else {
                                // retreat twice , still begin to check -->
                                mPage.ungetChar(mCursor);
                                mPage.ungetChar(mCursor);
                            }
                        } else {
                            // retreat once , still begin to check
                            mPage.ungetChar(mCursor);
                        }
                    }    // eat comment
                    // eat comment
                    break;
                default:
                    throw new Error('unexpected ' + state);
                }
            }
            end = mCursor.position;
            return this.makeCData(start, end);
        }
219332
def get_ticker(self):
        ''''''
        lastQuote = self.data['quote'][-1]
        lastTrade = self.data['trade'][-1]
        ticker = {
            "last": lastTrade['price'],
            "buy": lastQuote['bidPrice'],
            "sell": lastQuote['askPrice'],
            "mid": (float(lastQuote['bidPrice'] or 0) + float(lastQuote['askPrice'] or 0)) / 2
        }

        # The instrument has a tickSize. Use it to round values.
        instrument = self.data['instrument'][0]
        return {k: round(float(v or 0), instrument['tickLog']) for k, v in list(ticker.items())}
393651
function queryCommandValue(command) {
        var func;

        if (editor.quirks.isHidden() || editor.removed) {
          return;
        }

        command = command.toLowerCase();
        if ((func = commands.value[command])) {
          return func(command);
        }

        // Browser commands
        try {
          return editor.getDoc().queryCommandValue(command);
        } catch (ex) {
          // Fails sometimes see bug: 1896577
        }
      }
238527
async function getHelpContents(args, output) {
    if ('!' in args) {
        return getAllCommands(process.stdout);
    }

    if (args._.length == 0) {
        return getGeneralHelpContents(output);
    }
    else if (args._.length == 1) {
        return getVerbHelp(args._[0], output);
    } else if (args._.length >= 2) {
        const operation = getOperation(args._[0], args._[1]);
        if (operation) {
            output.write(`${operation.description}\n\n`);
            output.write(`Usage:\n${chalk.cyan.bold(operation.command)}\n\n`);
            return getHelpContentsForOperation(operation, output);
        } else {
            return getVerbHelp(args._[0], output);
        }
    }

    return getGeneralHelpContents(output);
}
455176
function tokenString(quote, f) {
    return function(stream, state) {
      var ch;

      if(isInString(state) && stream.current() == quote) {
        popStateStack(state);
        if(f) state.tokenize = f;
        return ret("string", "string");
      }

      pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });

      // if we're in a string and in an XML block, allow an embedded code block
      if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
        state.tokenize = tokenBase;
        return ret("string", "string"); 
      }

      
      while (ch = stream.next()) {
        if (ch ==  quote) {
          popStateStack(state);
          if(f) state.tokenize = f;
          break;
        }
        else {
          // if we're in a string and in an XML block, allow an embedded code block in an attribute
          if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
            state.tokenize = tokenBase;
            return ret("string", "string"); 
          }

        }
      }
      
      return ret("string", "string");
    };
  }
1205502
async function getHelpContents(args, output) {
    if ('!' in args) {
        return getAllCommands(output);
    }

    if (args._.length == 0) {
        return getGeneralHelpContents(output);
    }
    else if (args._.length == 1) {
        return getVerbHelp(args._[0], output);
    } else if (args._.length >= 2) {
        const serviceManifest = getServiceManifest(args);
        if (serviceManifest) {
            const { operation } = serviceManifest;

            output.write(`${operation.description}\n\n`);
            output.write(`Usage:\n${chalk.cyan.bold(operation.command)}\n\n`);
        } else {
            return getVerbHelp(args._[0], output);
        }
    }

    const serviceManifest = getServiceManifest(args);
    if (serviceManifest) {
        return getHelpContentsForService(serviceManifest, output);
    }

    return getGeneralHelpContents(output);
}
896516
def info(self):
        
        url = "{}/v7/finance/quote?symbols={}".format(
            self._base_url, self.ticker)
        r = _requests.get(url=url).json()["quoteResponse"]["result"]
        if len(r) > 0:
            return r[0]
        return {}
1252460
function quoteIdent(value) {

    if (value === undefined || value === null) {
        throw new Error('SQL identifier cannot be null or undefined');
    } else if (value === false) {
        return '"f"';
    } else if (value === true) {
        return '"t"';
    } else if (value instanceof Date) {
        return '"' + formatDate(value.toISOString()) + '"';
    } else if (value instanceof Buffer) {
        throw new Error('SQL identifier cannot be a buffer');
    } else if (Array.isArray(value) === true) {
        var temp = [];
        for (var i = 0; i < value.length; i++) {
            if (Array.isArray(value[i]) === true) {
                throw new Error('Nested array to grouped list conversion is not supported for SQL identifier');
            } else {
                temp.push(quoteIdent(value[i]));
            }
        }
        return temp.toString();
    } else if (value === Object(value)) {
        throw new Error('SQL identifier cannot be an object');
    }

    var ident = value.toString().slice(0); // create copy

    // do not quote a valid, unquoted identifier
    if (/^[a-z_][a-z0-9_$]*$/.test(ident) === true && isReserved(ident) === false) {
        return ident;
    }

    var quoted = '"';

    for (var i = 0; i < ident.length; i++) {
        var c = ident[i];
        if (c === '"') {
            quoted += c + c;
        } else {
            quoted += c;
        }
    }

    quoted += '"';

    return quoted;
}
81249
def token_cli(self, eauth, load):
        '''
        
        '''
        load['cmd'] = 'mk_token'
        load['eauth'] = eauth
        tdata = self._send_token_request(load)
        if 'token' not in tdata:
            return tdata
        try:
            with salt.utils.files.set_umask(0o177):
                with salt.utils.files.fopen(self.opts['token_file'], 'w+') as fp_:
                    fp_.write(tdata['token'])
        except (IOError, OSError):
            pass
        return tdata
460196
def stock2one(stock):
    
    lines = {}
    for line in stock:
        line = line.strip()
        if print_line(line) is True:
            yield line
            continue
        if line.startswith('//'):
            continue
        ID, seq = line.rsplit(' ', 1)
        if ID not in lines:
            lines[ID] = ''
        else:
            # remove preceding white space
            seq = seq.strip()
        lines[ID] += seq
    for ID, line in lines.items():
        yield '\t'.join([ID, line])
    yield '\n//'