Skip to content

Commit

Permalink
Rename the account value to "value"
Browse files Browse the repository at this point in the history
EmersonDove committed Oct 14, 2022
1 parent d6a8121 commit c6357c3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions blankly/exchanges/interfaces/paper_trade/backtest_result.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

import pandas as pd
from pandas import DataFrame, to_datetime, Timestamp
from blankly.utils import time_interval_to_seconds as _time_interval_to_seconds, info_print

@@ -176,6 +176,15 @@ def __str__(self):
return return_string

def to_dict(self) -> dict:
history_copy: pd.DataFrame = self.history_and_returns['history'].copy(deep=True)
value_column = None
for column in history_copy:
if column[0:13] == "Account Value":
value_column = column

# Renae the account value to just value
history_copy = history_copy.rename(columns={value_column: 'value'})

result = {
'metrics': self.metrics,
'exchange': self.exchange,
@@ -184,7 +193,7 @@ def to_dict(self) -> dict:
'start_time': self.start_time,
'stop_time': self.stop_time,
# "returns": self.history_and_returns['returns'].to_dict(),
"history": self.history_and_returns['history'].to_dict()
"history": history_copy.to_dict('records')
}

return result

0 comments on commit c6357c3

Please sign in to comment.