2014/06/27

暫停公告 6/28 ~ 6/30 (渡假 1)

帶小六畢業那隻做國內的參團旅遊, 算是這波放自己假的第一階段吧
第二階段放假是 7/2 ~ 7/8

20140627

攻擊力雖不足, 但買訊仍在

週期拉長看, 期時價格是很強勢的; 今日整理盤無進出, 偏多留倉


9:50
多方繼續主控盤勢, 管它甚麼週五易跌

2014/06/26

20140626

在手多單警報解除, 而買訊出, 反應加碼多單

週期拉長, 可免裝神需要去摸頭猜底; 今日加碼多單且偏多留倉


13:52
尾盤加碼8月多單SP 89 + BP 86

11:45
早上有事情, 晚開版
盤中挑戰新高, 只有一個方向續多; 不要想造神去先摸頭SC, 現在又要費事地自圓其說

2014/06/25

20140625

多單警戒未除, 可酌加保護

多頭持續前行沒轉弱; 連續幾日不做無謂進出, 偏多留倉


10:15
加空單稍安勿躁, 極短線都時機未到


9:11
TVIX仍在10以下, 看不出有加空單之必要
既有偏多之留倉組合單不變, 等真正受迫時再說

2014/06/24

20140624

短天期偏弱整理, 多方警戒尚未解除

拉長週期看, 多頭架構沒被破壞; 偏多留倉


10:45
market C/P ratio也是偏多, 沒必要像神人先一步地假會亂去SC


10:39
維持既有留倉的多空組合部位不變, 待有明確趨向時, 再實行 [跟上] 的操作

9:10
留倉偏多不變, 不因些微震盪而亂進出
沒有看到明顯的做空機會, 不要學神人亂SC喔

2014/06/23

20140623

短天期系統終於轉空訊, 留倉多單要開始警戒

多頭架構未被破壞, 留倉仍偏多


13:43
短天期系統顯示自5/22以來, 第一次有做空的機會, 但逢多頭架構未破, 我不做此短空!

11:39
股王3008今年股價連續暴衝, 今天現時1張可賺超過10萬
股價已高處不勝寒, 既然無法參與往上, 要持續關注何時能往下做啊
週線如能轉空再說吧


11:26
終於有些微轉弱的跡象, 不過, 仍不能據以操作空單

10:51
如果沒有突然來個令人驚訝的大起伏, 可能要微波上下無聊到月底喔

10:20
多頭繼續前行, 連極短線都沒看到有做空的機會

2014/06/20

20140620

即使是短天期系統,也不見5/22的買訊消失

週期拉長來看,雖有回檔跡象,仍在上限之上;留倉偏多


11:07
轉PO神單一張,想想自己為啥和人家差距這麼大 LOL


9:36
交易就是等待市場出現你完全可以捕捉的信號,並且它又符合你系統的交易要求。其餘時間就是一個字“等”,兩個字“等”,三個字“等”

9:20
5/22出發的這波多頭, 至今沒有像樣地回檔, 暫時不要有[空]的想法

2014/06/19

2014 六月績效檢討


6月台指期結算點數是9302, 相較上月的8860點, 漲幅約5%; 絕對點差相對於前幾個月大,看圖形可知幾乎是一拉到底的行情,這對我以往的操作模式是個考驗,多頭走法一直是我模式上的罩門,所幸本月因應行情有稍加改良固有缺點,算是獲得滿意的效果

這SC才40口不停損, 就要賠五十幾萬, 苦了我那些抵補的BC啊


總結投入的總資金 (含資金控管裡的全部預備金), 獲利率由上月的小正0.62%, 提升到仍不足1%的0.88%


這次也別忘了上個月提過的對照組:康和多空成長
暫時領先於它的態勢沒變

20140619

收盤續創新高, 不願追高的話, 也不該逆勢做空

連個像樣的修整都沒有, 一整個強悍不已; 偏多留倉


11:02
才剛新開倉﹐操作週期先拉長會比較好


9:28
攻擊有點遲滯,market CP ratio仍有利於多方


8:46
果然持續往上, 昨天結算後的壓盤可以無視

8:43
只要能持續高開, 多方就掌握了主動, 空頭便比較不敢妄動

2014/06/18

做跟隨市場的笨蛋, 不做試圖提前市場的聰明人

