Example #1
0
def run_child():
    """
    Running in the child process.
    """

    subSymbols = CBMomSub + ETFMomSub

    class myEngine(PushBaseEngine):
        EventType = 'sina'

        def init(self):
            self.source = easyquotation.use('sina')

        def fetch_quotation(self):
            return self.source.stocks(subSymbols)

    broker = 'ht'
    need_data = 'ht.json'
    quotation_engine = myEngine  # DefaultQuotationEngine
    quotation_engine.PushInterval = int(3)  # 每秒推送一次行情
    log_type = 'file'  # 'stdout'
    log_filepath = 'htMulti.log'
    log_handler = DefaultLogHandler(name='华泰多策略', log_type=log_type, filepath=log_filepath)

    m = easyquant.MainEngine(
        broker,
        need_data,
        quotation_engines=[quotation_engine],
        log_handler=log_handler
    )
    m.load_strategy(names=['CBMom', 'ETFMom'])
    m.start()

    while True:
        sleep(1)
Example #2
0
def startTHS():
    broker = 'ths'
    need_data = "ht.json"
    quotation_engine = DefaultQuotationEngine
    quotation_engine.PushInterval = 10
    log_handler = DefaultLogHandler(name='macd',
                                    log_type="file",
                                    filepath="engine.log")

    m = easyquant.MainEngine(broker,
                             need_data,
                             quotation_engines=[quotation_engine],
                             log_handler=log_handler)
    # m.is_watch_strategy = True  # 策略文件出现改动时,自动重载,不建议在生产环境下使用
    m.load_strategy()
    m.start()
Example #3
0
    def init(self):
        self.source = easyquotation.use('lf')

    def fetch_quotation(self):
        return self.source.stocks(['162411', '000002'])


quotation_choose = input(
    '请输入使用行情引擎 1: sina 2: leverfun 十档 行情(目前只选择了 162411, 000002)\n:')

quotation_engine = DefaultQuotationEngine if quotation_choose == '1' else LFEngine

push_interval = int(input('请输入行情推送间隔(s)\n:'))
quotation_engine.PushInterval = push_interval

log_type_choose = input('请输入 log 记录方式: 1: 显示在屏幕 2: 记录到指定文件\n: ')
log_type = 'stdout' if log_type_choose == '1' else 'file'

log_filepath = input('请输入 log 文件记录路径\n: ') if log_type == 'file' else ''

log_handler = DefaultLogHandler(name='测试',
                                log_type=log_type,
                                filepath=log_filepath)

m = easyquant.MainEngine(broker,
                         need_data,
                         quotation_engines=[quotation_engine],
                         log_handler=log_handler)
m.load_strategy()
m.start()
Example #4
0
import easyquant

print('easyquant 测试 DEMO')
print('请输入你使用的券商:')
choose = input('1: 华泰 2: 佣金宝 \n:')
broker = 'ht' if choose == '1' else 'yjb'


def get_broker_need_data(choose_broker):
    need_data = input('请输入你的帐号配置文件路径(直接回车使用 %s.json):' % choose_broker)
    if need_data == '':
        return '%s.json' % choose_broker
    return need_data

m = easyquant.MainEngine(broker, get_broker_need_data(broker))
m.load_strategy()
m.start()
Example #5
0
#!/usr/bin/python3
import easyquotation

import easyquant
from easyquant import DefaultQuotationEngine, DefaultLogHandler, PushBaseEngine

quotation_engine = DefaultQuotationEngine

push_interval = int(input('请输入行情推送间隔(s)\n:'))
quotation_engine.PushInterval = push_interval

log_handler = DefaultLogHandler(name='Monitor', log_type='stdout', filepath='')

m = easyquant.MainEngine(None,
                         None,
                         quotation_engines=[quotation_engine],
                         log_handler=log_handler)
m.is_watch_strategy = True  # 策略文件出现改动时,自动重载,不建议在生产环境下使用
m.load_strategy()
m.start()
Example #6
0
        return self.source.stocks(self.get_push_stocks())


#quotation_choose = input('请输入使用行情引擎 1: sina 2: leverfun 十档 行情(目前只选择了 162411, 000002)\n:')
quotation_choose = 2
quotation_engine = DefaultQuotationEngine if quotation_choose == '1' else LFEngine

#push_interval = int(input('请输入行情推送间隔(s)\n:'))
push_interval = 30
quotation_engine.PushInterval = push_interval

#log_type_choose = input('请输入 log 记录方式: 1: 显示在屏幕 2: 记录到指定文件\n: ')
#log_type = 'stdout' if log_type_choose == '1' else 'file'
log_type = 'file'
this_time = datetime.datetime.now()
date_str = this_time.strftime('%Y%m%d')
#log_filepath = input('请输入 log 文件记录路径\n: ') if log_type == 'file' else ''
log_filepath = 'strategy_log_%s.txt' % date_str

log_handler = DefaultLogHandler(name='测试',
                                log_type=log_type,
                                filepath=log_filepath)

m = easyquant.MainEngine(broker='yh',
                         need_data='yh.json',
                         quotation_engines=[quotation_engine],
                         log_handler=log_handler,
                         stocks=hold_stocks)  #)init_push_stocks)
m.load_strategy()
m.start()
Example #7
0
import easyquant

print('easyquant 测试 DEMO')
print('请输入你使用的券商:')
choose = input('1: 华泰 2: 佣金宝 \n:')
broker = 'ht' if choose == '1' else 'yjb'

if broker == 'ht':
    need_data = input('请输入你的华泰帐号配置文件路径(直接回车使用 me.json):')
    if need_data == '':
        need_data = 'me.json'
elif broker == 'yjb':
    need_data = input('请输入你的佣金宝 token:')

m = easyquant.MainEngine(broker, need_data)
m.load_strategy()
m.start()
Example #8
0
import easyquant

m = easyquant.MainEngine('ht', 'me.json')
m.load_strategy()
m.start()