私は。。をしようとしています
1) ystockquote を使用して、株式の分単位のデータを csv ファイルに書き込むファイルを作成します。
2) 特定の時間から特定の終了時間まで開始します。
3) 毎分、get_price_time 関数からデータを書き込み、csv ファイルに保存します。
4) シンボル、start_specific_time、end_specific_time、ファイル名、datarate を入力として使用します。
5) ファイルを作成し、ファイルを閉じました。start_specific_time で csv ファイルを作成し、end_specific_time で csv ファイルを閉じます。
このすべてのスケジューラを作成する必要があります。私はスケジューラーで立ち往生しています.Hereは私のコードです
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