原文出處: http://richclub.pixnet.net/blog/post/27236426-%E7%B0%A1%E5%96%AE%E7%9A%84%E5%B0%B1%E6%98%AF%E6%9C%80%E5%A5%BD%E7%9A%84

重點選錄:

十六個字“趨勢為王,週期轉換,順勢交易,逆勢看盤

做交易,首先是定方向,是做多,還是做空,還是不做。首先要有一個嚴格的參照標準,然後是各種大小週期之間的不斷轉換,需要馬上就能體會到它在日線的作用和位置以及對整個趨勢的影響,對均線系統的影響,關於後8個字,我可以再用4個字來形容叫做“找反做順”

一定要追漲殺跌,千萬不能高賣低買,你想,只有前者才是順勢而為,而後者就是逆勢而為,是猜。你說他能走多高和多低,波浪理論應該是最好的試圖解釋清楚波浪間關係的理論。但它也有很多選擇,3浪有可能是1浪的1.382倍,有可能是2倍,有可能是2.618倍等等。所以高賣低買要不得,偶然成功必然失敗

不要試圖去預測市場,也不要去交易方向不明的階段或者你自己沒把握或者不清楚的階段。交易就是等待市場出現你完全可以捕捉的信號,並且它又符合你系統的交易要求。其餘時間就是一個字“等”,兩個字“等”,三個字“等”,永遠只交易最簡單、最容易搞清楚的一段行情, 永遠只做跟隨市場的笨蛋,也不做試圖提前市場的聰明人



20140618

7月期指上漲18點,但留倉的7月買賣權的權利金皆上漲

現貨講究【真金實銀】對打,短天期不見多方有危險

拉長週期看,更在上限之上地強悍


13:43
大人們為了錢打架,把波動度拉大,讓買賣權雙方的時間價值增加一點也好

13:13
一不小心就會被軋到翻過去

13:10
如果在今低猜會結在9200附近而SC的人, 11.5 -> 現在100多, 快10倍了

13:03
午盤上下竄得很戲劇化, 為了結算利益都拼了
身為散戶的我們在旁邊看, 不要過度參與的好啊; 否則今天順極短勢當沖的人, 就算會反打, 應該也是受傷的


10:27
看來今天在高檔的9200以上結算無誤
設好系統自動簡訊通知以防有變﹐我要出門儲值給噓噓東了
極短線要轉弱還有得等


9:56
曾有個高手說得好:

十六個字“趨勢為王,週期轉換,順勢交易,逆勢看盤”

做交易,首先是定方向,是做多,還是做空,還是不做。首先要有一個嚴格的參照標準,然後是各種大小週期之間的不斷轉換,需要馬上就能體會到它在日線的作用和位置以及對整個趨勢的影響,對均線系統的影響,關於後8個字,我可以再用4個字來形容叫做“找反做順”

9:15
又在軋了, 要應驗那句: 空頭不死, 多頭不止啊

9:05
近兩天的calls / puts市價比, 又轉對多方有利, 偏多操作為要

2014/06/17

How I made $500k with machine learning & HFT

評析:

和以前說法一致: 散戶該放棄HFT, 但作者其他的概念有參考的價值

原文出處: http://jspauld.com/post/35126549635/how-i-made-500k-with-machine-learning-and-hft
This post will detail what I did to make approx. 500k from high frequency trading from 2009 to 2010. Since I was trading completely independently and am no longer running my program I’m happy to tell all. My trading was mostly in Russel 2000 and DAX futures contracts.
The key to my success, I believe, was not in a sophisticated financial equation but rather in the overall algorithm design which tied together many simple components and used machine learning to optimize for maximum profitability. You won’t need to know any sophisticated terminology here because when I setup my program it was all based on intuition. (Andrew Ng’s amazing machine learning course was not yet available - btw if you click that link you’ll be taken to my current project: CourseTalk, a review site for MOOCs)
First, I just want to demonstrate that my success was not simply the result of luck. My program made 1000-4000 trades per day (half long, half short) and never got into positions of more than a few contracts at a time. This meant the random luck from any one particular trade averaged out pretty fast. The result was I never lost more than $2000 in one day and never had a losing month:
(EDIT: These figures are after paying commissions)
And here’s a chart to give you a sense of the daily variation. Note this excludes the last 7 months because - as the figures stopped going up - I lost my motivation to enter them.
My trading background
Prior to setting up my automated trading program I’d had 2 years experience as a “manual” day trader. This was back in 2001 - it was the early days of electronic trading and there were opportunities for “scalpers” to make good money. I can only describe what I was doing as akin to playing a video game / gambling with a supposed edge. Being successful meant being fast, being disciplined, and having a good intuitive pattern recognition abilities. I was able to make around $250k, pay off my student loans and have money left over. Win!
Over the next five years I would launch two startups, picking up some programming skills along the way. It wouldn’t be until late 2008 that I would get back into trading. With money running low from the sale of my first startup, trading offered hopes of some quick cash while I figured out my next move.
A trading API
In 2008 I was “manually” day trading futures using software called T4. I’d been wanting some customized order entry hotkeys, so after discovering T4 had an API, I took on the challenge of learning C# (the programming language required to use the API) and went ahead and built myself some hotkeys.
After getting my feet wet with the API I soon had bigger aspirations: I wanted to teach the computer to trade for me. The API provided both a stream of market data and an easy way to send orders to the exchange - all I had to do was create the logic in the middle.
Below is a screenshot of a T4 trading window. What was cool is that when I got my program working I was able to watch the computer trade on this exact same interface. Watching real orders popping in and out (by themselves with my real money) was both thrilling and scary.

