掘金社区

Stop()函数没有效果Pinned highlighted

130211***055 发表在掘金2 2017-04-26 16:02:32

掘金2
440
0
0

-- coding: utf-8 --

"""
Created on Wed Apr 26 22:35:46 2017

@author: ksz
"""

from gmsdk.api import StrategyBase
from gmsdk import *
import tushare as ts
import time
import pandas as pd
import numpy as np
import logging
class Mystrategy(StrategyBase):
    def __init__(self, *args, **kwargs):
        super(Mystrategy, self).__init__(*args, **kwargs)


    def on_login(self):
        pass

    def on_error(self, code, msg):
        pass

    def on_tick(self, tick):
        pass
    
    def on_bar(self, bar):
        print('===============================')
        print (bar.strtime[8:10])
        print (bar.exchange,bar.sec_id)
        self.stop()
    def on_execrpt(self, res):
        pass

    def on_order_status(self, order):
        pass

    def on_order_new(self, res):
        pass

    def on_order_filled(self, res):
        pass

    def on_order_partiall_filled(self, res):
        pass

    def on_order_stop_executed(self, res):
        pass

    def on_order_canceled(self, res):
        pass

    def on_order_cancel_rejected(self, res):
        pass

if __name__ == '__main__':
    mystrategy = Mystrategy(
        username='13021133055',
        password='123456',
        strategy_id='b4845214-2a58-11e7-aab1-94de8069f806',
        subscribe_symbols='SHSE.000300.bar.daily', 
        mode=4,
        td_addr='localhost:8001'
    )
    print(mystrategy.subscribe_symbols)
    mystrategy.backtest_config(
        start_time='2017-04-03 11:00:00',
        end_time='2017-04-21 11:30:00',
        initial_cash=10000,
        transaction_ratio=0.5,
        commission_ratio=0.1,
        slippage_ratio=0.1,
        price_type=1)
    ret = mystrategy.run()
    print('exit code: ', ret)
    print(mystrategy.subscribe_symbols)

再简单不过的程序了,按道理一开始运行就开停下来,但是他一直运行到结束都不停,这是怎么回事呢@bidong

暂无评论

Looks like your connection to 掘金量化社区 - 量化交易者的策略交流学习社区 was lost, please wait while we try to reconnect.