How to pass an fix length array to a c function
Parameters including : Total balance , Attach point, mortgage rate , Tranche Rate, Payment term and Prepayment CPR .
Cash Flow Chart result:
Full code(2 functions):
Label( self.update_frame, text="CPR" ).grid( row = 0, column= 0 )
w = Scale( self.update_frame, from_=0.01, to=0.20, resolution = 0.005, orient=HORIZONTAL, variable=self.rmbs_cpr, showvalue = True )
w.grid(row = Read more [...]
When story begins
In Python , there is a shortcut in conditional checking, I didn't take much care about the difference of below form of conditional syntax :
if var :
if var is not None :
if var != None:
Explanation behind the scene is an analogy to difference of an empty string "" and NULL in a database . "" is an empty string but means something, NULL is nothing means nothing . In Python world , None equals NULL in Database , that's why "" == Read more [...]
When Dynamic Type comes to Trouble
As a dynamic programming languages , Python don't have a type on variables , as well as a arguments . This feature save us a lot workload and it enable us to focus on logical of program .
def add(x, y):
print add(5.0, 6)
Above function is straightforward and works fine if x and y are passed with int/ float/ string .
But things may Read more [...]
Original blog post wrote by Brian Holdefehr. This is a Chinese version of original post .
本文原文作者 Brian Holdefehr。若有不足，敬请斧正。
装饰器(Decorators) 是Python众多强大特性之一。装饰器除了本身编程语法上的作用之外，另外提供了一种有趣思维方式——"函数化"思维(a functional way)
我会从头开始介绍介绍装饰器的工作原理，接着会介绍几个必须了解的基本概念。之后，我们会详细深入探索一些装饰器实例以及其工作方式。最后我们会讨论一些装饰器的高阶应用，例如参数化装饰器(optional Read more [...]
Difference against Google Finance / Sina.com
Yahoo provide more rich function regarding to the Stock API than Google / Sina.com does. particular ,it provide customize return format which customized by supply a parameter in calling URL . Full parameter specification pls refer to this link .(credit to Kelly Elias ) .
200 calls per second , you will be warned if you exceed this limits
csv file returned
No market depth as SIna.com provide
Provide stock indication such as " Earnings Read more [...]
Google has officially announce that it won't sustain ongoing of Finance API, but there still a available API via URL API . Return data from web server is xml format . We need to parse the return text in Python and extract data .
Get the Stock Data
Google Web API format ( http://www.google.com/ig/api?stock=C ) , this will request market data for security code "C" ( Citigroup :) ) xml return result:
<finance module_id="0" Read more [...]
Although articles have been written about calling security quote API of Sina.com . I'd like to take a dive into it via Python and try to setup a OO implementation. Sina.com API will offer 5-th market depth prices of Chinese Shanghai / Shenzhen Exchange Stock in real time style .
calling Sina.com Stock API can be straightforward , just type "http://hq.sinajs.cn/list=sh601012" in browser address . call back will shown as below ( click to enlarge ):
Cracking Read more [...]
A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.
Find the value of d
1000 for which 1/d contains Read more [...]
The following iterative sequence is defined for the set of positive integers:
n/2 (n is even)
3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
It can be seen that this sequence (starting at 13 and finishing Read more [...]