-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addTxn having format issues? "Transactions must be added in order" error #76
Comments
hi @mrjohn357 could you share a reproducible example perhaps? |
I second the call for a reproducible example, but I'll unpack what you did say... You said you are entering transactions from two different "signals". This suggests one or both of two separate behaviors, both of which could result in the error you describe. The first behavior that would cause this error would be to process your signals e.g. on a daily timeframe, and then generate transactions for the next day after the signal (hopefully not the same day, since you cant see something and act on it instantly). This would generate multiple transactions on the same timestamp. Most of the time this will be fine, for daily data, but may fail on POSIXct data, due to floating point rounding. The other behavior is, as the error suggests, entering transactions out of order: initPortf('dailytest',symbols='foo')
stock('foo')
stock('foo','USD')
addTxn('dailytest','foo',100,1)
addTxn('dailytest','foo','2019-01-01',100,1)
addTxn('dailytest','foo','2019-01-01',101,1) #should be OK
addTxn('dailytest','foo','2018-12-31',99,1) #transaction from second signals, will fail In this second case, I would suggest using separate portfolios for each signal process that you hope to run independently. You would likely do this in real life anyway, so you could keep track of post trade statistics for each of your strategies. Alternately, aggregate your signals first, and then generate transactions. If you provide more details @mrjohn357 , we will see what we can do to assist. |
thank you both for the quick response...appreciate the insights and am investigating (as well as figure out how to provide a reproducible example) |
@mrjohn357 any further input? I care a lot about 'transaction out of order' issues if they are occurring where they shouldn't, but we need an example to validate that. |
Brian,
Thanks for the email. Have been crazy busy but will try and post a repeatable example (need to strip down my current code). Have encountered this error many times now, will try to figure out ehat I am doing differently. Might still be a week or two before I can post again.
Best,
mrjohn357
Sent from Yahoo Mail for iPhone
On Friday, March 22, 2019, 7:14 AM, Brian G. Peterson <notifications@github.com> wrote:
@mrjohn357 any further input?
I care a lot about 'transaction out of order' issues if they are occurring where they shouldn't, but we need an example to validate that.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I have received the following error on different stocks when addTxn is called on the same day by different signals (all xts indices were loaded using POSIXct and all appear to have tz = "UTC")...
"Transactions must be added in order. TxnDate (2017-08-15) is before last transaction in portfolio (2017-08-15 00:00:00) for XYZ"
using traceback(),
lastTxnDate str is: POSIXct[1:1], format: "2017-08-15 00:00:00"
TxnDate str is: POSIXct[1:1], format: "2017-08-15"
in the ruleOrderProc
txntime is: POSIXct[1:1], format: "2017-08-15"
timestamp is: POSIXct[1:1], format: "2017-08-15"
not sure how to fix the seeming conflict between formats...please advise. many thanks.
The text was updated successfully, but these errors were encountered: