strategy:turt1: add stable price detection methods

Add price detection methods to find the stable prices to reduce
transaction errors.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turt1: add tracing logs for stable price methods

Add tracing logs for stable price methods to know what it is
happening at runtime.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turt1: fix exception caused by a typo

Fix exception caused by using a typo 'getgetClose'.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:autopos: rename all position methods with Hungarian notation

1) Rename all position methods with Hungarian notation to keep
   consistency with other modules.
2) Update ctp.ctpParser and strategy.futures because of #1.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:futures: add commentaries for arguments of methods

Add commentaries for arguments of methods.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:autopos: add commentaries for arguments of methods

Add commentaries for arguments of methods.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
test:testctp: update test to autopos since methods were renamed

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turt1: fix hit signals are not stable enough

1) Hit signals are not stable enough, fix it using stable
   price methods.
2) Add commentaries for the arguments of hit-signal methods.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turt1: fix exception to add positions

Fix a exception caused by using a non-defined argument with
getClose() in the stable price methods to add long or short
positions.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
misc:elemmap: add checking before delete an element

Add checking before delete an element, otherwise it will
cause an error.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
test: add test to ElementMap

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpagent: fix recording order history from ctp at beginning

Fix recording order history received from ctp at beginning which
will affect checking the right order status while trading.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpapi/ctpagent/autopos: fix can not check right order status

1) Add new helper methods to manage order status for trader agent.
2) Enable agent's callback in OnRspOrderInsert for trader api.
3) Update position methods using the helpers introduced in #1.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpParser: add support to close positions opened today

Add support to close positions opened today (OF_CloseToday).

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:autopos: fix exception while halting

Fix an exception caused while halting.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
test:testctp: update test to CtpAutoPosition

Update test to CtpAutoPosition to halt using its own halt().

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp: re-encode error.xml using utf-8

Xml parser minidom can not work with gb2312 format with
which error.xml was encoded, so re-encode it using utf-8.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp: add ctperrors module

Add ctperrors module to parse ctp error messages.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctperrors: add method to make combined error message

Add errorMsgFactory() to make combined error message.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpapi: fix recording error messages using ascii code

Change to fetch error messages locally according to error id
using CtpErrorParser.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>