Exemplo n.º 1
0
 def inciso3v(self):
     codigo = int(
         input("Ingrese codigo del producto que desea cambiar stock:  "))
     cantid = int(input("Ingrese la cantidad:  "))
     stock1 = Stock(codigo, cantid)
     for i in range(len(self.__listaStock)):
         if self.__listaStock[i].getCodigoProducto() == codigo:
             stock2 = Stock(codigo, self.__listaStock[i].getCantidad())
             restar = stock1 - stock2
             self.inciso3a(codigo, restar)
Exemplo n.º 2
0
def main():

    chef = LineChef('BTC-USD', 20, 8, [1, 2, 3, 4])

    startDate = datetime.datetime(2018, 2, 4, 8)
    endDate = startDate + datetime.timedelta(days=60)

    chef.train(startDate, endDate)

    strongCount = 0
    for pat in chef.patterns:
        if (pat.isStrong()):
            strongCount += 1
            print("# Matches: ", pat.numMatches)
            print(pat.changes)
            print(pat)

    print("STRONG COUNT: ", strongCount)

    testStartDate = endDate
    testEndDate = testStartDate + datetime.timedelta(days=14)
    predictionDelta = 4

    simBoi = RepeatPredictor(5, Stock('BTC-USD'), 1000, 20, testStartDate,
                             datetime.timedelta(hours=predictionDelta))

    chef.test(testStartDate, testEndDate, predictionDelta, simBoi)
Exemplo n.º 3
0
 def manejadorArchiStock(self):
     archi = open("Stock.csv")
     reader = csv.reader(archi, delimiter=';')
     next(reader)
     for i in reader:
         codP = int(i[0])
         cant = int(i[1])
         objeto = Stock(codP, cant)
         self.agregadorStock(objeto)
     archi.close()
Exemplo n.º 4
0
def main(transaction_history):
    # this method assumes the transaction history is sent in the form of a dictionary.
    # It processes the transaction history of each instrument and creates a portfolio based on it.
    for key, value in transaction_history.iteritems():
        for all_bonds, tran_history in value.iteritems():
            transaction = get_current_quantity(tran_history)
            if key == 'Stock':
                instrument = Stock(all_bonds, transaction)
            elif key == 'Bonds':
                instrument = Bonds(all_bonds, transaction)
            elif key == 'Cash':
                instrument = Cash(all_bonds, transaction)
            else:
                raise ValueError('Instrument not defined')
            all_instrument[all_bonds] = instrument
    return create_portfolio()
Exemplo n.º 5
0
    def loadValuesIntoOneStock(self):
        testStock = Stock('TEST', 'testValues.txt')

        testStock.record = {
            "2019-03-18": {
                "06:00:00": (0.5, 45.10),
                "06:15:00": (73, 12)
            },
            "2019-03-19": {
                "06:15:00": (83, 12)
            },
            "2019-03-20": {
                "06:30:00": (14, -6.0),
                "06:31:00": (18, 9)
            }
        }
        return testStock
Exemplo n.º 6
0
def main():

    # ts = TimeSeries(key=API_KEY)
    # for key, stock in ALL_STOCKS.items():
    # 	data, metaData = ts.get_intraday(symbol=stock.symbol, interval="5min", outputsize="full")
    # 	for dataKey, item in data.items():
    # 		stock.addValue(dataKey.split(" ")[1], item["4. close"], item["5. volume"], dataKey.split(" ")[0])
    # 	stock.saveValues()

    # startDate = datetime.datetime(2018, 2, 4, 8) # bull?
    # startDate = datetime.datetime(2018, 2, 17, 8) # ?
    startDate = datetime.datetime(2018, 3, 6, 8)  # bear
    endDate = startDate + datetime.timedelta(hours=100)

    testStartDate = datetime.datetime(2018, 5, 12, 8)
    testEndDate = testStartDate + datetime.timedelta(hours=168)

    ratBoi = RatBoi(Stock("BTC-USD"))
    ratBoi.train(startDate, endDate, iterations=3, learningRate=0.9)
    # ratBoi.test(testStartDate, testEndDate)
    ratBoi.simulate(testStartDate, testEndDate, 0)
    return
