【协会平台入门】实现登录和构建一个回测

#1

1、网址:http://www.thquant.com
2、点击策略-我的策略
image
3、点击微信登录,扫码登录
image
4、登录后点击“开启智能投资之旅”-——“新建策略——股票”
image
5、在编辑框圆圈处编写策略
image
6、示例代码


# encoding: UTF-8
import sys
import os
import time
import numpy as np
PROJECT_BASE = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(PROJECT_BASE)

from signalTemplate import SignalTemplate
from random import Random


class UserCode(SignalTemplate):
    def onInit(self, context):
        self.setSettings({

            "symbol": ["stock#600865"]
        })

        self.period = 5

    # ———————————————————————————————————
    def onStart(self, context):
        pass

    # ———————————————————————————————————
    def onStop(self, context):
        pass

    # ———————————————————————————————————
    def onTick(self, tick, context):
        pass

    # ———————————————————————————————————
    def onBar(self, bar, context):

        bar = bar["stock#600865"]
        t = bar.datetime.timetuple()
        timeStamp = int(time.mktime(t))



        r = Random()

        return {
            "money": 0.2,
            # "stock#600865": r.random()
            "stock#600865": 0.8
        }

7、时间范围选择:选择如下时间范围,分钟回测,点击“运行回测”
image
8、回测效果图
image

split this topic #2

A post was merged into an existing topic: About the 量化平台入门 category

closed #3