Lots of changes. Modified the Position object to handle more of the actual position calculations instead of the Portfolio. Added more unit tests for both Position and Portfolio. Allowed Positions to trade in currencies other than GBPUSD and in base/quotes which aren't the home currency. Modified the backtester to be single-threaded and added a basic Moving Average Crossover strategy. Also added a basic equity curve output script.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import os, os.path
|
||||
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from qsforex.settings import OUTPUT_RESULTS_DIR
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""
|
||||
A simple script to plot the balance of the portfolio, or
|
||||
"equity curve", as a function of time.
|
||||
|
||||
It requires OUTPUT_RESULTS_DIR to be set in the project
|
||||
settings.
|
||||
"""
|
||||
equity_file = os.path.join(OUTPUT_RESULTS_DIR, "equity.csv")
|
||||
equity = pd.io.parsers.read_csv(
|
||||
equity_file, header=True,
|
||||
names=["time", "balance"],
|
||||
parse_dates=True, index_col=0
|
||||
)
|
||||
equity["balance"].plot()
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user