ctp:testctp: add test to CtpData

Merged zw-dev c75bed91a0 and ba0e391694.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:futures/turtle: add method to switch on CTP

1) Add method to switch on CTP.
2) Update __init__ for both Futures and Turtle to adjust CTP.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
misc: move runstat.py from regress to misc

Move runstat.py from regress to misc since it will be
used in CTP.

Merged zw-dev 38c7ede5.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
misc: separate run control from emulate module

Separate run control from emulate module to be an
independent module so that it can be used globally.

Merged zw-dev 38c7ede5.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
regress:regression: import runctrl and runstat from misc

Update to import runctrl and runstat from misc since these
two modules have been moved to misc.

Merged zw-dev 38c7ede5.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:futures: remove useless importing to runstat

Remove useless importing to runstat.

Merged zw-dev 38c7ede5.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpagent: make TraderAgent as an uniform trader interface

1) Remove self.instruments and make TraderAgent itself can be
   used for any passed instrument.
2) Add locks to protect reqest_id and order_ref.
3) Add is_order_success().

Merged zw-dev 7727d8ad.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpapi: remove useless self.instruments for trader api

Since trader api only works as an independent interface to
remote server, so remove useless self.instruments.

Merged zw-dev 7727d8ad.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp: add posmgr module to manage positions

Add posmgr module to work as positions manager interface, so
we can avoid managing positions using trader agents ourselves.

Merged zw-dev 8d87e95b.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:testctp: add test to posmgr module

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:posmgr: add cos_flag to close long/short positions

cos_flag is required to describe which kind of positions
to be closed.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp: rename posmgr to autopos

1) Rename posmgr to autopos since it always manages
   positions automatically.
2) Add global definitions for OffsetFlag and Direction.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpagent: fix is_order_success() not working

Order map dict needs a string instead of an int value
to search the right element, fix it.

Merged zw-dev ca637049.

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

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy: add support to manage ctp positions

1) Add 'extra' attribute for Date.
2) Upadte all methods related to positions in Futures.
3) Update moveToNextTick() to support ctp.
4) Update closePosition() for MarketRunStat to support
   close multiple positions in one time.
5) Make ctp as a subsystem.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turt1: update since positions interface changed

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