I need to test the risk management logic within a strategy which calculates the size of a position as a percentage of the account's cash value.
This seems to be a fairly straight forward process when using real time data, however, back testing using historical data is proving troublesome.
I need to be able to access the current account's Cash Value. I am aware that the Cash Value in back testing remains constant to what ever the Sim101 account value was initially set to. I am trying to code an alternative method which can be used during back testing only to determine the effectiveness of the risk management logic by getting the strategy go keep track of the cash value of the account as the back test is running.
There are various methods of achieving this. Eg. Accessing the open positions profit and loss value, entry/exit price, etc and adding it to a custom series created in the logic.
In my attempts, I have found that Position.AveragePrice and Position.GetUnrealizedProfitLoss() only ever yield a value of 0.
Using Account.Get() with the various account items available to retrieve has not been working either with back testing.
Is there any other way that I can retrieve this kind of data during historical back testing?
Comment