搞定了日线数据 - Jacky Liu's Blog

搞定了日线数据

Jacky Liu posted @ 2010年10月13日 12:46 in Python with tags python 股票 日线 , 5562 阅读

    ---- 新添了下载任务,来源是新浪财经,现在可以扒下来日线数据了

    ---- 过程中的几个要点:

    1. Nested List Comprehension:
   
    由分别为 m 项和 n 项的两个 list 生成一个 m×n 项的 list:

mylist= ['a', 'b', 'c']
print([s * n for n in range(1, 4) for s in mylist])
print([s * n for s in mylist for n in range(1, 4)])

    这段代码的输出是:

        ['a', 'b', 'c', 'aa', 'bb', 'cc', 'aaa', 'bbb', 'ccc']
        ['a', 'aa', 'aaa', 'b', 'bb', 'bbb', 'c', 'cc', 'ccc']

    2. lambda 函数的应用:

ptn_option= r'<option\s+value\s*=\s*"\d{4}"'		# 用来提取 '<option value="2010"' 这一部分
allyears= list(map(lambda s: re.search(r'\d{4}', s).group(0), re.findall(ptn_option, tagselect)))

    其中 tagselect 是 hmtl 页面源文件中的一个 "select" element,里面包含多个 "option" element,格式是:'<option value="2010">'
    上面那一段可以把所有 option 的值,也就是年份提取出来。

    3. 下载的时候不能 "扒太快"。往任务队列添加任务需要有一定延迟。如果没有设延迟,新浪服务器会隔段时间不理你。

    ---- 接下来准备建数据库,然后跑些简单的分析,事情开始慢慢变得有趣 。。。

    ---- 另外要记一下,网上有个叫 Andy 的达人,在实时行情上面下了功夫:

        太好了! 终于搞定了股票实时行情解决方案

        实时股票数据接口大全

    自己的目标是先从历史数据,静态分析入手,慢慢培养感觉。但是,对于实时行情相关的技术,也要保持关注。
 

Avatar_small
run 3 说:
2018年8月24日 15:20

谢谢。 你帮我把它弄清楚了!

Avatar_small
f88tw 说:
2021年4月25日 18:21

敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. f88tw粗工粗工内容 粗工粗工内容 |墓园|捡骨流程|捡骨费用|捡骨时间|禁忌|捡骨颜色|捡骨师|新竹|时间|台北|桃园|苗栗|头份|https://mypaper.m.pchome.com.tw/f88tw

Avatar_small
carpet cleaning duba 说:
2021年8月31日 20:18

Most companies do not start to see the necessity regarding hiring specialist office washing services. Nonetheless, professional business office cleaners can easily clean your working environment and offer it with all the deep cleaning it needs. Our purifiers will carefully scrub and also dust your working environment until that sparkles clear. Our washing tools are usually powerful and noteworthy. We provides your office a specialist makeover simply by removing staining from floors, eliminating airborne dirt and dust build-up, and also by eradicating cobwebs. By keeping your working environment clean, you're not only ensuring medical and well-being regarding its residents,

Avatar_small
maid agency dubai 说:
2021年11月15日 23:19

Sometimes maids are actually remembered only for the duration of house vacuuming service and / or for vacuuming upholstery and / or backyard vacuuming. But wounded passengers any residential renovation give good results done, to fix up typically the mess maids role really shines quite effortless. No situation how excited if you find yourself about the ultra-modern renovations on your property, it's hard to last excited any time you see typically the mess it is left in the home.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee