Skip to content
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

Date parsing error #3

Open
elescondite opened this issue Apr 15, 2021 · 4 comments
Open

Date parsing error #3

elescondite opened this issue Apr 15, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@elescondite
Copy link
Owner

Post upgrade to 1.14, tastypl aborts with

F0415 15:25:04.134842   13242 tastypl.go:626] record #4510, bad transaction date: parsing time "2021-03-31T18:19:37.200CST" as "2006-01-02T15:04:05-0700": cannot parse "CST" as "-0700"
goroutine 1 [running]:
github.com/golang/glog.stacks(0xc000927600, 0xc000120000, 0xb9, 0x10a)
	/Users/jrs/go/src/github.com/golang/glog/glog.go:769 +0xb8
github.com/golang/glog.(*loggingT).output(0x1355420, 0xc000000003, 0xc000118000, 0x12eae4f, 0xa, 0x272, 0x0)
	/Users/jrs/go/src/github.com/golang/glog/glog.go:720 +0x372
github.com/golang/glog.(*loggingT).printf(0x1355420, 0xc000000003, 0x11b44cd, 0x24, 0xc0000d3c38, 0x2, 0x2)
	/Users/jrs/go/src/github.com/golang/glog/glog.go:655 +0x14b
github.com/golang/glog.Fatalf(...)
	/Users/jrs/go/src/github.com/golang/glog/glog.go:1148
main.(*portfolio).parseTransaction(0xc000400000, 0x119e, 0xc000194b40, 0x11, 0x11, 0xc0000d3d36, 0xc000114140)
	/Users/jrs/src/tastypl/tastypl.go:626 +0x1ed3
main.(*portfolio).parseTransactions(0xc000400000, 0xc0003a2018, 0x1232, 0x13ff, 0x1000)
	/Users/jrs/src/tastypl/tastypl.go:609 +0xea
main.NewPortfolio(0xc0003a2018, 0x1232, 0x13ff, 0x0, 0x1400)
	/Users/jrs/src/tastypl/tastypl.go:462 +0x1d9
main.main()
	/Users/jrs/src/tastypl/tastypl.go:1876 +0x561
exit status 255

Lines from the old/new CSV show that the export format for dates has changed:

2021-03-31T18:19:37.200CST Trade,BUY,/M2KM1,Future,Bought 1 /M2KM1 @ 2219.5,0.00,1,0.00,-0.85,-0.57,,,,,,141107046
2021-03-31T17:00:00-0400,Money Movement,,/STIXJ21,Future,/STIXJ21 mark to market at 62.85 Final settlement price,336.00,4,84.00,--,0.00,,,,,,

For now, just add a second date format to parse for.

@elescondite elescondite added the bug Something isn't working label Apr 15, 2021
@elescondite elescondite self-assigned this Apr 15, 2021
@elescondite
Copy link
Owner Author

elescondite commented Apr 15, 2021

This is particularly problematic that they switched to alpha timezone identifiers as these can only be interpreted within the context of the system running the code (tastypl). This makes them virtually useless for international use. IST could be india, Ireland or Israel for example, CST like is used here could be North America, Cuba, China...

For the purposes of expediency, and the obvious fact that they are exporting in CST/CDT (Chicago) time, we'll just hack in those two possibilities. The challenge is to keep them consistent so that the order of transactions stays correct. Switching from a numeric timezone (-0400) to alpha could mean it is interpreted as UTC -- a 4 hour difference that could be earlier than the previous transaction.

@elescondite
Copy link
Owner Author

elescondite commented Apr 15, 2021

And another problem. The CSV selection criteria is off by the amount of the timezone offset. Check it out:

[snip]
2021-03-01T08:30:31.898CST,Trade,SELL,/M2KH1,Future,Sold 1 /M2KH1 @ 2247.0,5.50,1,5.50,-0.85,-0.57,,,,,,134147737
2021-03-01T08:27:34.360CST,Trade,BUY,/M2KH1,Future,Bought 1 /M2KH1 @ 2245.9,0.00,1,0.00,-0.85,-0.57,,,,,,134147268
2021-02-28T22:39:34-0500,Trade,SELL,/M2KH1,Future,Sold 1 /M2KH1 @ 2229.0,-18.50,1,-18.50,-0.85,-0.57,,,,,,134130218
2021-02-28T22:12:50-0500,Trade,BUY,/M2KH1,Future,Bought 1 /M2KH1 @ 2232.7,0.00,1,0.00,-0.85,-0.57,,,,,,134130189
2021-02-28T21:46:33-0500,Trade,SELL,/M2KH1,Future,Sold 1 /M2KH1 @ 2231.9,-30.50,1,-30.50,-0.85,-0.57,,,,,,134129013
2021-02-28T21:46:33-0500,Trade,SELL,/M2KH1,Future,Sold 1 /M2KH1 @ 2231.9,-25.50,1,-25.50,-0.85,-0.57,,,,,,134128997
2021-02-28T21:39:34.100CST,Trade,SELL,/M2KH1,Future,Sold 1 /M2KH1 @ 2229.0,-18.50,1,-18.50,-0.85,-0.57,,,,,,134130218
2021-02-28T21:12:50.144CST,Trade,BUY,/M2KH1,Future,Bought 1 /M2KH1 @ 2232.7,0.00,1,0.00,-0.85,-0.57,,,,,,134130189
2021-02-28T21:04:59-0500,Trade,BUY,/M2KH1,Future,Bought 1 /M2KH1 @ 2238.0,0.00,1,0.00,-0.85,-0.57,,,,,,134128121
2021-02-28T20:59:13-0500,Trade,BUY,/M2KH1,Future,Bought 1 /M2KH1 @ 2237.0,0.00,1,0.00,-0.85,-0.57,,,,,,134128017
2021-02-28T20:46:33.160CST,Trade,SELL,/M2KH1,Future,Sold 1 /M2KH1 @ 2231.9,-30.50,1,-30.50,-0.85,-0.57,,,,,,134129013
2021-02-28T20:46:33.160CST,Trade,SELL,/M2KH1,Future,Sold 1 /M2KH1 @ 2231.9,-25.50,1,-25.50,-0.85,-0.57,,,,,,134128997
2021-02-28T20:04:59.001CST,Trade,BUY,/M2KH1,Future,Bought 1 /M2KH1 @ 2238.0,0.00,1,0.00,-0.85,-0.57,,,,,,134128121
2021-02-28T19:59:13.445CST,Trade,BUY,/M2KH1,Future,Bought 1 /M2KH1 @ 2237.0,0.00,1,0.00,-0.85,-0.57,,,,,,134128017

That is supposed to start at March 1 (reverse chrono order), but it starts at March 1, 00:00 minus the timezone offset of 4 hours.

@elescondite
Copy link
Owner Author

This is a temporary hack while they (hopefully) revert back to numeric timezone offsets, which is the only correct way to export this data, especially for an international client base.

@elescondite
Copy link
Owner Author

Reopening this until tastyworks fixes it. tastypl handles it fairly well, but the TW platform exports are still a problem.

@elescondite elescondite reopened this Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant