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

搞定了日线数据

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

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

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

    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.

Avatar_small
Emma 说:
2023年2月01日 20:29

Great news! We now have access to the daily data from Sina Finance, which will certainly be a great resource for us. With this new task, we can use Nested List diamond rings Comprehension to generate a list of m×n items from two lists of m items and n items respectively. This addition is sure to be an invaluable asset for our work.

Avatar_small
anonymous 说:
2023年8月22日 00:11

I understand this column. I realize You put a many of struggle to found this story. I admire your process. Kissimmee Exterminator

Avatar_small
anonymous 说:
2023年8月28日 15:27

I am always searching online for storys that can accommodate me. There is obviously a multiple to understand about this. I feel you made few salubrious points in Attributes moreover. Detain busy, awesome career! Orlando Exterminator

Avatar_small
anonymous 说:
2023年8月28日 15:29

This is important, though it's necessary to help you head over to it weblink: Oviedo Exterminator

Avatar_small
anonymous 说:
2023年9月15日 21:01

I wrote about a similar issue, I give you the link to my site.  Western Store near Me

Avatar_small
anonymous 说:
2023年9月19日 20:16

I read this article. I think You put a great deal of exertion to make this article. I like your work.  Trouver un acupuncteur à Montreux Vevey Territet Chardonne Saint-Legier Villeneuve Chatel-Saint-Denis

Avatar_small
anonymous 说:
2023年9月22日 22:13

Beaver says I also have such interest, you can read my profile here:  hallmarknews

Avatar_small
anonymous 说:
2023年9月23日 19:32

wow this saintly however ,I love your enter plus nice pics might be part personss negative love being defrent mind total poeple , schwarzkümmel

Avatar_small
monthly cleaning ser 说:
2023年10月06日 20:04

Were living in the age while life can be running ahead speed. The competition can be so tough that men and women work all day and x 7 so as to protect his or her position. Their time can be spent to produce plans along with presentations, meeting clientele and looking to reach rigorous deadlines. Therefore the house chores are generally either quit incomplete or maybe not accomplished.

Avatar_small
anonymous 说:
2023年10月14日 03:04

Welcome to Therapy Trainings! We understand the economic challenges many new graduates face after completing their degree program.That's why we offer Free CEs, NAADAC Code of Ethics and Free CEUsfor Social Workers. As a new grad within the last six months, you'll receive unlimited CE access for a year, absolutely free!

Avatar_small
jnanabhumiap.in 说:
2024年1月20日 14:57

JNANABHUMI AP provides all latest educational updates and many more. The main concept or our aim behind this website has been the will to provide resources full information on each topic which can be accessed through Internet. To ensure that every readers get’s what important and worthy about the topic they search and link to hear from us. jnanabhumiap.in Jnanabhumi AP is a startup by passionate webmasters and bloggers who have passion to provide engaging content which is accurate, interesting and worthy to read. We are mope like a web community where you can find different information’s, resources, topics on day to day incidents or news. We provide you the finest of web content on each and every topics possible with help of editorial and content team.


登录 *


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