Exemplo n.º 7
0
    def loadValsForSkewKurtosis(self):
        testStock = Stock('TEST', 'testValues.txt')
        #3 days, 32 mins span
        testStock.record = {
            "2019-03-18": {
                "06:00:00": (61, 0),
                "06:01:00": (61, 0),
                "06:02:00": (61, 0),
                "06:03:00": (61, 0),
                "06:04:00": (61, 0),
                "06:05:00": (64, 0),
                "06:06:00": (64, 0),
                "06:07:00": (64, 0),
                "06:08:00": (64, 0),
                "06:09:00": (64, 0),
                "06:10:00": (64, 0),
                "06:11:00": (64, 0),
                "06:12:00": (64, 0),
                "06:13:00": (64, 0),
                "06:14:00": (64, 0),
                "06:15:00": (64, 0),
                "06:16:00": (64, 0),
                "06:17:00": (64, 0),
                "06:18:00": (64, 0),
                "06:19:00": (64, 0),
                "06:20:00": (64, 0),
                "06:21:00": (64, 0),
                "06:22:00": (64, 0),
                "06:23:00": (67, 0),
                "06:24:00": (67, 0),
                "06:25:00": (67, 0),
                "06:26:00": (67, 0),
                "06:27:00": (67, 0),
                "06:28:00": (67, 0),
                "06:29:00": (67, 0),
                "06:30:00": (67, 0),
                "06:31:00": (67, 0),
                "06:32:00": (67, 0),
                "06:33:00": (67, 0),
                "06:34:00": (67, 0),
                "06:35:00": (67, 0),
                "06:36:00": (67, 0),
                "06:37:00": (67, 0),
                "06:38:00": (67, 0),
                "06:39:00": (67, 0),
                "06:40:00": (67, 0),
                "06:41:00": (67, 0),
                "06:42:00": (67, 0),
                "06:43:00": (67, 0),
                "06:44:00": (67, 0),
                "06:45:00": (67, 0),
                "06:46:00": (67, 0),
                "06:47:00": (67, 0),
                "06:48:00": (67, 0),
                "06:49:00": (67, 0),
                "06:50:00": (67, 0),
                "06:51:00": (67, 0),
                "06:52:00": (67, 0),
                "06:53:00": (67, 0),
                "06:54:00": (67, 0),
                "06:55:00": (67, 0),
                "06:56:00": (67, 0),
                "06:57:00": (67, 0),
                "06:58:00": (67, 0),
                "06:59:00": (67, 0),
            },
            "2019-03-19": {
                "06:15:00": (73, 0),
                "06:16:00": (73, 0),
                "06:17:00": (73, 0),
                "06:18:00": (73, 0),
                "06:19:00": (73, 0),
                "06:20:00": (73, 0),
                "06:21:00": (73, 0),
                "06:22:00": (73, 0)
            },
            "2019-03-21": {
                "06:01:00": (67, 0),
                "06:02:00": (67, 0),
                "06:03:00": (67, 0),
                "06:04:00": (67, 0),
                "06:05:00": (67, 0),
                "06:06:00": (70, 0),
                "06:07:00": (70, 0),
                "06:08:00": (70, 0),
                "06:09:00": (70, 0),
                "06:10:00": (70, 0),
                "06:11:00": (70, 0),
                "06:12:00": (70, 0),
                "06:13:00": (70, 0),
                "06:14:00": (70, 0),
                "06:15:00": (70, 0),
                "06:16:00": (70, 0),
                "06:17:00": (70, 0),
                "06:18:00": (70, 0),
                "06:19:00": (70, 0),
                "06:20:00": (70, 0),
                "06:21:00": (70, 0),
                "06:22:00": (70, 0),
                "06:23:00": (70, 0),
                "06:24:00": (70, 0),
                "06:25:00": (70, 0),
                "06:26:00": (70, 0),
                "06:27:00": (70, 0),
                "06:28:00": (70, 0),
                "06:29:00": (70, 0),
                "06:30:00": (70, 0),
                "06:31:00": (70, 0),
                "06:32:00": (70, 0)
            }
        }

        return testStock
Exemplo n.º 8
0
d_bar = 5
interest_rate = 0.02
init_holding = 1
initialcash = 20000
theta = 75
gene_length = 64
risk_coef = 0.5
num_strategies = 80

max_stockprice = 200
min_stockprice = 0.01
min_excess = 0.005
eta = 0.005
specialist_iterations = 10

the_market = Stock(num_shares, init_price, dividend_startvalue, rho, noise_sd,
                   d_bar, interest_rate)
agents = [
    Agent(init_holding, initialcash, num_strategies, theta, gene_length,
          risk_coef, num_shares, init_price, dividend_startvalue, rho,
          noise_sd, d_bar, interest_rate) for _ in range(100)
]
the_specialist = Specialist(max_stockprice, min_stockprice, min_excess, eta,
                            specialist_iterations, num_shares, init_price,
                            dividend_startvalue, rho, noise_sd, d_bar,
                            interest_rate)

for t in range(1000):
    the_market.advance_arprocess()
    the_specialist.clear_market(agents)

ma = the_market.calculate_ma(query='dividend', period=50)
Exemplo n.º 9
0
from Stocks import Stock

ALL_STOCKS = {
    'amazon': Stock('AMZN', 'amazonValues.txt'),
    'walmart': Stock('WMT', 'walmartValues.txt'),
    'generalElectric': Stock('GE', 'generalElectricValues.txt'),
    'cocaCola': Stock('KO', 'cocaColaValues.txt'),
    'google': Stock('GOOGL', 'googleValues.txt'),
    'microsoft': Stock('MSFT', 'microsoftValues.txt'),
    'tesla': Stock('TSLA', 'teslaValues.txt'),
    'apple': Stock('AAPL', 'appleValues.txt'),
    'facebook': Stock('FB', 'facebookValues.txt'),
}