如何自己動手寫一個自動交易程式 - 期貨
By Regina
at 2012-03-08T17:50
at 2012-03-08T17:50
Table of Contents
薦於許多人對於寫交易程式很感興趣,但卻不知從何開始,且剛好有幾位網友寫信問我
寫交易程式的問題,因此我整理了幾個比較關鍵的概念與參考網站,供大家參考。
在開發工具的部份,目前小弟使用的是Visual Studio 2008 VB or C#,這算是範例
程式多,券商API支援度也較高的工具。
有了開發工具才能開始,一個完整的自動交易程式必要的程序如下:
接收盤中即時資料=>策略運算與分析=>下單
以下就各程序簡單說明:
1.接收盤中即時資料:
A.大部份券商的看盤軟體打開後,即是DDE Server,所以盤中必須打開它。
B.你的軟體裡必須有DDE Client端程式,以連線你所開啟的看盤軟體(DDE Server),
接收即時資料,請參考 http://goo.gl/sNA1s 或 http://goo.gl/GrTWg 。
C.DDE Client端裡重要設定:
a.DDE Server的Topic & Service,每個看盤軟體皆不同,請自己向券商詢問或上
網查,下面是凱基KGI全球通TS範例:
DdeClient DdeClient = new DdeClient("TCGQ", "ICE.TWF.FITX.HOT");
b.商品代碼,每到結算日轉倉要特別注意,請參考 http://goo.gl/G3fBq 。
2.策略:
這部份其實才是程式交易的核心,也是最難的,但並不是本文想著墨的,等你把接收
資料與下單搞定了,賺錢的策略就隨你發揮。我們只談:
A.技術分析:一般收費的自動交易程式有一堆現成的技術分析方法或指標可以直接拿來
用,自己寫就不同了,可能你只是弄個均線就滿頭大汗,更何況是其他更複雜的指標
,不過好處就是透過寫程式的過程,可以完全了解該技術指標的含義,且非常有彈性
,如:想寫個3秒K、8分K、2.5小時K都不是問題。
B.回測:當一個策略寫完後,除了要測bug,更重要的就是回測勝率,可以到期交所下載
每日歷史資料的Tick檔,餵進你的程式,檢驗策略可行性並調整,下載連結如下:
http://www.taifex.com.tw/DailyDownload/Daily_yyyy_mm_dd.zip (From期交所)
(yyyy年、mm月、dd日)
3.下單:
A.先向券商申請API下單權限。
B.透過券商的API(小弟的券商有提供支援VS的API)或所謂的下單機下單,這部份通常
券商會提供範例程式與函式說明。
以上是小弟過去摸索了一陣子累積的心得,希望分享給想要自己開發交易程式的同好,
降低摸索的時間,也別忘了停損的重要性,若有任何錯誤或問題,麻煩告知,
祝大家賺大錢,謝謝~
by winman
--
Tags:
期貨
All Comments
By Caroline
at 2012-03-11T16:19
at 2012-03-11T16:19
By Kristin
at 2012-03-12T01:59
at 2012-03-12T01:59
By Audriana
at 2012-03-13T09:43
at 2012-03-13T09:43
By Mia
at 2012-03-16T03:23
at 2012-03-16T03:23
By Lily
at 2012-03-20T07:42
at 2012-03-20T07:42
By Sierra Rose
at 2012-03-24T06:49
at 2012-03-24T06:49
By Margaret
at 2012-03-25T22:23
at 2012-03-25T22:23
By Belly
at 2012-03-29T20:24
at 2012-03-29T20:24
By Elizabeth
at 2012-03-30T03:12
at 2012-03-30T03:12
By Zenobia
at 2012-03-31T01:01
at 2012-03-31T01:01
By Ivy
at 2012-04-04T00:14
at 2012-04-04T00:14
By Harry
at 2012-04-04T20:37
at 2012-04-04T20:37
By Belly
at 2012-04-06T12:06
at 2012-04-06T12:06
By Daniel
at 2012-04-06T19:58
at 2012-04-06T19:58
By Daph Bay
at 2012-04-11T09:17
at 2012-04-11T09:17
By Skylar Davis
at 2012-04-13T01:20
at 2012-04-13T01:20
By Blanche
at 2012-04-17T22:06
at 2012-04-17T22:06
By Oscar
at 2012-04-21T04:04
at 2012-04-21T04:04
By Skylar Davis
at 2012-04-22T03:20
at 2012-04-22T03:20
By Sierra Rose
at 2012-04-24T18:21
at 2012-04-24T18:21
By Blanche
at 2012-04-29T12:47
at 2012-04-29T12:47
By George
at 2012-05-04T07:59
at 2012-05-04T07:59
By Rachel
at 2012-05-04T21:00
at 2012-05-04T21:00
By Dorothy
at 2012-05-04T23:20
at 2012-05-04T23:20
By Aaliyah
at 2012-05-06T14:53
at 2012-05-06T14:53
By Elma
at 2012-05-07T05:28
at 2012-05-07T05:28
By Frederica
at 2012-05-10T05:23
at 2012-05-10T05:23
By Callum
at 2012-05-10T23:08
at 2012-05-10T23:08
By Michael
at 2012-05-12T10:08
at 2012-05-12T10:08
By Necoo
at 2012-05-13T03:20
at 2012-05-13T03:20
By Aaliyah
at 2012-05-16T23:27
at 2012-05-16T23:27
By Caroline
at 2012-05-17T07:21
at 2012-05-17T07:21
By Ursula
at 2012-05-21T00:19
at 2012-05-21T00:19
By Iris
at 2012-05-24T17:38
at 2012-05-24T17:38
By Carolina Franco
at 2012-05-29T01:30
at 2012-05-29T01:30
By Una
at 2012-06-01T08:38
at 2012-06-01T08:38
By Jacky
at 2012-06-03T08:34
at 2012-06-03T08:34
By Yuri
at 2012-06-06T21:26
at 2012-06-06T21:26
By Hedy
at 2012-06-09T21:05
at 2012-06-09T21:05
Related Posts
三大法人&大額交易人期權資料 2012/3/8
By Victoria
at 2012-03-08T15:49
at 2012-03-08T15:49
101年03月08日 期貨收盤價&結算價一覽表
By Adele
at 2012-03-08T15:01
at 2012-03-08T15:01
101年03月08日 三大法人買賣金額統計表
By Oscar
at 2012-03-08T14:51
at 2012-03-08T14:51
2012/3/8 盤後閒聊
By Gary
at 2012-03-08T13:44
at 2012-03-08T13:44
現在開個戶這麼麻煩?
By Catherine
at 2012-03-08T10:57
at 2012-03-08T10:57