The design of my algorithm
From the outset my goal was to setup a system such that I could be reasonably confident I’d make money before ever making any live trades. To accomplish this I needed to build a trading simulation framework that would - as accurately as possible - simulate live trading.
While trading in live mode required processing market updates streamed through the API, simulation mode required reading market updates from a data file. To collect this data I setup the first version of my program to simply connect to the API and record market updates with timestamps. I ended up using 4 weeks worth of recent market data to train and test my system on. 
With a basic framework in place I still had the task of figuring out how to make a profitable trading system. As it turns out my algorithm would break down into two distinct components, which I’ll explore in turn:
  • Predicting price movements; and
  • Making profitable trades 
Predicting price movements
Perhaps an obvious component of any trading system is being able to predict where prices will move. And mine was no exception. I defined the current price as the average of the inside bid and inside offer and I set the goal of predicting where the price would be in the next 10 seconds. My algorithm would need to come up with this prediction moment-by-moment throughout the trading day.
Creating & optimizing indicators
I created a handful of indicators that proved to have a meaningful ability to predict short term price movements. Each indicator produced a number that was either positive or negative. An indicator was useful if more often than not a positive number corresponded with the market going up and a negative number corresponded with the market going down.
My system allowed me to quickly determine how much predictive ability any indicator had so I was able to experiment with a lot of different indicators to see what worked. Many of the indicators had variables in the formulas that produced them and I was able to find the optimal values for those variables by doing side by side comparisons of results achieved with varying values.
The indicators that were most useful were all relatively simple and were based on recent events in the market I was trading as well as the markets of correlated securities.
Making exact price move predictions
Having indicators that simply predicted an up or down price movement wasn’t enough. I needed to know exactly how much price movement was predicted by each possible value of each indicator. I needed a formula that would convert an indicator value to a price prediction.
To accomplish this I tracked predicted price moves in 50 buckets that depended on the range that the indicator value fell in. This produced unique predictions for each bucket that I was then able to graph in Excel. As you can see the expected price change increases as the indicator value increases.
Based on a graph such as this I was able to make a formula to fit the curve. In the beginning I did this “curve fitting” manually but I soon wrote up some code to automate this process.
Note that not all the indicator curves had the same shape. Also note the buckets were logarithmically distributed so as to spread the data points out evenly. Finally note that negative indicator values (and their corresponding downward price predictions) were flipped and combined with the positive values. (My algorithm treated up and down exactly the same.)
Combining indicators for a single prediction
An important thing to consider was that each indicator was not entirely independent. I couldn’t simply just add up all the predictions that each indicator made individually. The key was to figure out the additional predictive value that each indicator had beyond what was already predicted. This wasn’t to hard to implement but it did mean that if I was “curve fitting” multiple indicators at the same time I had to be careful; changing one would effect the predictions of another. 
In order to “curve fit” all of the indicators at the same time I setup the optimizer to step only 30% of the way towards the new prediction curves with each pass. With this 30% jump I found that the prediction curves would stabilize within a few passes. 
With each indicator now giving us it’s additional price prediction I could simply add them up to produce a single prediction of where the market would be in 10 seconds.
Why predicting prices is not enough
You might think that with this edge on the market I was golden. But you need to keep in mind that the market is made up of bids and offers - it’s not just one market price. Success in high frequency trading comes down to getting good prices and it’s not that easy.
The following factors make creating a profitable system difficult:
  • With each trade I had to pay commissions to both my broker and the exchange.
  • The spread (difference between highest bid and lowest offer) meant that if I were to simply buy and sell randomly I’d be losing a ton of money.
  • Most of the market volume was other bots that would only execute a trade with me if they thought they had some statistical edge.
  • Seeing an offer did not guarantee that I could buy it. By the time my buy order got to the exchange it was very possible that that offer would have been cancelled.
  • As a small market player there was no way I could compete on speed alone.
