Loading...
Searching...
No Matches
pickstock.py File Reference

Go to the source code of this file.

Variables

GamsInteractive pickstock.gams = GamsInteractive()
 
str pickstock.url = "https://github.com/daveh19/pydataberlin2017/raw/master/notebooks/dowjones2016.csv"
 
pd pickstock.price_data = pd.read_csv(url)
 
GamsInteractive pickstock.m = gams.exchange_container
 
GamsInteractive pickstock.date = m.addSet('date', description='trading date')
 
GamsInteractive pickstock.symbol = m.addSet('symbol', description='stock symbol')
 
GamsInteractive pickstock.price = m.addParameter('price', [date, symbol], domain_forwarding=True, records=price_data, description='price of stock on date')
 
GamsInteractive pickstock.d = m.addAlias('d', date)
 
GamsInteractive pickstock.s = m.addAlias('s', symbol)
 
GamsInteractive pickstock.avgprice = m.addParameter('avgprice', [symbol], description='average price of stock')
 The mean price per stock is calculated in GAMS.
 
GamsInteractive pickstock.weight = m.addParameter('weight', [symbol], description='weight of stock')
 The averages can be used in order to calculate weights.
 
GamsInteractive pickstock.contribution = m.addParameter('contribution', [date,symbol])
 Compute the contributions using weight and price.
 
GamsInteractive pickstock.index = m.addParameter('index', [date], description='Dow Jones index')
 Compute index values.
 
GamsInteractive pickstock.trainingdays = m.addParameter('trainingdays', records = 100)
 Create a plot showing the symbol and index values over time.
 
GamsInteractive pickstock.maxstock = m.addParameter('maxstock', records = 3, description='maximum number of stocks to select')
 
GamsInteractive pickstock.ds = m.addSet('ds', [date], description='selected dates')
 
GamsInteractive pickstock.p = m.addVariable('p', 'binary', [symbol], description = 'is stock included?')
 Declaration of the variables and equations used to formulate the optimization model.
 
GamsInteractive pickstock.w = m.addVariable('w', 'positive', [symbol], description = 'what part of the portfolio')
 
GamsInteractive pickstock.slpos = m.addVariable('slpos', 'positive', [date], description = 'positive slack')
 
GamsInteractive pickstock.slneg = m.addVariable('slneg', 'positive', [date], description = 'negative slack')
 
GamsInteractive pickstock.obj = m.addVariable('obj', 'free', description = 'objective')
 
GamsInteractive pickstock.fund = m.addParameter('fund', [date], description='Index fund report parameter')
 Defining the actual model We know come to the decision problem, where we want to pick a small subset of the stocks together with some weights, such that this portfolio has a similar behavior to our overall Dow Jones index.
 
GamsInteractive pickstock.error = m.addParameter('error', [date], description='Absolute error')
 
 pickstock.closedown
 Plotting of the results.