Ejemplo n.º 1
0
    def __init__(self):
        # 新浪接口
        self.Int = sinaInterface()
        # sqlserver 期权每3秒行情记录
        self.sPrice = sh50_price()
        # sqlserver sh510050 每3秒行情记录
        self.Owner = sh510050()
        # sqlserver 监测结果表
        self.Spy = sh50_spy()

        self.price_owner = 0
        # 资金成本
        self.interest = float(config_ini.get("interest", session="SH50")) / 365
        # 带融券的资金成本
        self.interest_rong = float(
            config_ini.get("interest_rong", session="SH50")) / 365
        # 买入阈值
        self.buy_line_0 = float(config_ini.get("buy_line_0", session="SH50"))
        self.buy_line_1 = float(config_ini.get("buy_line_1", session="SH50"))

        self.table_head = ""
        self.table_end = ""
        self.method = 'ma60'
        self.ws = s_webSocket("ws://%s:8090/etf50option" %
                              config_ini.get("ws.host", session="db"))
        self.keylist2 = ["result", "price_ask", "price_bid"]
        self.titlesList = self.Spy.keylist[:-2] + [
            "result_1", "price_ask", "price_bid"
        ]
Ejemplo n.º 2
0
    def __init__(self):
        # 新浪接口
        super().__init__()

        self.codes = ['510050.XSHG']

        self.iniAmount = 40000
        self.multiplier = 10000
        self.currentVol = 0
        self.currentPositionType = 0
        self.scale = 2.0
        self.ratio = 2
        self.shift = 0.002
        self.scaleDiff2 = 1.0
        self.isParamSave = True

        self.ws = s_webSocket("ws://%s:8090/etf50boll" %
                              config_ini.get("ws.host", session="db"))
        self.titleList = [
            'createdate', 'code', 'name', 'isBuy', 'vol', 'price', 'ownerPrice'
        ]
        self.table_head = ""
        self.table_end = ""
        self.method = 'bull4'
        self.viewItemList = [
            'createTime', 'close', 'pow', 'top', 'low', 'sarm', 'kdjm', 'powm',
            'isopen'
        ]
Ejemplo n.º 3
0
    def __init__(self):
        self.stage = "ETF"
        self.FT = fytuObject()
        # 股票列表
        self.stock_code_list = "SZ.159901,SZ.159902,SZ.159915,SH.510050,SH.510900, SH.510300,SH.519920,\
                                         SH.512160,SH.512880,SH.512800,SH.510180,SH.512660".split(
            ",")
        #账户
        self.account = self.iniKey('account')

        #interval = self.iniKey('interval')
        self.k_amount = int(self.iniKey('k_amount'))
        self.k_type = self.iniKey('k_type')

        #self.ETF = ETFRecord() #
        #self.Acc = account() # 账户

        self.Matic = Matic_interface()  # matic 接口类
        # 上一k线时段成交量
        self.lastVolume_Map = {}
        self.ws = s_webSocket("ws://%s:8090/forward" %
                              config_ini.get("ws.host", session="db"))
Ejemplo n.º 4
0
    def checkPosition(self, docs, isOpen, reverse=1, refresh=True):
        """ 提交前检查持仓和资金状况 """
        if isOpen == 1:
            # 开仓检查资金余额
            minRate = float(config_ini.get("minMarginRate", "CTP"))  # 保证金准备金比例
            fund = self.Available  # 可用保证金和所有保证金
            needs = sum([
                d['vol'] * self.baseInfo.att(d['code'], 'margin_rate')
                for d in docs
            ])
            return 0 if (fund[0] > needs and
                         ((fund[0] - needs) / fund[1] > minRate)) else -1

        else:
            # 平仓检查仓位余额
            if not refresh and self.preMap is not None:
                posMap = self.preMap
            else:
                self.preMap = posMap = self.posMap

            for doc in docs:
                # if doc['name'] =='IH': print(posMap.keys())
                if 'name' in doc:
                    key = '%s_%s' % (doc['name'],
                                     ('0' if
                                      (doc['mode'] * reverse < 0) else '1'))  #
                else:
                    key = '%s_%s' % (doc['symbol'],
                                     ('0' if
                                      (doc['mode'] * reverse < 0) else '1'))  #

                if not key in posMap or posMap[key][0] < doc['hands']:
                    return -2  #

                elif len(posMap[key]) > 2 and posMap[key][1] < doc[
                        'hands'] and posMap[key][2] == 'SHFE':
                    """区分是否时上期所平今仓, 仓位小于Yd持仓 """
                    doc.update({'istoday': 1})
            return 0
Ejemplo n.º 5
0
    def __init__(self):
        # 新浪接口
        self.Int = sinaInterface()
        self.Record = sh50_orderForm()
        self.Rice = interface_Rice()
        self.Rice.iniTimeArea = [('09:30:00', "11:30:00"),
                                 ('13:00:00', '15:00:00')]
        self.Rice.setTimeArea('15:00:00')
        self.Tick = mon_tick()
        self.isParamSave = False

        self.codes = ['510050.XSHG']
        self.ktypeMap = {'510050.XSHG': 30}

        self.period = '30m'
        self.timePeriodList = [5, 10, 20, 60]
        self.timePeriods = 60
        self.iniAmount = 40000
        self.multiplier = 10000
        self.currentVol = 0
        self.currentPositionType = 0
        self.ratio = 2
        self.status = 0

        self.ws = s_webSocket("ws://%s:8090/etf50optiontrend" %
                              config_ini.get("ws.host", session="db"))
        self.titleList = [
            'createdate', 'code', 'name', 'isBuy', 'mode', 'vol', 'price',
            'ownerPrice'
        ]
        self.table_head = ""
        self.table_end = ""
        self.method = 'ma60'
        self.viewItemList = [
            'createTime', 'close', 'ma5', 'ma10', 'ma20', 'ma60', 'vol', 'mode'
        ]
Ejemplo n.º 6
0
 def iniKey(self, key, db='GuangFa'):
     return config_ini.get(key, session=db)
Ejemplo n.º 7
0
Created on Sat Apr  1 14:35:13 2017

@author: admin

      手动通知ETF买单

"""

# from com.data.model_warrant import warModel
from com.base.public import public, config_ini, logger
from com.model.model_etf4 import etf4_compare
import time
import sys

if __name__ == '__main__':
    inter = int(config_ini.get("interval", session="ETF"))
    obj = etf4_compare()

    while 1:
        try:
            obj.FT.reconnect()
        except:
            sys.exit()
            break

        # 非交易日,退出
        if not obj.FT.isTradeDate("SH"):
            print("非交易日")
            exit()

        d, t = public.getDate(), public.getDatetime()
Ejemplo n.º 8
0
 def iniKey(self, key, db='Matic'):
     return config_ini.get(key, session=db)
Ejemplo n.º 9
0
      sh50自动记录

"""

# from com.data.model_warrant import warModel
from com.base.public import public, config_ini, logger
from com.model.model_sh50 import model_sh50
from com.data.data_base import Stock

import time
import sys
import os

if __name__ == '__main__':
    inter = int(config_ini.get("interval", session="SH50"))
    obj = model_sh50()
    ST = Stock()
    print(inter)
    while 1:
        # 非交易日,退出
        time0 = time.time()
        if not ST.isTradeDate():
            print("非交易日")
            break

        isT = ST.isTradeTime("SH")
        if isT[0]:
            # 交易时间记录
            obj.record()
            #logger.info("sh50记录并计算,耗时: %s" % str(time.time()-time0))
Ejemplo n.º 10
0
 def iniKey(self, key):
     return config_ini.get(key, session=self.stage)