Closed augmen closed 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
Yep, commission is not included, let me improve it, I really want to commit on this repo, but just too busy with my job.
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
Chmges to be made in app.py Whether the Best place to add the 1. Commission 2. Account balance or money
def _initiate(self):
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
@huseinzol05 its true that your code sucks :).
@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.
i have hired one developer. . I have following queries one by one
What is the final command to run the app.py: is it
agent.buy()
oragent.trade(data)
wheredata = [close(i), volume (i)]
.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 ?
def trade():
where theif action == 1 : buy = buy_market
ORdef buy():
where theif action == 1 : buy = buy_market
plz guide @huseinzol05