April 2019
Intermediate to advanced
426 pages
11h 13m
English
With a single VIX value calculated for a particular trading day, we can reuse the defined functions to calculate VIX values over a time period.
Let's write a function, process_file(), to process a single file path, and return the calculated VIX Index:
In [ ]: def process_file(filepath): """ Reads the filepath and calculates the VIX index. :param filepath: path the options chain file :return: VIX index value """ headers, calls_and_puts = read_file(filepath) dt_current = get_dt_current(headers) chain = generate_options_chain(calls_and_puts) (dt_near, dt_next) = find_option_terms(chain, dt_current) N_t1 = Decimal((dt_near-dt_current).total_seconds() // 60) N_t2 = Decimal((dt_next-dt_current).total_seconds() ...
Read now
Unlock full access