Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 16 backtesting/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def _check_params(self, params):
"can be optimized or run with.")
setattr(self, k, v)
return params

def deposit_cash(self, amount):
return self._broker.deposit_cash(amount)

def withdraw_cash(self, amount):
return self._broker.withdraw_cash(amount)

def I(self, # noqa: E743
func: Callable, *args,
Expand Down Expand Up @@ -721,6 +727,16 @@ def __init__(self, *, data, cash, commission, margin,

def __repr__(self):
return f'<Broker: {self._cash:.0f}{self.position.pl:+.1f} ({len(self.trades)} trades)>'

def deposit_cash(self, amount: float):
self._cash += amount
return self._cash

def withdraw_cash(self, amount: float):
if amount > self._cash:
return self._cash
self.cash -= amount
return self._cash

def new_order(self,
size: float,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.