stock

Posted xiaodebing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了stock相关的知识,希望对你有一定的参考价值。

技术分享图片
import requests
import logging
import logging.config
import random
import os
import yaml

class Observer(object):
    open_price_last_1 = ‘‘
    close_price_last_1 = ‘‘
    highest_price_last_1 = ‘‘
    minimum_price_last_1 = ‘‘
    ding_fen_xing = []
    di_fen_xing = []
    not_ding_di = []

    def __init__(self):
        path = logging.yaml
        value = os.getenv(LOG_CFG, None)
        if value:
            path = value
        if os.path.exists(path):
            with open(path, "r") as f:
                config = yaml.load(f)
                logging.config.dictConfig(config)
        else:
            print(log config file not found!)

    def get_stock_data(self,stock_code,scale):
        #url = ‘http://ifzq.gtimg.cn/appstock/app/kline/mkline?param=sh600030,m30,,320&_var=m30_today&r=0.1700474168906776‘
        url = http://ifzq.gtimg.cn/appstock/app/kline/mkline
        headers = {User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/70.0.3538.77 Safari/537.36}
        params = {
            param:  {},m{},,320.format(stock_code,scale),
            _var: m{}_today.format(scale),
            r: 0.1700474{}.format("".join(random.choice("0123456789") for i in range(10)))
        }
        logging.info(url:%s 	 params:%s,url,params)
        res = requests.get(url,params=params,headers=headers)
        logging.info(res.text)

    def get_stock_code(self,a_type):
        #url = ‘http://stock.gtimg.cn/data/index.php?appn=rank&t=rankash/chr&p=1&o=0&l=40&v=list_data‘
        url = http://stock.gtimg.cn/data/index.php
        headers = { User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36}
        params = {
            appn: rank,
            t: ranka{}/chr.format(a_type),
            p: 1,
            o: 0,
            l: 3000,
            v: list_data
        }
        logging.info(url:%s 	 params:%s, url, params)
        res = requests.get(url, params=params, headers=headers)
        logging.info(res.text)

if __name__ == __main__:
    o = Observer()
    #o.get_stock_data(‘sh600030‘,‘30‘)
    o.get_stock_code(sh)
    o.get_stock_code(sz)
View Code

 

以上是关于stock的主要内容,如果未能解决你的问题,请参考以下文章

失败:语义异常 [错误 10014]:第 1:21 行错误的参数“stock_price_high”:

最强解析面试题:best-time-to-buy-and-sell-stock

leetcode901. Online Stock Span

最强解析面试题:best-time-to-buy-and-sell-stock

POJ 3903 Stock Exchange LIS

Leetcode121. Best Time to Buy and Sell Stock