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

Function buy

finagent/trajectory/dynamic_programming_threshold.py:78–82  ·  view source on GitHub ↗
(cash, position, price, fee_ratio)

Source from the content-addressed store, hash-verified

76"""
77
78def buy(cash, position, price, fee_ratio):
79 buy_position = int(np.floor(cash / (price * (1 + fee_ratio))))
80 position += buy_position
81 cash -= buy_position * price * (1 + fee_ratio)
82 return cash, position
83
84def sell(cash, position, price, fee_ratio):
85 cash += position * price * (1 - fee_ratio)

Calls

no outgoing calls

Tested by

no test coverage detected