Beispiel #1
0
def getSynthStock(tgt, date, dte, vol, interest, strike, stock):
    '''Sets up iterative process to build the inventory up to initial levels'''
    #get exDate
    exDate = getExpDate(date)

    #create the inventory object
    inventory = options.Inventory()
    i = 0
    if system_status == 1:
        tgt_factor = ((tgt) / 100)  #adding leverage
    else:
        tgt_factor = tgt / 50

    while i < tgt_factor:

        #create the options
        call = options.Option(exDate, vol, strike, stock, "Call", interest, 1)
        put = options.Option(exDate, vol, strike, stock, "Put", interest, -1)
        #build the position
        if system_status == 1:
            pos_list = [call, put]
        else:
            pos_list = [call]

        pos = options.Position(pos_list)

        #add the position to Inventory

        inventory.add_position(pos)
        i = i + 1

    return inventory
Beispiel #2
0
    def __init__(self, w_width, w_height, caption):
        pygame.init()
        self.root = tkinter.Tk()
        self.root.withdraw()
        self.w_width = w_width
        self.w_height = w_height
        self.caption = caption
        self.set_window(self.w_width, self.w_height, self.caption)
        font = pygame.font.Font("Retroscape.ttf", 15)
        self.menu = []

        for i, text in enumerate(("PLAY", "EDIT", "HELP")):
            self.menu.append(options.Option(text, self.w_width/2,
                             (self.w_height/4)+103+(i*50), font))
            
        self.title = pygame.image.load("title.png").convert()
        self.title_pos = self.title.get_rect(center=(self.w_width/2,
                                                     self.w_height/4))
        self.game = game.Game(self)
Beispiel #3
0
import options

set = options.OptionSet()
set.add_option([
    options.Option("output", ["-o", "-beh"], sep=["", " "]),
    options.Option("blah", "-behemoth"),
    options.Option("flag", "-f", type="bool")
])
s = set.make_option_string([("flag", True), ("output", "hello")])
print s
print set.parse_option_string("-o hello -behemoth -f -beh_h there")
Beispiel #4
0
def run_sim(df):
    stock = df.iloc[0]['Close']
    vol = df.iloc[0]['Settle']
    today = df.iloc[0]['Date']
    df.at[0, 'tgtdelta'] = float(port) / float(stock)
    today = getDate(today)
    y = initiate_sim(df)
    price = y.get_inventory_stats(today, stock, vol)

    value = price['price']
    pDelta = price['delta']
    #initiate initial values
    df.at[0, 'options'] = value
    df.at[0, 'delta'] = pDelta
    df.at[0, 'cash'] = float(df.iloc[0]['portfolio'] - df.iloc[0]['options'])

    #cycle through by day

    for i in range(1, len(df) - 1):
        stock = df.iloc[i]['Close']
        vol = df.iloc[i]['Settle']
        today = df.iloc[i]['Date']
        today = getDate(today)
        interest = df.iloc[i]['Value']
        daily_interest = interest / 36500

        #get new cash value and delta
        price = y.get_inventory_stats(today, stock, vol)

        total_cash = df.iloc[i - 1]['cash']

        total_cash = float(total_cash) * (1 + daily_interest)
        df.at[i, 'cash'] = total_cash

        #update df value
        df.at[i, 'options'] = price['price']
        #get rid of expiring contracts
        y.sellExpirContracts(today)

        delta = price['delta']
        value = price['price']

        ###Issue with rolling up cash portfolio...need to checl

        df.at[i, 'portfolio'] = total_cash + price['price']

        #get new target delta
        tgtdelta = (df.iloc[i]['portfolio'] / stock)  #adding leverage

        #tgt=getTargetDelta(tgtdelta)
        df.at[i, 'tgtdelta'] = tgtdelta
        df.at[i, 'delta'] = delta

        gap = tgtdelta - delta

        #set up portfolio rebalance

        exDate = getExpDate(today)
        strike = getStrike(stock)

        if gap > 100:

            call = options.Option(exDate, vol, strike, stock, "Call", interest,
                                  1)
            put = options.Option(exDate, vol, strike, stock, "Put", interest,
                                 -1)
            if system_status == 1:
                pos_list = [call, put]
            else:
                pos_list = [call]

            pos = options.Position(pos_list)

            #add the position to Inventory

            y.add_position(pos)

        elif gap < -100:
            y.sell_position()
        else:
            continue

        #get new options price
        price = y.get_inventory_stats(today, stock, vol)
        value = price['price']
        df.at[i, 'options'] = value
        df.at[i, 'cash'] = df.iloc[i]['portfolio'] - value

    if system_status == 1:
        df.to_csv('synth.csv')
    else:
        df.to_csv('call.csv')
Beispiel #5
0
import os 
import numpy as np
import torch
import copy
import options

TrainingFile = 'ModelNet10'
path = os.walk('./Data/' + TrainingFile)

obj_num = 0
obj_class = dict()
TrainingSet = list()
TestSet = list()
current_class = 'nothing'
now = 0
opt = options.Option()
global TrainingSize
global TestSize

def get_TrainingSize():
    global TrainingSize
    return TrainingSize

def shuffle_TrainingSet():
    np.random.shuffle(TrainingSet)

def normalize_pointnum(point):
    if point.shape[0] == opt.pointnum:
        return point
    elif point.shape[0] < opt.pointnum:
        idx =  np.random.choice(range(0, point.shape[0]), opt.pointnum - point.shape[0])