Building a full trading simulation
So I had a framework that allowed me to backtest and optimize indicators. But I had to go beyond this - I needed a framework that would allow me to backtest and optimize a full trading system; one where I was sending orders and getting in positions. In this case I’d be optimizing for total P&L and to some extent average P&L per trade.
This would be trickier and in some ways impossible to model exactly but I did as best as I could. Here are some of the issues I had to deal with:
  • When an order was sent to the market in simulation I had to model the lag time. The fact that my system saw an offer did not mean that it could buy it straight away. The system would send the order, wait approximately 20 milliseconds and then only if the offer was still there was it considered as an executed trade. This was inexact because the real lag time was inconsistent and unreported.
  • When I placed bids or offers I had to look at the trade execution stream (provided by the API) and use those to gauge when my order would have gotten executed against. To do this right I had to track the position of my order in the queue. (It’s a first-in first-out system.) Again, I couldn’t do this perfectly but I made a best approximation.
To refine my order execution simulation what I did was take my log files from live trading through the API and compare them to log files produced by simulated trading from the exact same time period. I was able to get my simulation to the point that it was pretty accurate and for the parts that were impossible to model exactly I made sure to at least produce outcomes that were statistically similar (in the metrics I thought were important).
Making profitable trades
With an order simulation model in place I could now send orders in simulation mode and see a simulated P&L. But how would my system know when and where to buy and sell?
The price move predictions were a starting point but not the whole story. What I did was create a scoring system for each of 5 price levels on the bid and offer. These included one level above the inside bid (for a buy order) and one level below the inside offer (for a sell order). 
If the score at any given price level was above a certain threshold that would mean my system should have an active bid/offer there - below the threshold then any active orders should be cancelled. Based on this it was not uncommon that my system would flash a bid in the market then immediately cancel it. (Although I tried to minimize this as it’s annoying as heck to anyone looking at the screen with human eyes - including me.)
The price level scores were calculated based on the following factors:
  • The price move prediction (that we discussed earlier).
  • The price level in question. (Inner levels meant greater price move predictions were required.) 
  • The number of contracts in front of my order in the queue. (Less was better.)
  • The number of contracts behind my order in the queue. (More was better.)
Essentially these factors served to identify “safe” places to bid/offer. The price move prediction alone was not adequate because it did not account for the fact that when placing a bid I was not automatically filled - I only got filled if someone sold to me there. The reality was that the mere fact of someone selling to me at a certain price changed the statistical odds of the trade. 
The variables used in this step were all subject to optimization. This was done in the exact same way as I optimized variables in the price move indicators except in this case I was optimizing for bottom line P&L.
What my program ignored
When trading as humans we often have powerful emotions and biases that can lead to less than optimal decisions. Clearly I did not want to codify these biases. Here are some factors my system ignored:
  • The price that a position was entered - In a trading office it’s pretty common to hear conversation about the price at which someone is long or short as if that should effect their future decision making. While this has some validity as part of a risk reduction strategy it really has no bearing on the future course of events in the market. Therefore my program completely ignored this information. It’s the same concept as ignoring sunk costs.
  • Going short vs. exiting a long position - Typically a trader would have different criteria that determines where to sell a long position versus where to go short. However from my algorithms perspective there was no reason to make a distinction. If my algorithm expected a downward move selling was a good idea regardless of if it was currently long, short, or flat.
  • A “doubling up” strategy - This is a common strategy where traders will buy more stock in the event that there original trade goes against them. This results in your average purchase price being lower and it means when (or if) the stock turns around you’ll be set to make your money back in no time. In my opinion this is really a horrible strategy unless you’re Warren Buffet. You’re tricked into thinking you are doing well because most of your trades will be winners. The problem is when you lose you lose big. The other effect is it makes it hard to judge if you actually have an edge on the market or are just getting lucky. Being able to monitor and confirm that my program did in fact have an edge was an important goal.
