示例#1
0
def main():
    """主测试函数,出现堵塞时可以考虑使用sleep"""
    reqid = 0

    # 创建Qt应用对象,用于事件循环
    app = QtGui.QApplication(sys.argv)

    # encoding: UTF-8# 创建API对象
    api = TestMdApi()

    # 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址
    api.createDFITCMdApi()  #此API包含获取行情相关的指令

    # 初始化api,连接前置机
    api.init("tcp://203.187.171.250:10915")
    sleep(0.5)

    # 登陆,测试通过
    loginReq = {}
    reqid += 1
    loginReq['lRequestID'] = reqid  # 参数作为字典键值的方式传入
    loginReq['passwd'] = '123'  # 键名和C++中的结构体成员名对应
    loginReq['accountID'] = '000200002874'  # 请求数必须保持唯一性
    i = api.reqUserLogin(loginReq)
    sleep(0.5)

    # 订阅合约,测试通过
    reqid += 1
    i = api.subscribeMarketData('i1605', reqid)

    ## 退订合约,测试通过
    #reqid += 1
    #i = api.unSubscribeMarketData('i1605', reqid)

    input()
示例#2
0
文件: tdtest.py 项目: yywangfei/vnpy
def main():
    """主测试函数,出现堵塞时可以考虑使用sleep"""
    reqid = 0
    
    # 创建Qt应用对象,用于事件循环
    app = QtGui.QApplication(sys.argv)

    # 创建API对象,测试通过
    api = TestTdApi()
    
    # 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址,测试通过
    api.createFtdcTraderApi('')
    
    # 设置数据流重传方式,测试通过
    api.subscribePrivateTopic(1)
    api.subscribePublicTopic(1)
    
    # 注册前置机地址,测试通过
    api.registerFront("tcp://180.168.146.187:10031")
    
    # 初始化api,连接前置机,测试通过
    api.init()
    sleep(0.5)
    
    # 登陆,测试通过
    loginReq = {}                           # 创建一个空字典
    loginReq['UserID'] = '053430'         # 参数作为字典键值的方式传入
    loginReq['Password'] = '******'         # 键名和C++中的结构体成员名对应
    loginReq['BrokerID'] = '9999'    
    reqid = reqid + 1                       # 请求数必须保持唯一性
    i = api.reqUserLogin(loginReq, reqid)
    sleep(0.5)
    
    ## 查询合约, 测试通过
    #reqid = reqid + 1
    #i = api.reqQryInstrument({}, reqid)
    
    ## 查询结算, 测试通过
    #req = {}
    #req['BrokerID'] = api.brokerID
    #req['InvestorID'] = api.userID
    #reqid = reqid + 1
    #i = api.reqQrySettlementInfo(req, reqid)
    #sleep(0.5)
    
    ## 确认结算, 测试通过
    #req = {}
    #req['BrokerID'] = api.brokerID
    #req['InvestorID'] = api.userID    
    #reqid = reqid + 1
    #i = api.reqSettlementInfoConfirm(req, reqid)
    #sleep(0.5)
    
    
    # 连续运行
    app.exec_()
示例#3
0
文件: mdtest.py 项目: wenjiandu/vnpy
def main():
    """主测试函数,出现堵塞时可以考虑使用sleep"""
    reqid = 0

    # 创建Qt应用对象,用于事件循环
    app = QtGui.QApplication(sys.argv)

    # 创建API对象
    api = TestMdApi()

    # 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址
    api.createFtdcMdApi('')

    # 注册前置机地址
    api.registerFront("tcp://qqfz-md1.ctp.shcifco.com:32313")

    # 初始化api,连接前置机
    api.init()
    sleep(0.5)

    # 登陆
    loginReq = {}  # 创建一个空字典
    loginReq['UserID'] = ''  # 参数作为字典键值的方式传入
    loginReq['Password'] = ''  # 键名和C++中的结构体成员名对应
    loginReq['BrokerID'] = ''
    reqid = reqid + 1  # 请求数必须保持唯一性
    i = api.reqUserLogin(loginReq, 1)
    sleep(0.5)

    ## 登出,测试出错(无此功能)
    #reqid = reqid + 1
    #i = api.reqUserLogout({}, 1)
    #sleep(0.5)

    ## 安全退出,测试通过
    #i = api.exit()

    ## 获取交易日,目前输出为空
    #day = api.getTradingDay()
    #print 'Trading Day is:' + str(day)
    #sleep(0.5)

    ## 订阅合约,测试通过
    #i = api.subscribeMarketData('IF1505')

    ## 退订合约,测试通过
    #i = api.unSubscribeMarketData('IF1505')

    # 订阅询价,测试通过
    i = api.subscribeForQuoteRsp('IO1504-C-3900')

    # 退订询价,测试通过
    i = api.unSubscribeForQuoteRsp('IO1504-C-3900')

    # 连续运行,用于输出行情
    app.exec_()
示例#4
0
文件: mdtest.py 项目: yywangfei/vnpy
def main():
    """主测试函数,出现堵塞时可以考虑使用sleep"""
    reqid = 0
    
    #创建Qt应用对象,用于事件循环
    app = QtGui.QApplication(sys.argv)

    # 创建API对象
    api = TestMdApi()
    
    # 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址
    api.createOTPMdApi('')
    
    # 注册前置机地址
    api.registerFront("tcp://115.238.106.253:18993")
    #api.registerFront("tcp://124.160.44.166:17159")     # 其他测试地址
    
    # 初始化api,连接前置机
    api.init()
    sleep(8)
    
    # 登陆
    loginReq = {}                           # 创建一个空字典
    loginReq['UserID'] = ''                 # 参数作为字典键值的方式传入
    loginReq['Password'] = ''               # 键名和C++中的结构体成员名对应
    loginReq['BrokerID'] = ''    
    reqid = reqid + 1                       # 请求数必须保持唯一性
    i = api.reqUserLogin(loginReq, 1)
    sleep(3)
    
    ## 登出,测试出错(无此功能)
    #reqid = reqid + 1
    #i = api.reqUserLogout({}, 1)
    #sleep(0.5)
    
    ## 安全退出,测试通过
    #i = api.exit()
    
    ## 获取交易日,目前输出为空
    #day = api.getTradingDay()
    #print 'Trading Day is:' + str(day)
    #sleep(0.5)
    
    ## 订阅合约,测试通过
    #req = {}
    #req['InstrumentID'] = '510050'
    #req['ExchangeID'] = 'SHE'
    #i = api.subscribeMarketData(req)
    
    ## 退订合约,测试通过
    #i = api.unSubscribeMarketData('IF1505')
    
    # 连续运行,用于输出行情
    app.exec_()
示例#5
0
def get_string(prompt="What is your name? ", title="Title",
               default_response="PyQt4", app=None):
    """GUI equivalent of input()."""

    if app is None:
        app = QtGui.QApplication([])
    app.dialog = QtGui.QInputDialog()
    text, ok = app.dialog.getText(None, title, prompt,
                                  QtGui.QLineEdit.Normal,
                                  default_response)
    app.quit()
    if ok:
        return text
示例#6
0
def main():
    # kills the program when you hit Cntl+C from the command line
    # doesn't save the current state as presumably there's been an error
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    import sys
    # Someone is launching this directly
    # Create the QApplication
    app = QtGui.QApplication(sys.argv)
    #The Main window
    #g = GeometryHandle()
    #g.add('main', color=(0, 0, 0), line_thickness=0.0)
    #g.get_grid('name')
    #g.set_color('name')
    #g.set_grid('name')
    #g.set_grid('name')
    parent = app
    green = (0, 255, 0)

    point_properties = AltGeometry(parent,
                                   'point_properties',
                                   color=green,
                                   point_size=5,
                                   opacity=1.0)

    points = {
        1: ['LERoot', 0, 'R', 1.0, 2.0, 3.0],
        2: ['LETip', 42, 'S', 2.0, 3.0, 4.0],
    }
    coords = {
        0: ['R'],
        2: ['C'],
        42: ['S'],
    }
    d = {
        'point_properties': point_properties,
        'points': points,
        'active_point': 2,
        'coords': coords,
    }
    main_window = BreakSurfaceMenu(d, win_parent=None)
    main_window.show()
    # Enter the main loop
    app.exec_()
示例#7
0
def main():  # pragma: no cover
    # kills the program when you hit Cntl+C from the command line
    # doesn't save the current state as presumably there's been an error
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    import sys
    # Someone is launching this directly
    # Create the QApplication
    app = QtGui.QApplication(sys.argv)
    #The Main window
    d = {
        'name': 'plane_test',
        'origin': [1., 2., 3.],
        'normal': [4., 5., 6.],
        'a': [7., 8., 9.],
        'b': [10., 11., 12.],
        'is_horizontal': False,
    }
    main_window = BCMap(d, win_parent=None)
    main_window.show()
    # Enter the main loop
    app.exec_()
示例#8
0
            if self.fcst.isChecked() is True:
                self.parcel_types.append('FCST')
            if self.mu.isChecked() is True:
                self.parcel_types.append('MU')
            if self.eff.isChecked() is True:
                self.parcel_types.append('EFF')
            if self.usr.isChecked() is True:
                self.parcel_types.append('USER')

            self.thermo.pcl_types = self.parcel_types
            self.thermo.skewt_pcl = 0
            self.thermo.ylast = self.thermo.label_height
            pcl_to_pass = self.thermo.parcels[self.thermo.pcl_types[
                self.thermo.skewt_pcl]]
            self.thermo.updatepcl.emit(pcl_to_pass)
            self.thermo.clearData()
            self.thermo.plotBackground()
            self.thermo.plotData()
            self.thermo.update()
            self.thermo.parentWidget().setFocus()
            self.hide()


