@@ -475,7 +475,9 @@ def __init__(self, name):
475
475
self .__name = name
476
476
sys .modules ['talib' ] = self
477
477
def __getattr__ (self , attr ):
478
- raise Exception ('Please install %s module for python' % self .__name )
478
+ if attr == '__file__' :
479
+ return 'talib.py'
480
+ raise Exception ('Please install %s module for python (%s)' % (self .__name , attr ))
479
481
480
482
class MyList (list ):
481
483
def __init__ (self , data ):
@@ -1729,23 +1731,22 @@ def data_clean(self):
1729
1731
holdSpot += (position [code ]['Stocks' ] + position [code ]['FrozenStocks' ]) * position [code ]['Last' ]
1730
1732
diffSpot += (position [code ]['Stocks' ] + position [code ]['FrozenStocks' ] - acc ['Stocks' ]) * position [code ]['Last' ]
1731
1733
1732
- if item ['QuoteCurrency' ] == 'CNY' :
1733
- assets += item ['Balance' ] + item ['FrozenBalance' ] + profit + margin
1734
- moneyUse += margin / assets
1735
- dic ['unit' ] = '(CNY)'
1736
- elif 'Futures_' in item ['Id' ]:
1737
- if item ['QuoteCurrency' ] == 'USDT' :
1738
- assets += item ['Balance' ] + item ['FrozenBalance' ] + profit + margin
1739
- moneyUse += margin / assets
1740
- dic ['unit' ] = '(USDT)'
1734
+ for asset in item ['Assets' ]:
1735
+ if item ['QuoteCurrency' ] == 'CNY' :
1736
+ assets += asset ['Amount' ] + asset ['FrozenAmount' ] + profit + margin
1737
+ dic ['unit' ] = '(CNY)'
1738
+ elif 'Futures_' in item ['Id' ]:
1739
+ if item ['QuoteCurrency' ] == 'USDT' :
1740
+ assets += asset ['Amount' ] + asset ['FrozenAmount' ] + profit + margin
1741
+ dic ['unit' ] = '(USDT)'
1742
+ else :
1743
+ assets += asset ['Amount' ] + asset ['FrozenAmount' ] + profit + margin
1744
+ dic ['unit' ] = '(%s)' % (item ["BaseCurrency" ], )
1741
1745
else :
1742
- assets += item ['Stocks' ] + item ['FrozenStocks' ] + profit + margin
1743
- moneyUse += margin / assets
1744
- dic ['unit' ] = '(%s)' % (item ["BaseCurrency" ], )
1745
- else :
1746
- assets += item ['Balance' ] + item ['FrozenBalance' ] + holdSpot
1747
- moneyUse += abs (diffSpot ) / assets
1748
- dic ['unit' ] = '(USD)'
1746
+ assets += asset ['Amount' ] + asset ['FrozenAmount' ] + holdSpot
1747
+ margin = abs (diffSpot )
1748
+ dic ['unit' ] = '(USD)'
1749
+ moneyUse += margin / assets if assets != 0 else 0
1749
1750
dic ['timeStamp' ].append (datetime .datetime .fromtimestamp (i [0 ]/ 1000 ).date ())
1750
1751
dic ['assets' ].append (assets )
1751
1752
dic ['moneyUse' ].append (moneyUse )
0 commit comments