Skip to content

Commit

Permalink
no more withdraw. make negative deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
llazzaro committed Nov 30, 2015
1 parent a4cd0f1 commit 4a014db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions pyStock/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ def execute(self, order, tick):
def deposit(self, money):
money.account = self

def withdraw(self, money):
self.deposit(Money(amount=-1 * money.amount, currency=money.currency))

@hybrid_property
def total(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions pyStock/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def validate_buy_order(mapper, connection, target):
cost = target.share * target.price + target.account.broker.commission(target)
if cost > target.account.cash[target.security.currency]:
raise Exception('Transition fails validation: cash {0} is smaller than cost {1}'.format(target.account.cash[target.security.currency], cost))
# TODO create the withdraw from account
target.account.withdraw(Money(amount=target.share * Decimal(target.price), currency=target.security.exchange.currency))

target.account.deposit(Money(amount=target.share * -1 * Decimal(target.price), currency=target.security.exchange.currency))
session = object_session(target)
position = Position(buy_order=target, stage=OpenPositionStage(), share=target.share, account=target.account)
session.add(position)
Expand Down

0 comments on commit 4a014db

Please sign in to comment.