if __name__ == '__main__':
    app_frame = QtGui.QApplication([])
    #tester = plotText(['sfcpcl', 'mlpcl', 'mupcl'])
    tester = plotBackgroundText()
    #tester.setProf()
    tester.show()
    app_frame.exec_()
示例#9
0
import sys
import numpy as np
from qtpy import QtGui, QtCore, QtWidgets
from sharppy.viz import plotSkewT, plotHodo, plotText, plotAnalogues
from sharppy.viz import plotThetae, plotWinds, plotSpeed, plotKinematics
from sharppy.viz import plotSlinky, plotWatch, plotAdvection, plotSTP
from sharppy.viz import plotGeneric
from sharppy.sharptab.constants import *
from sharppy.sounding import prof, plot_title

# Setup Application
app = QtGui.QApplication(sys.argv)
mainWindow = QtGui.QMainWindow()
x = 1180
y = 800
mainWindow.setGeometry(0, 0, x, y)
title = 'SHARPpy: Sounding and Hodograph Analysis and Research Program '
title += 'in Python'
mainWindow.setWindowTitle(title)
mainWindow.setStyleSheet("QMainWindow {background-color: rgb(0, 0, 0);}")
centralWidget = QtWidgets.QFrame()
mainWindow.setCentralWidget(centralWidget)
grid = QtGui.QGridLayout()
grid.setHorizontalSpacing(0)
grid.setVerticalSpacing(2)
centralWidget.setLayout(grid)

# Handle the Upper Left
## plot the main sounding
#print prof.right_scp, prof.left_scp
brand = 'SHARPpy Beta'
示例#10
0
        main_layout = QtGui.QVBoxLayout()
        main_layout.addWidget(group_box)
        main_layout.addWidget(QtGui.QLabel(instruction))
        main_layout.addWidget(button_box)
        self.setLayout(main_layout)
        self.setWindowTitle(title)
        self.show()
        self.raise_()

    def check_box_toggled(self):
        """Callback when a checkbox is toggled"""
        self.locale = self.qm_files_choices[self.sender()]

    def confirm(self):
        """Callback from confirm_button used to set the locale"""
        if self.locale != self.parent.config['locale']:
            self.parent.set_locale(self.locale)
        print(self.locale)  # feedback to launcher
        self.close()


if __name__ == '__main__':
    app = QtGui.QApplication([])
    # mocks
    app.config = {'locale': None}
    app.set_locale = lambda x: x
    #
    selector = LanguageSelector(app, title="title")
    selector.exec_()
    app.quit()
def run():
    app = QtGui.QApplication(sys.argv)
    GUI = Window()
    sys.exit(app.exec_())
示例#12
0
def main():
    """主测试函数,出现堵塞时可以考虑使用sleep"""
    reqid = 0

    # 创建Qt应用对象,用于事件循环
    app = QtGui.QApplication(sys.argv)

    # 创建API对象,测试通过
    api = TestTdApi()

    # 在C++环境中创建TdApi对象,传入参数是希望用来保存.con文件的地址,测试通过
    api.createDFITCTraderApi()

    # 注册前置机地址,初始化api
    api.init("tcp://203.187.171.250:10910")

    sleep(0.5)

    # 登陆,测试通过
    loginReq = {}
    reqid += 1
    loginReq['lRequestID'] = reqid  # 参数作为字典键值的方式传入
    loginReq['passwd'] = '123'  # 键名和C++中的结构体成员名对应
    loginReq['accountID'] = '000200002874'  # 请求数必须保持唯一性
    i = api.reqUserLogin(loginReq)
    sleep(0.5)

    #----------------------------------------------------------------------
    def sendOrder(api, symbol, price, volume, reqid):
        """发单"""

        req = {}
        req['accountID'] = api.accountID
        req['instrumentID'] = symbol
        req['buySellType'] = 1
        req['openCloseType'] = 1
        req['localOrderID'] = 1
        req['insertPrice'] = price
        req['orderAmount'] = volume
        req['speculator'] = 0
        req['orderProperty'] = '0'
        req['orderType'] = 1
        req['instrumentType'] = 0
        req['insertType'] = 0x0001

        i = api.reqInsertOrder(req)

        return i

    def cancelOrder(api, orderRef, reqid):
        """撤单"""

        req = {}

        req['accountID'] = api.accountID
        req['instrumentID'] = 'i1605'
        req['localOrderID'] = orderRef

        i = api.reqCancelOrder(req)
        return i

    # 发单测试, 测试通过
    reqid = reqid + 1
    sendOrder(api, 'i1605', 299, 1, reqid)
    sleep(3)
    # 撤单测试, 待测试
    reqid = reqid + 1
    cancelOrder(api, 1, reqid)

    input()
示例#13
0
def main():
    _ = QtGui.QApplication([])
    dialog = Dialog()
    dialog.exec_()