When you have high-frequency data, you cannot use Excel to visualize the data due to the high number of observations. On the follwing, we will see that importing high-frequency data into a Jupyter Notebook using Stata allows you to visualize the data without the line limit of Excel.
import stata_setup
stata_setup.config('C:\Program Files\Stata18/', 'se')
___ ____ ____ ____ ____ ® /__ / ____/ / ____/ 18.0 ___/ / /___/ / /___/ SE—Standard Edition Statistics and Data Science Copyright 1985-2023 StataCorp LLC StataCorp 4905 Lakeway Drive College Station, Texas 77845 USA 800-STATA-PC https://www.stata.com 979-696-4600 stata@stata.com Stata license: Single-user perpetual Serial number: 401806202105 Licensed to: Jamel Saadaoui University of Strasbourg Notes: 1. Unicode is supported; see help unicode_advice. 2. Maximum number of variables is set to 5,000 but can be increased; see help set_maxvar.
%%stata
*set scheme stcolor
cd "C:\Users\jamel\OneDrive\PROJECTS\22-11-hfd-causality"
cd "OneDrive_2022-11-05\Gazi and HFD\HFD-commodities\Project 1_Energy"
**# CL (Crude Oil WTI) Continuous futures
import delimited CL_continuous_adjusted_5min.txt, clear
rename v1 DateTime
rename v2 Open
rename v3 High
rename v4 Low
rename v5 Close
rename v6 Volume
. . set scheme stcolor . . cd "C:\Users\jamel\OneDrive\PROJECTS\22-11-hfd-causality" C:\Users\jamel\OneDrive\PROJECTS\22-11-hfd-causality . cd "OneDrive_2022-11-05\Gazi and HFD\HFD-commodities\Project 1_Energy" C:\Users\jamel\OneDrive\PROJECTS\22-11-hfd-causality\OneDrive_2022-11-05\Gazi a > nd HFD\HFD-commodities\Project 1_Energy . . **# CL (Crude Oil WTI) Continuous futures . . import delimited CL_continuous_adjusted_5min.txt, clear (encoding automatically selected: UTF-8) (6 vars, 1,094,456 obs) . . rename v1 DateTime . rename v2 Open . rename v3 High . rename v4 Low . rename v5 Close . rename v6 Volume .
%%stata
gen double date = clock(DateTime, "YMDhms")
gen double date2 = clock(DateTime, "YMDhms")
format %100.0g date2
format %tc date
tsset date
. . gen double date = clock(DateTime, "YMDhms") . . gen double date2 = clock(DateTime, "YMDhms") . . format %100.0g date2 . . format %tc date . . tsset date Time variable: date, 19sep2006 03:45:00 to 27may2022 16:55:00, but with gaps Delta: .001 seconds .
Because %tc values can be so large, whenever you use the function clock(), you must store the results in a double, as we do below: https://www.stata.com/manuals13/u24.pdf
%%stata
tsline Close, ///
title("CL (Crude Oil WTI) Continuous futures") ///
ylabel(, angle(vertical)) tlabel(, grid) xsize(9) ///
xlabel(1501646400000(116910750000)1969289400000, ///
labsize(small) angle(horizontal)) graphregion(margin(l+10 r+15))
. tsline Close, /// > title("CL (Crude Oil WTI) Continuous futures") /// > ylabel(, angle(vertical)) tlabel(, grid) xsize(9) /// > xlabel(1501646400000(116910750000)1969289400000, /// > labsize(small) angle(horizontal)) graphregion(margin(l+10 r+15)) .