Risk management 
Since my algorithm made decisions the same way regardless of where it entered a trade or if it was currently long or short it did occasionally sit in (and take) some large losing trades (in addition to some large winning trades). But, you shouldn’t think there wasn’t any risk management.
To manage risk I enforced a maximum position size of 2 contracts at a time, occasionally bumped up on high volume days. I also had a maximum daily loss limit to safeguard against any unexpected market conditions or a bug in my software. These limits were enforced in my code but also in the backend through my broker. As it happened I never encountered any significant problems.
Running the algorithm
From the moment I started working on my program it took me about 6 months before i got it to the point of profitability and begun running it live. Although to be fair a significant amount of time was learning a new programming language. As I worked to improve the program I saw increased profits for each of the next four months.
Each week I would retrain my system based on the previous 4 weeks worth of data. I found this struck the right balance between capturing recent market behavioral trends and insuring my algorithm had enough data to establish meaningful patterns. As the training began taking more and more time I split it out so that it could be performed by 8 virtual machines using amazon EC2. The results were then coalesced on my local machine.
The high point of my trading was October 2009 when I made almost 100k. After this I continued to spend the next four months trying to improve my program despite decreased profit each month. Unfortunately by this point I guess I’d implemented all my best ideas because nothing I tried seemed to help much.
With the frustration of not being able to make improvements and not having a sense of growth I began thinking about a new direction. I emailed 6 different high frequency trading firms to see if they’d be interested in purchasing my software and hiring me to work for them. Nobody replied. I had some new startup ideas I wanted to work on so I never followed up.
UPDATE - I posted this on Hacker News and it has gotten a lot of attention. I just want to say that I do not advocate anyone trying to do something like this themselves now. You would need a team of really smart people with a range of experiences to have any hope of competing. Even when I was doing this I believe it was very rare for individuals to achieve success (though I had heard of others.)
There is a comment at the top of the page that mentions  ”manipulated statistics” and refers to me as a “retail investor” that quants would “gleefully pick off”. This is a rather unfortunate comment that’s simply not based in reality. Setting that aside there’s some interesting comments: http://news.ycombinator.com/item?id=4748624
UPDATE #2 - I’ve posted a follow-up FAQ that answers some common questions I’ve received from traders about this post.

20140617

現貨收盤創新高, 自5/22起始的買訊不止

拉長週期看, 多頭強勢行進, 沒有任何轉弱點; 留倉偏多


13:39
現貨收盤創新高, 決定贊助多方做07BC 89 + 07SC 93

13:28
按7月份除息預計扣除的點數看, 現在7月期指已經實質正價差超過30點了


11:07
明天要結算的6月9200買權契約, 恐怕會被 [破發] 了 LOL
有參考我一直在加多的人, SC倒莊沒事還可以賺, 我手上就有不少6月的SC, 剛看了一下, 竟然有價內很久的SC 9000繼續抱到現在哩

11:00
大型股攻擊的態勢比較像樣了, 可以考慮酌量加多


9:22
預計結算完的月底, 先帶小六畢業的那個去玩三天兩夜
為此減碼7月雙邊獲利入袋以降風險, 損益圖形遂變醜 哈 LOL


9:17
7月期指比0050來得強, 不排除是為了結算利益在拉
因此若有較大部位要進場的話, 等結算完確定了方向會比較保險

8:57
只要能往上高開, 對多頭都是好事, 偏多操作不變

2014/06/16

20140616

高檔震盪, 沒確認轉弱前, 繼續偏多操作

拉長週期看, 多頭架構仍舊堅實; 留倉偏多


13:03
07BC 89 + 07SC 93
即使主觀認為已經漲多, 但極短線買訊出, 也只能硬著頭皮做

10:52
極短線有轉強機會, 做06BC 89 + 06SC 92 + 07BC 89 + 07SC 93

9:23
最近這波上漲, 外資扮演最重要主力
極短線觀察大型類股代表0050是否轉強, 當成是否加多的指標


9:18
calls/puts市值比對多方不佳, 若無重大漲跌, 還是不調整的好


.

.