Share and Money Management 0.18devel
|
Class to handle transactions. More...
Public Member Functions | |
def | __init__ (self, count, kind, position, date=datetime.date.today(), exchange=None, fee=None, value=None, details=None) |
Create a new Transaction instance. More... | |
def | __str__ (self) |
Returns the content of this instance as string. More... | |
def | getVolume (self, withFee=True) |
Calculate the transaction volume. More... | |
def | getHoldingPeriod (self, date=datetime.date.today()) |
Returns the holding period of shares. More... | |
def | getSplitDetails (self) |
Get details of a split transaction. More... | |
def | getSwapDetails (self) |
Get details of a swap transaction. More... | |
def | setSplitDetails (self, peer) |
Set split transaction details. More... | |
def | setSwapDetails (self, peer) |
Set swap transaction details. More... | |
def | remove (self) |
Delete position. More... | |
Public Member Functions inherited from smm.objects.SMMBaseObject | |
def | __init__ (self, **kwargs) |
Initialise the instance and set attributes optionally. More... | |
def | __repr__ (self) |
Returns the representation of this object as string. More... | |
def | update (self, **kwargs) |
Update instance arguments. More... | |
def | add2db (self) |
Add an object to the database. More... | |
Static Public Member Functions | |
def | get (id=None) |
Query Transaction objects. More... | |
def | getCount () |
Returns the total number of Transaction. More... | |
def | getInPeriod (start, end, pos=None) |
Returns all Transaction between start and end date. More... | |
Static Public Attributes | |
dictionary | arguments |
string | psTopic = "smm.transaction" |
id = Int(default=AutoReload, primary=True) | |
Unique ID for each object. More... | |
count = Decimal() | |
Number of shares to buy or sell. More... | |
value = Decimal() | |
Value of one share. More... | |
fee = Decimal() | |
Overall transaction fee. More... | |
date = Date() | |
Date of the transaction. More... | |
exchange_id = Int() | |
Property to store the ID of the referred Exchange object. More... | |
exchange = Reference(exchange_id, Exchange.id) | |
Reference to the Exchange object More... | |
kind = Enum(map={"buy": 1, "sell": 2, "dividend": 3, "split": 4, "swap": 5}) | |
Type of transaction. More... | |
position_id = Int() | |
Property to store the ID of the referred Position object. More... | |
position = Reference(position_id, "Position.id") | |
Reference to the Position object More... | |
details = Unicode() | |
Additional details for this transaction. More... | |
NO_VALUE = decimal.Decimal("0.0000000000001") | |
Very small value non-zero value to use for worthless expired positions. More... | |
Static Public Attributes inherited from smm.objects.SMMBaseObject | |
dictionary | arguments |
Set of argument names for keyword arguments. More... | |
encoding = sys.stdout.encoding or sys.getdefaultencoding() | |
Encoding of all character strings. More... | |
psTopic = None | |
Publish Subscribe Topic for this class. More... | |
id = None | |
Unique ID for each object. More... | |
Private Member Functions | |
def | _getDetails (self, kind) |
Get details of a transaction. More... | |
def | _setDetails (self, kind, peer) |
Set transaction details. More... | |
Static Private Attributes | |
string | __storm_table__ = "t_transaction" |
Use given table to store all of this class inside. More... | |
Class to handle transactions.
def smm.objects.Transaction.__init__ | ( | self, | |
count, | |||
kind, | |||
position, | |||
date = datetime.date.today() , |
|||
exchange = None , |
|||
fee = None , |
|||
value = None , |
|||
details = None |
|||
) |
Create a new Transaction instance.
self | The object instance itself |
count | Number of shares to trade (decimal.Decimal ) |
date | Transaction.date (datetime.date ) |
details | Transaction.details |
exchange | Exchange to trade |
fee | Transaction.fee (decimal.Decimal ) |
kind | Transaction.kind |
value | Value of a single share (decimal.Decimal ) |
position | Position object |
ValueError | Raised for missing or wrong arguments |
Reimplemented from smm.objects.SMMBaseObject.
References gui.dialogs.DlgTrade.position, gui.panel.PanelOpenPositionDetails.position, and smm.objects.Transaction.position.
def smm.objects.Transaction.__str__ | ( | self | ) |
Returns the content of this instance as string.
References smm.objects.Transaction.count, smm.objects.DailyQuote.date, smm.objects.Transaction.date, smm.objects.SMMBaseObject.id, smm.objects.Exchange.id, smm.objects.Currency.id, smm.objects.Share.id, smm.objects.DailyQuote.id, smm.objects.Transaction.id, smm.objects.Watch.id, smm.objects.Position.id, smm.objects.Share.kind, smm.objects.Transaction.kind, smm.objects.Transaction.NO_VALUE, gui.dialogs.DlgTrade.position, gui.panel.PanelOpenPositionDetails.position, smm.objects.Transaction.position, smm.objects.Transaction.value, and smm.objects.Config.value.
Referenced by smm.objects.SMMBaseObject.__repr__().
|
private |
Get details of a transaction.
self | The object instance itself |
kind | transaction kind |
None
in case of errorsValueError | Raised for non-split transactions |
References smm.objects.Transaction.details, smm.objects.Share.kind, and smm.objects.Transaction.kind.
Referenced by smm.objects.Transaction.getSplitDetails(), and smm.objects.Transaction.getSwapDetails().
|
private |
Set transaction details.
self | The object instance itself |
kind | transaction kind |
peer | Peer transaction |
ValueError | Raised wrong transactions kind |
References smm.objects.Transaction.count, smm.objects.Share.kind, smm.objects.Transaction.kind, and smm.objects.SMMBaseObject.update().
Referenced by smm.objects.Transaction.setSplitDetails(), and smm.objects.Transaction.setSwapDetails().
|
static |
Query Transaction objects.
id | Returns a single transaction specified by id. |
|
static |
Returns the total number of Transaction.
def smm.objects.Transaction.getHoldingPeriod | ( | self, | |
date = datetime.date.today() |
|||
) |
Returns the holding period of shares.
The function calculates the difference between a transaction date and given date.
self | The object instance itself |
date | Date of the end of the holding period |
References smm.objects.DailyQuote.date, and smm.objects.Transaction.date.
|
static |
Returns all Transaction between start
and end
date.
start | Start date |
end | End date |
pos | Return transactions associated with this Position |
def smm.objects.Transaction.getSplitDetails | ( | self | ) |
Get details of a split transaction.
None
in case of errorsValueError | Raised for non-split transactions |
References smm.objects.Transaction._getDetails().
def smm.objects.Transaction.getSwapDetails | ( | self | ) |
Get details of a swap transaction.
None
in case of errorsValueError | Raised for non-swap transactions |
References smm.objects.Transaction._getDetails().
def smm.objects.Transaction.getVolume | ( | self, | |
withFee = True |
|||
) |
Calculate the transaction volume.
Acquisitions increased the volume. Sales decreases it. Dividends are added to the volume. Splits and swaps don't have any effect.
Fees are processed for buy and sell transactions only.
self | The object instance itself |
withFee | Include the transaction fees in the volume |
decimal.Decimal
value. Split transactions returns decimal.Decimal
('0'). Worthless transactions returns decimal.Decimal
('0').References smm.objects.Transaction.count, smm.objects.Transaction.fee, smm.objects.SMMBaseObject.id, smm.objects.Exchange.id, smm.objects.Currency.id, smm.objects.Share.id, smm.objects.DailyQuote.id, smm.objects.Transaction.id, smm.objects.Watch.id, smm.objects.Position.id, smm.objects.Share.kind, smm.objects.Transaction.kind, smm.objects.Transaction.NO_VALUE, smm.objects.Transaction.value, and smm.objects.Config.value.
def smm.objects.Transaction.remove | ( | self | ) |
Delete position.
The reference between share and watch list entry will be cleaned and Watch object will be removed from the database.
References smm.objects.SMMBaseObject._remove(), gui.dialogs.DlgTrade.position, gui.panel.PanelOpenPositionDetails.position, and smm.objects.Transaction.position.
def smm.objects.Transaction.setSplitDetails | ( | self, | |
peer | |||
) |
Set split transaction details.
self | The object instance itself |
peer | Peer transaction |
ValueError | Raised for non-split transactions |
References smm.objects.Transaction._setDetails().
def smm.objects.Transaction.setSwapDetails | ( | self, | |
peer | |||
) |
Set swap transaction details.
self | The object instance itself |
peer | Peer transaction |
ValueError | Raised for non-swap transactions |
References smm.objects.Transaction._setDetails().
|
staticprivate |
Use given table to store all of this class inside.
|
static |
Referenced by smm.objects.SMMBaseObject._setAttrs().
|
static |
Number of shares to buy or sell.
Referenced by smm.objects.Transaction.__str__(), smm.objects.Transaction._setDetails(), and smm.objects.Transaction.getVolume().
|
static |
Date of the transaction.
Referenced by smm.objects.DailyQuote.__str__(), smm.objects.Transaction.__str__(), and smm.objects.Transaction.getHoldingPeriod().
|
static |
Additional details for this transaction.
Currently supported events:
Referenced by smm.objects.Transaction._getDetails().
|
static |
Reference to the Exchange object
Referenced by smm.objects.DailyQuote.__str__().
|
static |
Property to store the ID of the referred Exchange object.
|
static |
Overall transaction fee.
Referenced by smm.objects.Transaction.getVolume().
|
static |
Unique ID for each object.
Referenced by smm.objects.Exchange.__str__(), smm.objects.Currency.__str__(), smm.objects.Share.__str__(), smm.objects.DailyQuote.__str__(), smm.objects.Transaction.__str__(), smm.objects.Watch.__str__(), smm.objects.Position.__str__(), smm.objects.SMMBaseObject._remove(), and smm.objects.Transaction.getVolume().
|
static |
Type of transaction.
Adapt functions below after adding a new kind:
Referenced by smm.objects.Transaction.__str__(), smm.objects.Transaction._getDetails(), smm.objects.Transaction._setDetails(), and smm.objects.Transaction.getVolume().
|
static |
Very small value non-zero value to use for worthless expired positions.
Referenced by smm.objects.Transaction.__str__(), and smm.objects.Transaction.getVolume().
|
static |
Reference to the Position object
Referenced by smm.objects.Transaction.__init__(), smm.objects.Transaction.__str__(), gui.dialogs.DlgTrade._prepareBuy(), gui.dialogs.DlgTrade._processInput(), gui.dialogs.DlgTrade._updateDateRangePosition(), gui.dialogs.DlgTrade._validateInput(), gui.panel.PanelOpenPositionDetails.OnItemSelected(), gui.panel.PanelOpenPositionDetails.OnSave(), gui.panel.PanelOpenPositionDetails.OnTrade(), gui.dialogs.DlgTrade.OnUpdateExistingPosition(), gui.dialogs.DlgTrade.OnUpdateNewPosition(), gui.panel.PanelOpenPositionDetails.psUpdateContent(), smm.objects.Transaction.remove(), and gui.panel.PanelOpenPositionDetails.showDetails().
|
static |
Property to store the ID of the referred Position object.
|
static |
|
static |
Value of one share.
Referenced by smm.objects.Transaction.__str__(), smm.objects.Config.__str__(), and smm.objects.Transaction.getVolume().