Python 2.7.11 |Anaconda 2.2.0 (64-bit)| (default, Dec 7 2015, 14:10:42) [MSC v.1500 64 bit (AMD64)]

Type "copyright", "credits" or "license" for more information.


IPython 1.0.0 -- An enhanced Interactive Python.

? -> Introduction and overview of IPython's features.

%quickref -> Quick reference.

help -> Python's own help system.

object? -> Details about 'object', use 'object??' for extra details.

%guiref -> A brief reference about the graphical user interface.


In [1]: import datetime as dt


In [2]: dates=[dt.datetime(2015,1,1),dt.datetime(2015,7,1),dt.datetime(2016,1,1)]


In [3]: (dates[1]-dates[0]).days/365

Out[3]: 0


In [4]: (dates[1]-dates[0]).days/365.

Out[4]: 0.4958904109589041


In [5]: (dates[2]-dates[1]).days/365.

Out[5]: 0.5041095890410959


In [6]: fractions=[0.0,0.5,1.0]


In [7]: runfile('C:/Users/zhuto/Documents/Python Scripts/dxlibrary/get_year_deltas.py', wdir='C:/Users/zhuto/Documents/Python Scripts/dxlibrary')


In [8]: import datetime as dt


In [9]: dates=[dt.datetime(2015,1,1),dt.datetime(2015,7,1),dt.datetime(2016,1,1)]


In [10]: get_year_deltas(dates)

Out[10]: array([ 0. , 0.49589041, 1. ])


In [11]: runfile('C:/Users/zhuto/Documents/Python Scripts/dxlibrary/constant_short_rate.py', wdir='C:/Users/zhuto/Documents/Python Scripts/dxlibrary')


In [12]: dates=[dt.datetime(2015,1,1),dt.datetime(2015,7,1),dt.datetime(2016,1,1)]


In [13]: from constant_short_rate import *


In [14]: csr=constant_short_rate('csr',0.05)


In [15]: csr.get_discount_factors(dates)

Traceback (most recent call last):


File "<ipython-input-15-6601a52e3a77>", line 1, in <module>

csr.get_discount_factors(dates)


AttributeError: 'constant_short_rate' object has no attribute 'get_discount_factors'



In [16]: runfile('C:/Users/zhuto/Documents/Python Scripts/dxlibrary/constant_short_rate.py', wdir='C:/Users/zhuto/Documents/Python Scripts/dxlibrary')

Reloaded modules: constant_short_rate, get_year_deltas


In [17]: csr.get_discount_factors(dates)

Traceback (most recent call last):


File "<ipython-input-17-6601a52e3a77>", line 1, in <module>

csr.get_discount_factors(dates)


AttributeError: 'constant_short_rate' object has no attribute 'get_discount_factors'



In [18]: csr=constant_short_rate('csr',0.05)


In [19]: csr.get_discount_factors(dates)

Out[19]:

array([[datetime.datetime(2015, 1, 1, 0, 0), 0.951229424500714],

[datetime.datetime(2015, 7, 1, 0, 0), 0.9755103387657228],

[datetime.datetime(2016, 1, 1, 0, 0), 1.0]], dtype=object)


In [20]: deltas=get_year_deltas(dates)


In [21]: deltas

Out[21]: array([ 0. , 0.49589041, 1. ])


In [22]: csr.get_discount_factors(deltas,dtobjects=False)

Out[22]:

array([[ 0. , 0.95122942],

[ 0.49589041, 0.97551034],

[ 1. , 1. ]])


In [23]: runfile('C:/Users/zhuto/Documents/Python Scripts/dxlibrary/market_envionment.py', wdir='C:/Users/zhuto/Documents/Python Scripts/dxlibrary')

Reloaded modules: get_year_deltas


In [24]: from market_environment import *

Traceback (most recent call last):


File "<ipython-input-24-8f97bc342eef>", line 1, in <module>

from market_environment import *


ImportError: No module named market_environment



In [25]: runfile('C:/Users/zhuto/Documents/Python Scripts/dxlibrary/market_envionment.py', wdir='C:/Users/zhuto/Documents/Python Scripts/dxlibrary')


In [26]: from market_environment import *

Traceback (most recent call last):


File "<ipython-input-26-8f97bc342eef>", line 1, in <module>

from market_environment import *


ImportError: No module named market_environment



In [27]: