예제 #1
0
def initializeTests():

    yPosition = UI.SCREENHEIGHT / 2 - optionSize / 2

    for i in range(0, len(tests)):

        xPosition = (((i / len(tests)) * UI.SCREENWIDTH) + UI.SCREENWIDTH /
                     (2 * (len(tests)))) - optionSize / 2
        test = None

        #screen, numRuns, numBlocks, speed, testName

        if tests[i] == "Opto Test":
            #Num blocks must be multiple of 4
            test = t.Test(screen, 300, 20, 7, "Opto Test")
        elif tests[i] == "Random Test":
            test = t.Test(screen, 11, None, 1, "Random Test")
        elif tests[i] == "Saccades Test":
            test = t.Test(screen, 4, None, 0.25, "Saccades Test")
        elif tests[i] == "Smooth Test":
            test = t.Test(screen, 200, None, None, "Smooth Test")
        else:
            print("Something went wrong with test names")

        options.append(
            opt.Option(tests[i], xPosition, yPosition, optionSize, test))
예제 #2
0
 def __init__(self):
     self.car = ""
     self.quiz = None
     self.quiz_answers = None
     self.option = option.Option()
     def show_main_menu(self):
         print(self.Option.name);
예제 #3
0
def bak_change(background , palette , op):
    color_change = option.Option(background , palette)
    if op == '0':
    	color_change.PaletteBased_Recolor()
    else:
    	color_change.LinearMapping_Recolor()
    return background.zIndex
예제 #4
0
 def __init__(self, userStyle):
     self.windowList = []
     globalref.treeControl = self
     self.serverSocket = None
     mainVersion = '.'.join(__version__.split('.')[:2])
     globalref.options = option.Option(u'treeline-%s' % mainVersion, 21)
     globalref.options.loadAll(optiondefaults.defaultOutput())
     iconPathList = [iconPath, os.path.join(globalref.modPath, u'icons/'),
                     os.path.join(globalref.modPath, u'../icons/')]
     if not iconPath:
         del iconPathList[0]
     globalref.treeIcons = icondict.IconDict()
     globalref.treeIcons.addIconPath([os.path.join(path, u'tree') for path
                                      in iconPathList])
     globalref.treeIcons.addIconPath([globalref.options.iconPath])
     treemainwin.TreeMainWin.toolIcons = icondict.IconDict()
     treemainwin.TreeMainWin.toolIcons.\
                 addIconPath([os.path.join(path, u'toolbar')
                              for path in iconPathList],
                             [u'', u'32x32', u'16x16'])
     treemainwin.TreeMainWin.toolIcons.loadAllIcons()
     windowIcon = globalref.treeIcons.getIcon(u'treeline')
     if windowIcon:
         QtGui.QApplication.setWindowIcon(windowIcon)
     if not userStyle:
         if sys.platform.startswith('dar'):
             QtGui.QApplication.setStyle('macintosh')
         elif not sys.platform.startswith('win'):
             QtGui.QApplication.setStyle('plastique')
     self.recentFiles = recentfiles.RecentFileList()
     qApp = QtGui.QApplication.instance()
     qApp.connect(qApp, QtCore.SIGNAL('focusChanged(QWidget*, QWidget*)'),
                  self.updateFocus)
예제 #5
0
    def testOptionClassCreation(self):

        # Below we test if an exception is thrown when try to instantiate the class.
        # We should not be able to instantiate the Option class.
        # TODO: This should be redone to use an assert failure.
        failed = False
        try:
            classObj = option.Option('SPY', 250, 'PUT', 0.3, 45)
        except NotImplementedError:
            failed = True

        # This should pass if an exception is raised above
        self.assertEqual(failed, True)
예제 #6
0
 def __init__(self):
     self.stack = calcstack.CalcStack()
     self.option = option.Option('rpcalc', 20)
     self.option.loadAll(optiondefaults.defaultList)
     self.restoreStack()
     self.xStr = ''
     self.updateXStr()
     self.flag = Mode.saveMode
     self.base = 10
     self.numBits = 0
     self.useTwosComplement = False
     self.history = []
     self.histChg = 0
     self.setAltBaseOptions()
예제 #7
0
def other_positions():
    delta = 0.0
    gamma = 0.0
    vega = 0.0
    theta = 0.0
    position = 0.0

    time = 21.0 / 365.0
    rate = 0.0

    opt1 = option.Option('C', 125.0, 124.08, 0.412, time, risk_free_rate=rate)
    print('Option 1: {}'.format(opt1.price))
    delta += opt1.delta * -12.0
    gamma += opt1.gamma * -12.0
    theta += opt1.theta * -12.0
    vega += opt1.vega * -12.0

    position += opt1.price * -12.0 * 100.0
    position += 124.08 * 500.0

    opt2 = option.Option('C', 125.0, 122.27, 0.4085, time, risk_free_rate=rate)
    opt3 = option.Option('P', 125.0, 122.27, 0.4085, time, risk_free_rate=rate)
    print('Straddle: {}'.format(opt2.price + opt3.price))
    delta += (opt2.delta + opt3.delta) * -50.0
    gamma += (opt2.gamma + opt3.gamma) * -50.0
    theta += (opt2.theta + opt3.theta) * -50.0
    vega += (opt2.vega + opt3.vega) * -50.0

    position += (opt2.price + opt3.price) * -50.0 * 100.0
    position += 122.27 * -300.0

    print('Position: {}'.format(position))
    print('Delta: {}'.format(delta * 100.0))
    print('Gamma: {}'.format(gamma * 100.0))
    print('Theta: {}'.format((theta / 365.0) * 100.0))
    print('Vega: {}'.format(vega))
