DEPRECATED: Renamed ``get_relevant_stocks``
760321
def get_relevant(self, **kwargs):
        
        import warnings
        warnings.warn("get_relevant has been renamed get_relevant_stocks "
                      "and will be deprecated in v0.4.1")
        return self._get_endpoint("relevant", params=kwargs)
315974
def mkCuttingStock(s):
    """"""
    w,q = [],[]   # list of different widths (sizes) of items, their quantities
    for item in sorted(s):
        if w == [] or item != w[-1]:
            w.append(item)
            q.append(1)
        else:
            q[-1] += 1
    return w,q
809348
def Task_display(self):
    
    re = """%(stock_name)s %(stock_no)s %(stock_date)s
Today: %(stock_price)s %(stock_range)s
=-=-=-=""" % {
        'stock_name': unicode(self.stock_name),
        'stock_no': unicode(self.stock_no),
        'stock_date': unicode(self.data_date[-1]),
        'stock_price': unicode(self.raw_data[-1]),
        'stock_range': unicode(self.stock_range[-1]),
      }
    return re
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
1344302
def relevant_items(df):
    
    start_date = datetime(2013, 1, 1)

    df['DataProjeto'] = pd.to_datetime(df['DataProjeto'])

    # get only projects newer than start_date
    # and items with price > 0
    df = df[df.DataProjeto >= start_date]
    df = df[df.VlUnitarioAprovado > 0.0]

    return df
659396
def allck():
  '''  '''
  for i in twseno().allstockno:
    a = goristock.goristock(i)
    try:
      if a.stock_vol[-1] > 1000*1000 and a.raw_data[-1] > 10:
        #a.goback(3) ## 倒退天數
        ck4m(a)
    except:
      pass
946908
def __getCashToBuyStock(self):
        '''  '''
        account=self.__strategy.getAccountCopy()

        if (account.buyingPower >= account.getTotalValue() / self.__buyingRatio):
            return account.getTotalValue() / self.__buyingRatio
        else:
            return 0
356750
def __getCashToBuyStock(self):
        '''  '''
        account=self.__strategy.getAccountCopy()
        if (account.getCash() >= account.getTotalValue() / self.buying_ratio):
            return account.getTotalValue() / self.buying_ratio
        else:
            return 0
1154662
def orderbook_for_stock(self, stock):
        
        url_fragment = 'venues/{venue}/stocks/{stock}'.format(
            venue=self.venue,
            stock=stock,
        )
        url = urljoin(self.base_url, url_fragment)
        return self.session.get(url).json()
1342861
def __loadindcomps(self):
        '''  '''
        csv_path = os.path.join(os.path.dirname(__file__), self.stock_no_files)
        with open(csv_path) as csv_file:
            csv_data = csv.reader(csv_file)
            result = {}
            check_words = re.compile(r'^[\d]{2,}[\w]?')
            for i in csv_data:
                if check_words.match(i[2]):
                    try:
                        result[i[2]].append(i[0].decode('utf-8'))
                    except (ValueError, KeyError):
                        try:
                            result[i[2]] = [i[0].decode('utf-8')]
                        except KeyError:
                            pass
            return result
151297
def Rt_display(stock_no):
  
  a = twsk(stock_no).real
  if a:
    re = "{%(time)s} %(stock_no)s %(c)s %(range)+.2f(%(pp)+.2f%%) %(value)s" % {
        'stock_no': stock_no,
        'time': a['time'],
        'c': a['c'],
        'range': covstr(a['range']),
        'value': a['value'],
        'pp': covstr(a['pp'])
      }
    return re
  else:
    return a
626224
def fetch_trades_since(self, since: int) -> List[Trade]:
        """"""
        return self._fetch_since('trades', self.market.code)(self._trades_since)(since)
634261
def QA_fetch_stock_terminated(collections=DATABASE.stock_terminated):
    ''
    # 🛠todo  转变成 dataframe 类型数据
    return pd.DataFrame([item for item in collections.find()]).drop('_id', axis=1, inplace=False).set_index('code', drop=False)
644672
function getRichName(metaInfo) {
    if (metaInfo.deprecatedFrom) {
        return getDeprecatedTemplate()
            .replace(/\$version/g, metaInfo.deprecatedFrom)
            .replace(/\$replacement/g, metaInfo.replacement)
            .replace(/\$name/g, metaInfo.name);
    } else {
        return metaInfo.name;
    }
}
1234591
def _from_deprecated_son(cls, id_dict, run):
        """"""
        cls._deprecation_warning()
        return BlockUsageLocator._from_deprecated_son(id_dict, run)
690436
def load_stock_quantity(self):
        
        info = StocksInfo(self.config)
        for stock in self.model.stocks:
            stock.quantity = info.load_stock_quantity(stock.symbol)
        info.gc_book.close()
162472
def aggregated_relevant_items(raw_df):
    
    df = (
        raw_df[['idSegmento', 'idPlanilhaItens', 'VlUnitarioAprovado']]
        .groupby(by=['idSegmento', 'idPlanilhaItens'])
        .agg([np.mean, lambda x: np.std(x, ddof=0)])
    )
    df.columns = df.columns.droplevel(0)
    return (
        df
        .rename(columns={'<lambda>': 'std'})
    )