MCPcopy Create free account
hub / github.com/DVampire/FinAgent / sell

Method sell

finagent/environment/trading.py:215–229  ·  view source on GitHub ↗
(self, price, amount=-1)

Source from the content-addressed store, hash-verified

213 self.value = self.current_value(price)
214
215 def sell(self, price, amount=-1):
216
217 # evaluate sell position
218 eval_sell_postion = self.eval_sell_position()
219
220 # predict sell position
221 sell_position = int(np.floor((1.0 * np.abs(amount / self.action_radius)) * eval_sell_postion))
222 if sell_position == 0:
223 self.action = "HOLD"
224 else:
225 self.action = "SELL"
226
227 self.cash += sell_position * price * (1 - self.transaction_cost_pct)
228 self.position -= sell_position
229 self.value = self.current_value(price)
230
231 def hold_on(self, price, amount=0):
232 self.action = "HOLD"

Callers 1

stepMethod · 0.95

Calls 2

eval_sell_positionMethod · 0.95
current_valueMethod · 0.95

Tested by

no test coverage detected