From 5e03feef29d77927e8a8c85d9719b2670e5ab1fb Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 9 Feb 2018 18:06:31 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=E6=96=B0=E5=A2=9EBlack-Scholes=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=9A=84Cython=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/WebTrader/CTP_connect.json | 4 +- vnpy/pricing/README.md | 4 + vnpy/pricing/bsCython.pyd | Bin 0 -> 43008 bytes vnpy/pricing/bsCython/bsCython.pyx | 148 ++++++++++++++++++ vnpy/pricing/bsCython/setup.py | 7 + .../app/optionMaster/etf_portfolio.json | 2 +- vnpy/trader/app/optionMaster/omEngine.py | 3 +- 7 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 vnpy/pricing/README.md create mode 100644 vnpy/pricing/bsCython.pyd create mode 100644 vnpy/pricing/bsCython/bsCython.pyx create mode 100644 vnpy/pricing/bsCython/setup.py diff --git a/examples/WebTrader/CTP_connect.json b/examples/WebTrader/CTP_connect.json index 1b4d5a42..e4bfa6b8 100644 --- a/examples/WebTrader/CTP_connect.json +++ b/examples/WebTrader/CTP_connect.json @@ -2,6 +2,6 @@ "brokerID": "9999", "mdAddress": "tcp://180.168.146.187:10011", "tdAddress": "tcp://180.168.146.187:10001", - "userID": "000300", - "password": "19890624" + "userID": "simnow申请", + "password": "simnow申请" } \ No newline at end of file diff --git a/vnpy/pricing/README.md b/vnpy/pricing/README.md new file mode 100644 index 00000000..9034981e --- /dev/null +++ b/vnpy/pricing/README.md @@ -0,0 +1,4 @@ +* Cython相关模型的编译方法:python setup.py build_ext --inplace + +* 报错Unable to find vcvarsall.bat的解决方法:SET VS90COMNTOOLS=%VS120COMNTOOLS% + diff --git a/vnpy/pricing/bsCython.pyd b/vnpy/pricing/bsCython.pyd new file mode 100644 index 0000000000000000000000000000000000000000..285ea771602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9)5H~~BBh}{sFD_P(0bXd-8S2THXB4aFs%z8@>c#5Y z)PGd3!;Irk>doq1h^+nUzo`$Yzfm7Wd=1hJ*C;f<(_E^#TBFxEfF##zDl}D^2F(&p zE5_6Nfg@`%CwX4;vSyQJm*zdqM;OEYfvEdMBhe1mj@DkO)o88SEW}))wgfTf)z%>H znhCV$#h$tKj7ba}dbU5RcU#^{B* zWxCseLQmfi}82=9&elT!`Va5xLV-Vq)m_N+|k}WdcX1v3=()c3gQ14)zI%@nL z5iT)ZY*Lx7FljMrUu&9Sns2H$`7mPLZu*1iG1C(m!}po~&PVt!rs3u^%&V?9mzn3A z7nm0V%O1oG>qW%(Zs6G|v)pniFs;Zk+foZuYqh*;*=l*$@|ER?g~qb0trM)1tqU=V z-ECcGecJkw^)u_gtO>SZ826pFslc>K%t6-JUb4Mv+h_a6)`KV?Vjpdvz+>7>j92&C zA3~Hm50c>5d{tiKE`J)bW_(dB>lCUnd;@b|{?ZB986OZ0A(x4CgFo zoAZ9>ADxdOdY{3lbopX@1Ygk`8e)Ra>B)sjbuAqHWQx);_Oo*S@0-XusE5bu)Bjx;l(PxAXJb zeQ5Qgy6xu%tA7Z6OE|sO6)1bX|?8I zjS3iAjoNKQy*6w2YYzZ1nKjsNh;cbZor+#nqMm~}lUH30`}V69nj}q%CRL- (s - k) * exp(-r * t)): + meet = True + elif cp == -1 and (price > k * exp(-r * t) - s): + meet = True + + if not meet: + return 0 + + v = 0.3 + + for i in range(50): + p = calculatePrice(s, k, r, t, v, cp) + + vega = calculateOriginalVega(s, k, r, t, v, cp) + + if not vega: + break + + dx = (price - p) / vega + + if abs(dx) < DX_TARGET: + break + + v += dx + + if v <= 0: + return 0 + + v = round(v, 4) + + return v + \ No newline at end of file diff --git a/vnpy/pricing/bsCython/setup.py b/vnpy/pricing/bsCython/setup.py new file mode 100644 index 00000000..dae54a84 --- /dev/null +++ b/vnpy/pricing/bsCython/setup.py @@ -0,0 +1,7 @@ +from distutils.core import setup +from Cython.Build import cythonize + +setup( + name = 'bsCython', + ext_modules = cythonize("bsCython.pyx"), +) diff --git a/vnpy/trader/app/optionMaster/etf_portfolio.json b/vnpy/trader/app/optionMaster/etf_portfolio.json index 626f29cc..fe2ea449 100644 --- a/vnpy/trader/app/optionMaster/etf_portfolio.json +++ b/vnpy/trader/app/optionMaster/etf_portfolio.json @@ -1,6 +1,6 @@ { "name": "etf_portfolio", - "model": "black", + "model": "bsCython", "underlying": [ "510050" ], diff --git a/vnpy/trader/app/optionMaster/omEngine.py b/vnpy/trader/app/optionMaster/omEngine.py index f7f98b2c..3e2eba03 100644 --- a/vnpy/trader/app/optionMaster/omEngine.py +++ b/vnpy/trader/app/optionMaster/omEngine.py @@ -17,7 +17,7 @@ from vnpy.trader.vtConstant import (PRODUCT_OPTION, OPTION_CALL, OPTION_PUT, DIRECTION_LONG, DIRECTION_SHORT, OFFSET_OPEN, OFFSET_CLOSE, PRICETYPE_LIMITPRICE) -from vnpy.pricing import black, bs, crr +from vnpy.pricing import black, bs, crr, bsCython from .omBase import (OmOption, OmUnderlying, OmChain, OmPortfolio, EVENT_OM_LOG, EVENT_OM_STRATEGY, EVENT_OM_STRATEGYLOG, @@ -31,6 +31,7 @@ MODEL_DICT = {} MODEL_DICT['black'] = black MODEL_DICT['bs'] = bs MODEL_DICT['crr'] = crr +MODEL_DICT['bsCython'] = bsCython