huseinzol05 / Stock-Prediction-Models

Gathers machine learning and deep learning models for Stock forecasting including trading bots and simulations
Apache License 2.0
7.69k stars 2.74k forks source link

Feeding live data to app.py #47

Closed augmen closed 4 years ago

augmen commented 4 years ago

i have hired one developer. . I have following queries one by one

  1. What is the final command to run the app.py: is it agent.buy() or agent.trade(data) where data = [close(i), volume (i)].

  2. If we can feed json data to agent.trade(data) from request.ipynb then why there is line 347 app.py we have : df = pd.read_csv('TWTR.csv') real_trend = df['Close'].tolist() parameters = [df['Close'].tolist(), df['Volume'].tolist()] minmax = MinMaxScaler(feature_range = (100, 200)).fit(np.array(parameters).T) scaled_parameters = minmax.transform(np.array(parameters).T).T.tolist() initial_money = np.max(parameters[0]) * 2

why we need to feed again this data in app.py ?

  1. Also inserting API call function to buy or sell the stocks where to add this function ? in :
  2. def trade(): where the if action == 1 : buy = buy_market OR
  3. def buy(): where the if action == 1 : buy = buy_market plz guide @huseinzol05
augmen commented 4 years ago

I connect to live data using agent.buy(). But the app is pretty loss. Probably the commission is not included. Where we can add additional patams in app.py file.
Plz guide @huseinzol05

huseinzol05 commented 4 years ago

Yep, commission is not included, let me improve it, I really want to commit on this repo, but just too busy with my job.

augmen commented 4 years ago

Also we need integration of the inventory and capital to api so that the neural net cn decide whether he is really making any losess. It should able to check the account balanaces of capital and total value of stock it holds. This should work with reward function. We should add them as separate parameters also to feed to agent. 🧐 @huseinzol05

augmen commented 4 years ago

Chmges to be made in app.py Whether the Best place to add the 1. Commission 2. Account balance or money

def _initiate(self):

i assume first index is the close value

    self.trend = self.timeseries[0]
    self._mean = np.mean(self.trend)
    self._std = np.std(self.trend)
    self._inventory = assets
    self._capital = self.initial_money
    self. _commission = commission

def buy(self): initial_money = self._scaled_capital starting_money = initial_money real_initial_money = self.initial_money real_starting_money = self.initial_money inventory = [] real_inventory = [] state = self.get_state(0, inventory, starting_money, self.timeseries) states_sell = [] states_buy = [] commission = commission for t in range(0, len(self.trend) - 1, self.skip): action, prob = self.act_softmax(state) print(t, prob)

if action == 1 and starting_money >= self.trend[t] and t < (len(self.trend) - 1 - window_size): inventory.append(self.trend[t]) real_inventory.append(self.real_trend[t]) real_starting_money -= self.real_trend[t] starting_money -= self.trend[t] + self.commission states_buy.append(t) print( 'day %d: buy 1 unit at price %f, total balance %f' % (t, self.real_trend[t], real_starting_money) )

df = pd.read_csv('TWTR.csv') real_trend = df['Close'].tolist() parameters = [df['Close'].tolist(), df['Volume'].tolist()] minmax = MinMaxScaler(feature_range = (100, 200)).fit(np.array(parameters).T) scaled_parameters = minmax.transform(np.array(parameters).T).T.tolist() initial_money = API call token_commission = API call

agent = Agent(model = model, timeseries = scaled_parameters, skip = skip, initial_money = initial_money, commission = token_commission, real_trend = real_trend, minmax = minmax) ] @huseinzol05 plz guide

augmen commented 4 years ago

@huseinzol05 its true that your code sucks :).

Rajmehta123 commented 3 years ago

@augmen You are allowed to not follow the repo and code if you don't find it useful. I am pretty sure you won't be able to get to this state (as in this repo) if you do it yourself. Stupids like you just want stuff ready-made, suitable to your need. Get some good stuff on your profile before you make a comment :) @huseinzol05 : Ignore that prick. You are doing amazing work.