我正在尝试
1)创建一个文件,通过ystockquote将分钟到分钟的数据写入csv文件中。
2)从特定的特定时间开始到特定的结束时间。
3)对于每一分钟,我从get_price_time函数写入数据并将其存储到csv文件中。
4)使用symbol,start_specific_time,end_specific_time,filename,datarate作为输入。
5)我创建了文件并关闭了文件。在start_specific_time创建一个csv文件,并在end_specific_time中关闭csv文件。
我需要为所有这些创建一个调度程序。我被调度员困在了。这是我的代码
import ystockquote
import sched, time
from sys import argv
script, symbol, start_specific_time, end_specific_time, filename, datarate = argv
def get_price_time(symbol):
price = ystockquote.get_price(symbol)
current_time = datetime.datetime.now()
return [symbol, price, current_time]
def create_file(filename):
return open(filename,'w')
def close_file(target):
target.close()
def write_data_to_file(target, data):
target.write(data[0])# first element of list which is symbol
target.write(",")
target.write(data[1])# 2nd element of list which is price
target.write(",")
target.write(str(data[2])) # 3rd element date which is string
target.write ("\n") # create new line
def create_scheduler