strategy:futures: fix bugs to close long/short position

1) Fix calculating wrong profit for log positions.
2) fix using closeShortPosition() to close long positions.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:futures/turtle: adjust ctp to share emuRunCtrl with emulation mode

1) Adjust ctp to share emuRunCtrl with emulation mode since ctp needs to run
   a same emulation process to determine the current runtime statistics.
2) Update moveToNextTick() to set right tick using curDay at end of emulation
   for ctp thread.

Merged zw-dev 5c4375a1.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turt1: fix using wrong price records for ctp

Need always using the returned price by openShortPosition() or
openLongPosition() as price records in strategies since the ctp
price varies each second, fix it.

Merged zw-dev 5c4375a1.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:testctp: change back to use monitor

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
misc:painter: add sub-window support

1) Add sub-window support which is useful to separate terminal
   into multiple windows and display respectively.
2) Add test to sub-window and update test to Painter.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:ctpagent: update start_monitor() for market data agent

Update start_monitor() to display in a sub-window of a Painter.

Merged zw-dev d9cdab51.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:testctp: update test to md using new Painter interface

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:turtle: wait a moment before move to next tick

Sleep a while before move to next tick to reduce cpu load.

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

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

Add ctpOn to replace dataSet.extra to keep logically
reasonable and Futures independent.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
strategy:futures: fix return wrong values

Fix return wrong values if positions are full. Keeps
consistency with autopos module.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
regress:emulate: support thread entry and self-defined args

Emulate supports thread entry and self-defined arguments, and
makes it as a uniform interface to emulation and ctp.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
regress:regression: update to use new Emulate interface

Update to use new Emulate interface since Emulate has
been enhenced to support thread entry.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
win: add config subsystem

Add futconfig and genconfig modules.

Merged zw-dev e1189f57.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
misc: move genconfig module from config to misc

Move genconfig from config to misc so that it could be used globally.

Merged zw-dev 94287492.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp: move futconfig module from config to ctp

Move futconfig from config to ctp since it is only used for
Future configuration.

Merged zw-dev 94287492.

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

Add test.ini and remove __init__.py.

Merged zw-dev 94287492.

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

Add ctpParser module which is the command options parser
for ctp subsystem.

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
ctp:futconfig: fix wrong test ini name

Signed-off-by: Zhengwang Ruan <ruan.zhengwang@gmail.com>
misc:runctrl: mute the logs to synchronize ticks

Mute the logs to synchronize ticks when test timetick
lags behind the source timetick.

Merged zw-dev dd97e8ee.

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