Python for Finance: Analyze Big Financial Data

(Elle) #1
Figure 13-6. Screenshot of traits GUI with updating (empty)

Figure 13-7 illustrates what happens with this new GUI “in action.” Providing values for


the object attributes and pushing the Update button returns the calculated discount factors


— this time within the GUI window.


The following Python code shows step-by-step the equivalent operations without a GUI.


First, the assigning of values to the attributes:


In  [ 84 ]: sr.name =   ‘sr_class’
sr.rate = 0.05
sr.time_list = np.array(([0.0, 0.5, 1.0, 1.5, 2.0],), dtype=np.float32)

Second, the update of the list object containing the discount factors:


In  [ 85 ]: sr._update_fired()

Figure 13-7. Screenshot of traits GUI with updating (after update)

Finally, the output of the calculated/updated list with the discount factors:

Free download pdf