예제 #8
0
def color_option(request):
    if request.method == 'POST':
        img = request.FILES['image']
        with open('image_option.png' , 'wb+') as des:
            des.write(img.read())
        palette = request.POST['palettes']
        #print type(palette)
        palette = [int(item) for item in palette.split(',')]
        
        index = 0
        palette_list = []
        while(index < len(palette)):
            palette_list.append(palette[index:index + 3])
            index = index +3

        background_type = int(request.POST['background_type'])
        print palette_list
        background = layout.Backgsround('image_option.png' , background_type)
        color_change = option.Option(background , palette_list)
    return render_to_response('index.html',{'flag':False})
예제 #9
0
def calc_slide(positions_file, underlying, sigma, time, risk_free_rate):
    positions = load_positions(positions_file)

    delta = 0.0
    gamma = 0.0
    vega = 0.0
    theta = 0.0
    pnl = 0.0

    for strike, inst_type, qty in positions.values:
        if inst_type == 'S':
            pnl += strike * qty
            delta += qty
        else:
            opt = option.Option(inst_type,
                                strike,
                                underlying,
                                sigma,
                                time,
                                risk_free_rate=risk_free_rate)

            delta += ((opt.delta * 100.0) * qty)
            print('Delta adjust: {}'.format(opt.delta * 100.0 * qty))
            gamma += (opt.gamma * 100.0) * qty  # Gamma is always positive
            vega += (opt.vega) * qty  # See p80
            theta += (opt.theta) * qty  # See p76

            pnl += opt.price * qty * 100.0

            print('Strike: {}, Type: {}, Qty: {}, Price: {}'.format(
                strike, inst_type, qty, opt.price))
            print('Delta: {}, Gamma: {}, Vega: {}, Theta: {}'.format(
                opt.delta, opt.gamma, opt.vega, opt.theta / 365.0))

    print('Delta:\t\t{}'.format(delta))
    print('Gamma:\t\t{}'.format(gamma))
    print('Vega:\t\t{}'.format(vega))
    print('Theta:\t\t{}'.format((theta / 365.0) * 100.0))
    print('Position Cost:\t\t{}'.format(pnl))
    print('Total PnL:\t\t{}'.format(pnl))
예제 #10
0
파일: poll.py 프로젝트: acriter/chooserbot
 def set_options(self, optionList):
     idx = 0
     for option in optionList:
         self.optionList.append(o.Option([option, str(idx)]))
         idx += 1
예제 #11
0
파일: main.py 프로젝트: wcf1065948474/COCO
import train
import dataset
import option
import torch
import models
import time
import utility
import numpy as np
torch.backends.cudnn.benchmark = True

opt = option.Option()
celeba_dataset = dataset.CelebaDataset_h5py(opt)
dataloader = torch.utils.data.DataLoader(celeba_dataset,
                                         opt.batchsize,
                                         shuffle=True,
                                         num_workers=16,
                                         drop_last=True,
                                         pin_memory=True)
gan = train.COCOGAN(opt)


def get_macro_from_full(img, pos):
    macro_pos_list = [0, 1, 2, 4, 5, 6, 8, 9, 10]
    macro_pos = macro_pos_list[pos]
    i = macro_pos // 4
    j = macro_pos % 4
    fake_patch = img[:, :,
                     i * opt.micro_size:i * opt.micro_size + opt.macro_size,
                     j * opt.micro_size:j * opt.micro_size + opt.macro_size]
    return fake_patch
예제 #12
0
 def add(self, codes):
     #options=['90000373.SH','90000374.SH',...]
     for code in codes:
         o = opt.Option(code, Security.Exchange.she)
         o.getinfo()
         self.optionset.append(o)
예제 #13
0
파일: hedging.py 프로젝트: conor10/algos
def get_revised_price(underlying):
    opt = option.Option(OptionType.CALL, 100.0, underlying, 0.3, 1)
    print(opt.price * 100.0 * 25.0)
    print(opt.vega * 25.0)
예제 #14
0
            except ValueError:  # log10 of zero is undefined
                exp = 0
            num = round(num / 10**exp, decPlcs)
            # check if rounding bumps exponent
            if abs(num) >= 1000.0:
                num /= 1000.0
                exp += 3
            return '{0:0.{prec}f}E{1:0=+3d}'.format(num, exp, prec=decPlcs)
        # general short representation
        return '{0:0.{prec}G}'.format(num, prec=decPlcs)


if __name__ == '__main__':
    import unitdata
    import option
    options = option.Option('convertall', 20)
    options.loadAll(["DecimalPlaces       8", "Notation            general"])
    data = unitdata.UnitData()
    data.readData()
    fromText = input('Enter from unit -> ')
    fromUnit = UnitGroup(data, options)
    fromUnit.update(fromText)
    toText = input('Enter to unit -> ')
    toUnit = UnitGroup(data, options)
    toUnit.update(toText)
    print('{0}   TO   {1}'.format(fromUnit.unitString(), toUnit.unitString()))
    fromUnit.reduceGroup()
    toUnit.reduceGroup()
    print('{0}   TO   {1}'.format(fromUnit.unitString(fromUnit.reducedList),
                                  toUnit.unitString(toUnit.reducedList)))
    if not fromUnit.categoryMatch(toUnit):
예제 #15
0
def parseArgs(opts, args):
    """Parse the command line and output conversion results.
    """
    options = option.Option('convertall', 20)
    options.loadAll(optiondefaults.defaultList)
    quiet = False
    dataTestMode = False
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            printUsage()
            return
        if opt in ('-d', '--decimals'):
            try:
                decimals = int(arg)
                if 0 <= decimals <= unitgroup.UnitGroup.maxDecPlcs:
                    options.changeData('DecimalPlaces', arg, False)
            except ValueError:
                pass
        elif opt in ('-f', '--fixed-decimals'):
            options.changeData('Notation', 'fixed', False)
        elif opt in ('-s', '--sci-notation'):
            options.changeData('Notation', 'scientific', False)
        elif opt in ('-e', '--eng-notation'):
            options.changeData('Notation', 'engineering', False)
        elif opt in ('-q', '--quiet'):
            quiet = True
        elif opt in ('-t', '--test'):
            dataTestMode = True
    data = unitdata.UnitData()
    try:
        data.readData()
    except unitdata.UnitDataError as text:
        print('Error in unit data - {0}'.format(text))
        sys.exit(1)
    if dataTestMode:
        unitDataTest(data, options)
        return
    numStr = '1.0'
    if args:
        numStr = args[0]
        try:
            float(numStr)
            del args[0]
        except (ValueError):
            numStr = '1.0'
    fromUnit = None
    try:
        fromUnit = getUnit(data, options, args.pop(0))
    except IndexError:
        pass
    if not fromUnit and quiet:
        return
    toUnit = None
    try:
        toUnit = getUnit(data, options, args[0])
    except IndexError:
        pass
    if not toUnit and quiet:
        return
    while True:
        while not fromUnit:
            text = _('Enter from unit -> ')
            fromText = input(text)
            if not fromText:
                return
            fromUnit = getUnit(data, options, fromText)
        while not toUnit:
            text = _('Enter to unit -> ')
            toText = input(text)
            if not toText:
                return
            toUnit = getUnit(data, options, toText)
        if fromUnit.categoryMatch(toUnit):
            badEntry = False
            while True:
                if not badEntry:
                    newNumStr = fromUnit.convertStr(float(numStr), toUnit)
                    print('{0} {1} = {2} {3}'.format(numStr,
                                                     fromUnit.unitString(),
                                                     newNumStr,
                                                     toUnit.unitString()))
                    if quiet:
                        return
                badEntry = False
                text = _('Enter number, [n]ew, [r]everse or [q]uit -> ')
                rep = input(text)
                if not rep or rep[0] in ('q', 'Q'):
                    return
                if rep[0] in ('r', 'R'):
                    fromUnit, toUnit = toUnit, fromUnit
                elif rep[0] in ('n', 'N'):
                    fromUnit = None
                    toUnit = None
                    numStr = '1.0'
                    print()
                    break
                else:
                    try:
                        float(rep)
                        numStr = rep
                    except ValueError:
                        badEntry = True
        else:
            print(
                _('Units {0} and {1} are not compatible').format(
                    fromUnit.unitString(), toUnit.unitString()))
            if quiet:
                return
            fromUnit = None
            toUnit = None
예제 #16
0
print(opts)

if not opts.all and not opts.tablename:
    print("You should choose [export all: -a] or [sepcify tablename -t]")
    os._exit(0)

if opts.all and not opts.output:
    print("When out all tables, you have to sepcify output directory")
    os._exit(0)

if opts.output:
    if not os.path.exists(opts.output):
        print("The output path is not exists")
        os._exit(0)

params = option.Option(opts.database, opts.tablename, opts.username,
                       opts.password, opts.host, opts.port, opts.json == "1", opts.all == "1", opts.output, opts.pgname)


if opts.type == "M":
    convertor = mysql2go.MySql2Go(params)
    if opts.all == "1":
        convertor.convertAllTables()
        call(["goreturns", "-w", opts.output])
    else:
        print(convertor.convert2GoStruct())

if opts.type == "P":
    convertor = postgre2go.Postgre2Go(opts.database, opts.tablename, opts.username,
                                      opts.password, opts.host, opts.port, opts.json == "1")
    print(convertor.convert2GoStruct())