mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 10:44:16 +08:00
made distinction between cumulative behavior and daily behavior a bit more clear.
This commit is contained in:
@@ -56,9 +56,6 @@ Position Tracking
|
||||
+-----------------+----------------------------------------------------+
|
||||
| last_sale_price | price at last sale of the security on the exchange |
|
||||
+-----------------+----------------------------------------------------+
|
||||
| transactions | all the transactions that were acrued into this |
|
||||
| | position. |
|
||||
+-----------------+----------------------------------------------------+
|
||||
|
||||
|
||||
Performance Period
|
||||
@@ -104,7 +101,9 @@ Performance Period
|
||||
| period_open | The first open of the market in period. datetime in |
|
||||
| | pytz.utc timezone. |
|
||||
+---------------+------------------------------------------------------+
|
||||
|
||||
| transactions | all the transactions that were acrued during this |
|
||||
| | period. Unset/missing for cumulative periods. |
|
||||
+---------------+------------------------------------------------------+
|
||||
|
||||
|
||||
"""
|
||||
@@ -471,7 +470,7 @@ class PerformancePeriod():
|
||||
positions = self.get_positions_list()
|
||||
transactions = [x.as_dict() for x in self.processed_transactions]
|
||||
|
||||
return {
|
||||
rval = {
|
||||
'ending_value' : self.ending_value,
|
||||
'capital_used' : self.period_capital_used,
|
||||
'starting_value' : self.starting_value,
|
||||
@@ -489,6 +488,12 @@ class PerformancePeriod():
|
||||
'period_close' : self.period_close
|
||||
}
|
||||
|
||||
# we want the key to be absent, not just empty
|
||||
if not self.keep_transactions:
|
||||
del(rval['transactions'])
|
||||
|
||||
return rval
|
||||
|
||||
def to_namedict(self):
|
||||
"""
|
||||
Creates a namedict representing the state of this perfomance period.
|
||||
|
||||
@@ -292,7 +292,7 @@ class RiskMetrics():
|
||||
curve = None
|
||||
# in case end date is not a trading day, search for the next market
|
||||
# day for an interest rate
|
||||
for i in range(7):
|
||||
for i in xrange(7):
|
||||
if(self.treasury_curves.has_key(self.end_date + i * one_day)):
|
||||
curve = self.treasury_curves[self.end_date + i * one_day]
|
||||
break
|
||||
|
||||
+5
-4
@@ -636,7 +636,9 @@ def PERF_FRAME(perf):
|
||||
cp = perf['cumulative_perf']
|
||||
|
||||
assert isinstance(tp['transactions'], list)
|
||||
assert isinstance(cp['transactions'], list)
|
||||
# we never want to send transactions for the cumulative period.
|
||||
# performance.py should never send them, but just to be safe:
|
||||
assert not cp.has_key('transactions')
|
||||
assert isinstance(tp['positions'], list)
|
||||
assert isinstance(cp['positions'], list)
|
||||
assert isinstance(tp['period_close'], datetime.datetime)
|
||||
@@ -652,9 +654,8 @@ def PERF_FRAME(perf):
|
||||
cp['period_close'] = EPOCH(cp['period_close'])
|
||||
cp['period_open'] = EPOCH(cp['period_open'])
|
||||
|
||||
tp['transactions'] = convert_transactions(tp['transactions'])
|
||||
cp['transactions'] = convert_transactions(cp['transactions'])
|
||||
|
||||
tp['transactions'] = convert_transactions(tp['transactions'])
|
||||
|
||||
return BT_UPDATE_FRAME('PERF', perf)
|
||||
|
||||
def convert_transactions(transactions):
|
||||
|
||||
Reference in New Issue
Block a user