自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(74)
  • 收藏
  • 关注

原创 adjacent_find

Protype of function is template ForwardIterator adjacent_find( ForwardIterator _First, ForwardIterator _Last );template ForwardIterator adjacent_find( ForwardIterat

2015-07-05 19:34:55 544

原创 STL Application 1

(1) class hierarchy(2) polymorphism, pointer of base class(3) function object#include #include #include using namespace std;class Shape{public: virtual void Draw() = 0; virtua

2015-06-30 19:35:41 352

转载 一个故事告诉你什么是分级基金

从2007年分级基金问世开始,就一直受到投资者广泛关注。分级基金的价格市场波动强,经常在几个交易日内爆发性的上涨百分之几十,也可能一周内下跌20%。作为一种基金的创新品种,很多朋友可能都对分级基金不了解,或者是有知道一点点,但是对分级基金的杠杆系数、稳健份额、进取份额、母基金、溢价折价等概念不甚理解。今天,我就通过一个简单的故事来带你去了解一下什么叫分级基金。为了帮助大家的理解,先举一个杠杆系数为

2015-06-26 12:00:23 527

转载 大浪淘金——下半年经济与资本市场展望(姜超6月25日于海通深圳策略会)

感谢各位参加海通深圳策略会。最近资本市场非常动荡,大家都对未来充满了疑惑。  我们做研究猿的会经常和各大主流机构交流,上周我在北京和几家大银行、保险的领导交流,昨天我和我们策略荀老师也和深圳的诸多公私募大佬交流,发现一个共同的现象,大家对未来失去了方向,这好像是从去年以来的第一次。  以往每次大家都会对某一类资产的表现斩钉截铁,要么看好股票,要么看好债券,要么小盘、要么大盘,但这一次大家陷

2015-06-26 11:44:34 516

原创 swap

If we use containers, such as vector, the two for swap do not need to be of same length,#include#include#include #includeusing namespace std;int main(){ vectorv1{10,20,30}; vectorv2{1

2015-06-25 16:16:23 569

原创 lambda function

A lambda is an ad-hoc, locally-scoped function. Basically, lambdas are syntactic sugar, designed to reduce a lot of the work required in creating ad-hoc functor classes,The brackets ([]) mark th

2015-06-24 11:33:57 693

原创 string

Use stringstream#include #include #include #include using namespace std;templatevoid printInfo(T& s){ for(auto itr=s.begin(); itr!=s.end(); ++itr){ cout << *itr << ' '; }

2015-06-24 09:59:20 372

转载 “疯熊”走势也同样应该受到抨击

记得去年12月和今年5、6月大盘连续上涨时,新华社、人民日报以及管理层一再抨击“疯牛”,主张“慢牛”,并采取了查两融违规,加快扩容节奏,由每月发一批变成每月发两批,由每月发11家变成每月发48家,由一直发行小盘股变为6月份就发行两只融资超300亿的大盘股。但是,对于本周每天大跌几百点的“疯熊”,两大官媒及管理层却一声不吭,任凭大盘狂泻,很让人匪夷所思。      我认为,对“疯牛”固然

2015-06-22 18:16:07 373

转载 为何5000点上才出现慢牛

本周上证指数从5023-5166点,涨2.8%;深成指从17649—18098点,涨2.5%;中小板从17712—18325点,涨3.46%;创业板从3885—3899点,涨0.36%。无论是日、周涨幅,还是成交量,或是投资者的感觉上,都不再是以往的快牛、疯牛,而是典型的慢牛走势。      为什么管理层和新华社从3000点开始就不断呼吁的慢牛,市场都置之不理,总是反其道而行之?为何500

2015-06-14 11:39:43 501

原创 Simulate Blackjack Game - Card Generator

First of all, we define a abstract class for card. We implement the initialization function in base class, so every subclass will inherite such initial function. In the base class,# -*- coding:

2015-06-14 11:32:33 404

原创 Calibration Heston Model via Python

Semi-Closed-Form of Pricing Formulaimport numpy as npimport scipy.integrate as spidef Heston_Call_Value_Int(kappa, theta, sigma, rho, v0, r, T, s0, K): a = s0*Heston_P_Value(kappa, theta,

2015-06-01 20:06:09 3126

原创 Monte Carlo Asian Option Pricing OOP Framework

Box-Muller  Algorithm to Generate Normal Random Numbersdouble gaussian_box_muller(){ double x = 0.0; double y = 0.0; double euclid_sq = 0.0; do{ x = 2.0 * rand() / static_ca

2015-05-19 10:05:28 867

原创 Basic OOP in Python

Short rate classimport numpy as npimport matplotlib.pyplot as pltclass short_rate(object): def __init__(self, name_, rate_): self.name = name_ self.rate = rate_ d

2015-05-07 13:38:27 425

原创 American Option Pricing via Longstaff and Schwartz (2001)

import numpy as npimport matplotlib.pyplot as pltimport numpy.random as nprdef gen_sn(M, I, anti_paths=True, mo_match=True): if anti_paths is True: sn = npr.standard_normal((M+1, I/2)

2015-05-07 09:21:13 1404 1

原创 Simulate Common Stochastic Process

import numpy as npimport matplotlib.pyplot as pltimport numpy.random as npr####################################### simulate stock price in one step######################################S0 = 100

2015-05-06 22:53:30 470

原创 binomial tree in python

import numpy as npdef binomial(strike, optype, extype): # optype 'C' = call, 'P' = put # extype 'E' = european, 'A' = american # set model paramters S0 = 100 # initial st

2015-05-06 15:06:54 1877

原创 Download and Process High Frequency Data from NetFods

API for trade datahttp://hopey.netfonds.no/tradedump.php?date=20150423&paper=AAPL.O&csv_format=csvAPI for quota data should behttp://hopey.netfonds.no/posdump.php?date=20150423&paper=AAPL.O&csv_

2015-05-06 10:01:24 1380 1

转载 10 ways to download historical stock quotes data for free

Here is a list of websites that provide end of day historical data for US and international stock markets.All the quotes data provided by the websites listed here can be exported to CSV or Excel

2015-05-06 09:56:21 955

转载 6 ways to download free intraday and tick data for the U.S. stock market

Intraday and even tick data is also available free on the net. Today, I will show you six places where you can download and export historical intraday data. Some of these websites are very popular and

2015-05-06 09:52:36 1100

转载 顺应政策指挥棒,又现百点大震荡

自大盘以快牛方式,连续上攻4500、4500点时,管理层采取了三种方式为股市降温:增加每月新股批次,反复提示风险,禁止创业板高价股和部分涨幅过大的中字头股作为融资的抵押品。       三管齐下,强制大盘在4500点之下盘整9日。尤其是今起面对25只新股发行,增加供给手段、分流市场资金终于起作用,导致大盘再现百点大震荡(4488——4387点)。午前沪市大跌82点,1.84%;深市大跌38

2015-05-05 21:16:46 716

原创 Finite Difference BS Call PDE

#include #include #include #include using namespace std;double explicitCallOption(double S0, double X, double T, double r, double sigma, int iMax, int jMax) { // declare and initialise local v

2015-05-03 15:35:35 538

原创 Basket Call Option via C++

Two stocks, with correlation rho, European type,  payoff is Max(S1-S2, 0). First, Box-Muller algorithm,#ifndef BM_GAUSSIAN_HPP_INCLUDED#define BM_GAUSSIAN_HPP_INCLUDED#include #include #include

2015-05-03 12:01:39 543

原创 Vanilla Option Pricing via C++

Box-Muller Algorithm, generate Gaussian random numbers#ifndef BM_GAUSSIAN_HPP_INCLUDED#define BM_GAUSSIAN_HPP_INCLUDED#include #include #include double uniformRandom(){ return (double)(rand

2015-05-03 11:44:58 430

原创 Download Option Data from Yahoo Finance

from lxml.html import parsefrom urllib2 import urlopenimport pandas as pddef unpack(row, kind='td'): elts = row.findall('.//%s' % kind) return [val.text_content() for val in elts]optionu

2015-04-18 11:19:29 948

原创 Download Analyst Recommendation from HeXun

import numpy as npimport scipy as spimport scipy.stats as ssimport pandas as pdimport requests as rsimport bs4df = pd.DataFrame()for i in range(51,3808): webpage = 'http://yanbao.stock.he

2015-04-16 11:09:40 982

原创 Download Chinese Stock Data from Sina Finance

import numpy as npimport pandas as pdfrom urllib2 import urlopenfrom bs4 import BeautifulSoup def get_year_range(code): url = 'http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_MarketHisto

2015-04-16 11:06:52 1333

原创 Download U.S. Stock Data form Yahoo Finance

def get_data_yahoo(ticker, datestart, dateend): datestart = datestart.split('-') dateend = dateend.split('-') startyear = datestart[0] startmonth = str(int(datestart[1])-1) start

2015-04-16 11:03:46 625

原创 design_pattern_derivative_tree

Usually, tree is used to calculate American style options. We define our American style options as  follows#ifndef TREEPRODUCT_HPP_INCLUDED#define TREEPRODUCT_HPP_INCLUDEDclass TreeProducts {p

2015-03-23 19:24:24 372

原创 design_pattern_derivative_exotic_option

Based on payoff, option, mcstatistics and random numbers classes,  we now have basic components to build option pricing applications. This post applies template pattern to price path-dependent options

2015-03-23 00:18:53 385

原创 design_pattern_derivative_randomnumber

We have implemented payoff, option, statistics class. In our calculation for option price, we have used gsl library to generate random numbers, gsl is a high quality numerical library, however,  to pr

2015-03-22 13:47:48 500

原创 design_pattern_derivative_statistics

Our monte carlo rounte  lacks any indication of the simulation’s convergence. We could make the routine return standard error, or a convergence table, or simply have it return the value for every sing

2015-03-22 10:59:50 476

原创 design_pattern_derivative_option

If we consider option as a whole, the basic components are expiration and payoff. We want to define a Vanilla Option class which has as data members a PayOff object and a double to represent expiry. H

2015-03-22 00:34:16 395

原创 design_pattern_derivative_payoff

In the option pricing framework, the first component which always changes is option's payoff.  Therefore, we need to  encapsulation the payoff class. First of all, we define an abstract PayOff class,

2015-03-21 23:47:48 506

原创 exception

Simple example for defining users' own exception. The key point is to implement pure virtual function what().#include #include using namespace std;class myexception : public exception {publi

2015-03-20 17:19:43 447

原创 sort

Use student class. #ifndef STUDENT_HPP_INCLUDED#define STUDENT_HPP_INCLUDEDusing namespace std;class student{private: int NO; int Grade; string Name;public: student():NO(0),G

2015-03-18 19:45:00 318

原创 remove

use student class, remove students from collection, if his grade is less than 80.student class#ifndef STUDENT_HPP_INCLUDED#define STUDENT_HPP_INCLUDEDusing namespace std;class student{private:

2015-03-18 18:32:19 345

原创 replace

Simple example#include #include #include #include using namespace std;int main(){ vector v({1,2,3,4,5,4,3,2,1}); cout << "Original Vector: " << endl; auto itr = v.begin(); whi

2015-03-18 16:27:28 264

原创 transform

Use student class, for each student, add extra 5 points to its grade.#ifndef STUDENT_HPP_INCLUDED#define STUDENT_HPP_INCLUDEDusing namespace std;class student{private: int NO; int Grad

2015-03-18 15:51:42 261

原创 copy

Examples. Still use student class.#ifndef STUDENT_HPP_INCLUDED#define STUDENT_HPP_INCLUDEDusing namespace std;class student{private: int NO; int Grade; string Name;public: st

2015-03-18 14:54:47 316

转载 重整国家资产负债表的核心是谁来买单

本文由华创证券总经理助理华中炜推荐主要观点:1万亿地方政府债务置换迈出了中国重塑国家资产负债表的关键一步。重塑中国国家资产负债表是步入新常态需要化解的首要问题。去杠杆去产能进程推进缓慢,融资利率居高不下,刚性兑付孰难突破等诸多困局,正是国家资产负债表错配扭曲的病态,也是中国进入长债务周期下半场的表现。如果不能同步配合资产负债表的修复,货币放水与财政刺激的药方

2015-03-18 14:10:18 772

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除