Content-Length: 279606 | pFad | http://github.com/kernc/backtesting.py/pull/925/commits/a473d4c8cef06ac27b801aa8f016a8b90e12bab3

B9 Allow for cash to be deposited or withdrawn during a backtest by AdiSai · Pull Request #925 · kernc/backtesting.py · GitHub
Skip to content

Allow for cash to be deposited or withdrawn during a backtest #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
Next Next commit
Broker add deposit and withdraw functions
  • Loading branch information
AdiSai authored Mar 2, 2023
commit a473d4c8cef06ac27b801aa8f016a8b90e12bab3
10 changes: 10 additions & 0 deletions backtesting/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/kernc/backtesting.py/pull/925/commits/a473d4c8cef06ac27b801aa8f016a8b90e12bab3

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy