<s> import datetime as dt <EOL> import csv <EOL> import copy <EOL> import os <EOL> import pickle <EOL> import math <EOL> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> import pandas as pd <EOL> from QSTK . qstkutil import qsdateutil as du <EOL> def write ( ls_symbols , d_data , ldt_timestamps ) : <EOL> ldt_timestamps . reverse ( ) <EOL> ls_keys = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> length = len ( ldt_timestamps ) <EOL> for symbol in ls_symbols : <EOL> sym_file = open ( '<STR_LIT>' + symbol + '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> sym_file . write ( "<STR_LIT>" ) <EOL> for i , date in enumerate ( ldt_timestamps ) : <EOL> date_to_csv = '<STR_LIT>' . format ( date ) <EOL> string_to_csv = date_to_csv <EOL> for key in ls_keys : <EOL> string_to_csv = string_to_csv + '<STR_LIT:U+002C>' + str ( d_data [ symbol ] [ length - i - <NUM_LIT:1> ] ) <EOL> string_to_csv = string_to_csv + '<STR_LIT:\n>' <EOL> sym_file . write ( string_to_csv ) <EOL> def main ( ) : <EOL> print "<STR_LIT>" <EOL> dt_start = dt . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> dt_end = dt . datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> ) <EOL> ldt_timestamps = du . getNYSEdays ( dt_start , dt_end , dt . timedelta ( hours = <NUM_LIT:16> ) ) <EOL> x = np . array ( range ( len ( ldt_timestamps ) ) ) <EOL> ls_symbols = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> sine_fast = <NUM_LIT:10> * np . sin ( x / <NUM_LIT> ) + <NUM_LIT:100> <EOL> sine_slow = <NUM_LIT:10> * np . sin ( x / <NUM_LIT> ) + <NUM_LIT:100> <EOL> sine_fast_noise = <NUM_LIT:10> * ( np . sin ( x / <NUM_LIT> ) + np . random . randn ( x . size ) ) + <NUM_LIT:100> <EOL> sine_slow_noise = <NUM_LIT:10> * ( np . sin ( x / <NUM_LIT> ) + np . random . randn ( x . size ) ) + <NUM_LIT:100> <EOL> d_data = dict ( zip ( ls_symbols , [ sine_fast , sine_slow , sine_fast_noise , sine_slow_noise ] ) ) <EOL> write ( ls_symbols , d_data , ldt_timestamps ) <EOL> plt . clf ( ) <EOL> plt . plot ( ldt_timestamps , sine_fast ) <EOL> plt . plot ( ldt_timestamps , sine_slow ) <EOL> plt . plot ( ldt_timestamps , sine_fast_noise ) <EOL> plt . plot ( ldt_timestamps , sine_slow_noise ) <EOL> plt . ylim ( <NUM_LIT:50> , <NUM_LIT> ) <EOL> plt . xticks ( size = '<STR_LIT>' ) <EOL> plt . legend ( ls_symbols , loc = '<STR_LIT>' ) <EOL> plt . savefig ( '<STR_LIT>' , format = '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
