gotasty / tastypl Goto Github PK
View Code? Open in Web Editor NEWTrack P/L, portfolio performance, net credit after rolls, for tastytraders
License: GNU General Public License v3.0
Track P/L, portfolio performance, net credit after rolls, for tastytraders
License: GNU General Public License v3.0
Hi,
I have 2 accounts with TW and occasionally fat finger a roll by doing it in a wrong account. This is taken care of by the backend team later moving the trade from account A to account B. However, the transaction export CSV has the commission entry as a positive 1 and fails.
Stacktrace:
14304 tastypl.go:427] record #60, positive commission amount 1.00
goroutine 1 [running]:
Here is an example of such entry:
2018-03-20T11:22:22-0400 | Administrative Transfer | BUY_TO_CLOSE | FB 180420C00160000 | Equity Option | Administrative transfer to account XXXX | -912 | 1 | -912 | 1 | 0.17 | 100 | FB | 4/20/18 | 160 | CALL
For reference: I'm using Windows. Followed the directions step by step.
I retraced my steps and re-read the directions. Went to the "History" tab then "Transactions." Did the custom date range, scrolled to the bottom as instructed, and exported to CSV. Still getting errors.
But seems you are on to something on the CSV, as now it is saying this:
F0304 22:41:51.352941 9360 tastypl.go:1575] CSV seems malformed
goroutine 1 [running]:
github.com/golang/glog.stacks(0xc000070700, 0xc000246d20, 0x43, 0x93)...
Gotcha. Could you open an issue on my fork please, and provide more details? Thanks.
Originally posted by @Graeme22 in #4 (comment)
Once all packages were installed, I tried running per the README and received the error below. I removed and redownloaded the package, then tried > go build
which results in the same error
....\tastypl.go:1259:12: undefined: chart.MarketHoursRange
I get a very long error log. I think the shopspring decimal module is not working. Perhaps the other modules as well.
I'm a complete beginner just following the instructions you wrote on github.
How can I fix this gotasty?
smalls futures are live since June 1st but there is a problem with the symbol format... regular futures use a 1 digit year (0 = 2020, 1 = 2021), but smalls have a 2 digit year (20 = 2020). This causes the program to abort in futuresNotional():
Fri Jul 10 11:38:11 2020
F0710 11:38:26.411353 96364 tastypl.go:739] Don't know how much a point of /SFXN is worth in Bought 1 /SFXN20 @ 154.48
goroutine 1 [running]:
github.com/golang/glog.stacks(0xc000071200, 0xc0001d4000, 0x79, 0xca)
/Users/jrs/go/src/github.com/golang/glog/glog.go:769 +0xb8
github.com/golang/glog.(*loggingT).output(0x134f380, 0xc000000003, 0xc0001d2000, 0x12e52b7, 0xa, 0x2e3, 0x0)
/Users/jrs/go/src/github.com/golang/glog/glog.go:720 +0x372
github.com/golang/glog.(*loggingT).printf(0x134f380, 0x3, 0x11b30d6, 0x30, 0xc000115c10, 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.futuresNotional(0xc00018f900, 0x10e784a, 0xc0001cdda0)
/Users/jrs/src/tastypl/tastypl.go:739 +0x218
main.(*portfolio).handleTrade(0xc000154000, 0xc00018f900, 0xc000196101)
/Users/jrs/src/tastypl/tastypl.go:766 +0x508
main.(*portfolio).handleTransaction(0xc000154000, 0xc00018f900)
/Users/jrs/src/tastypl/tastypl.go:941 +0x4d0
main.NewPortfolio(0xc000148018, 0xb6, 0xff, 0x0, 0x100)
/Users/jrs/src/tastypl/tastypl.go:451 +0x281
main.main()
/Users/jrs/src/tastypl/tastypl.go:1578 +0x47d
exit status 255
CSV entry for smalls future /SFXN20
2020-07-08T13:03:45-0400,Trade,BUY,/SFXN20,Future,Bought 1 /SFXN20 @ 154.48,0.00,1.0,0.00,-0.25,-0.20,,,,,
CSV entry for regular future /MESU0
2020-06-26T10:45:42-0400,Trade,BUY,/MESU0,Future,Bought 1 /MESU0 @ 3019.25,0.00,1.0,0.00,-0.85,-0.52,,,,,
CSV entry for option on future /NGU0
2020-07-09T11:11:39-0400,Trade,BUY_TO_CLOSE,./NGU0 LNEU0 200826C2.3,Future Option,Bought 1 /NGU0 LNEU0 08/26/20 Call 2.300 @ 0.035,-350.00,1.0,-350.00,0.00,-1.82,1,/NGU0,8/26/20,2.3,CALL
I just started looking at this program today so I haven't got my head around the internals yet to find the best place to fix it. The offending lines in futuresNotional() and ParsePrice() are:
contract := tx.underlying[:len(tx.underlying)-2]
pointValue, ok := futuresPoints[contract]
Which sets contract to /SFXN, not /SFX.
It seems to me we need an isSmalls flag/function and a generalized getContract() function for futures rather than hard coding. Storing the flag and contract string in the transaction struct seems appropriate after studying the code for 5 minutes ;-)
Thoughts?
Go runtime installed via Homebrew.
go version
go version go1.10.2 darwin/amd64
Session:
go run tastypl.go -input ../tastyworks_transactions_xxx.csv -printpl -positions
tastypl.go:28:2: cannot find package "github.com/golang/glog" in any of:
/usr/local/Cellar/go/1.10.2/libexec/src/github.com/golang/glog (from $GOROOT)
/Users/agrande/go/src/github.com/golang/glog (from $GOPATH)
tastypl.go:29:2: cannot find package "github.com/shopspring/decimal" in any of:
/usr/local/Cellar/go/1.10.2/libexec/src/github.com/shopspring/decimal (from $GOROOT)
/Users/agrande/go/src/github.com/shopspring/decimal (from $GOPATH)
tastypl.go:30:2: cannot find package "github.com/wcharczuk/go-chart" in any of:
/usr/local/Cellar/go/1.10.2/libexec/src/github.com/wcharczuk/go-chart (from $GOROOT)
/Users/agrande/go/src/github.com/wcharczuk/go-chart (from $GOPATH)
tastypl.go:31:2: cannot find package "github.com/wcharczuk/go-chart/util" in any of:
/usr/local/Cellar/go/1.10.2/libexec/src/github.com/wcharczuk/go-chart/util (from $GOROOT)
/Users/agrande/go/src/github.com/wcharczuk/go-chart/util (from $GOPATH)
Had to manually install additional modules:
go get github.com/golang/glog
go get github.com/shopspring/decimal
github.com/wcharczuk/go-chart
Hello,
Thanks for putting this project together.
I've been trying to implement something similar using python, and, in an effort to learn more about coding along the way, I'm still going to attempt that route. Can you briefly describe (in a language agnostic way) the algorithm you created to parse through the CSV file and account for P/L? I'm getting hung up on how to track positions with only the information provided in the CSV.
Thanks!
Hi,
When running tastypl on Windows, if I include the -chart
option, the run will fail. This is because when creating the chart, the rpl.png
file is being placed in the /tmp
folder. If that does not exist, which it does not by default on Windows, then the run fails.
The quick fix is to create a folder at C:\tmp.
Session:
C:\tastypl> .\tastypl-v0.1-1-win.exe -input .\market.csv -printpl -positions -stats -chart > output.txt
F0713 15:32:59.597036 33640 tastypl.go:1186] open /tmp/rpl.png: The system cannot find the path specified.
goroutine 1 [running]:
github.com/golang/glog.stacks(0xc042083300, 0xc0420b2000, 0x6d, 0xbd)
/go/src/github.com/golang/glog/glog.go:769 +0xd6
github.com/golang/glog.(*loggingT).output(0x757360, 0xc000000003, 0xc04211a210, 0x6f010f, 0xa, 0x4a2, 0x0)
/go/src/github.com/golang/glog/glog.go:720 +0x328
github.com/golang/glog.(*loggingT).printDepth(0x757360, 0x3, 0x1, 0xc042acc810, 0x1, 0x1)
/go/src/github.com/golang/glog/glog.go:646 +0x130
github.com/golang/glog.(*loggingT).print(0x757360, 0x3, 0xc042acc810, 0x1, 0x1)
/go/src/github.com/golang/glog/glog.go:637 +0x61
github.com/golang/glog.Fatal(0xc042acc810, 0x1, 0x1)
/go/src/github.com/golang/glog/glog.go:1128 +0x5a
main.dumpChart(0xc0422b6030, 0xe63, 0x1000, 0x0)
/go/src/github.com/gotasty/tastypl/tastypl.go:1186 +0x128f
main.main()
/go/src/github.com/gotasty/tastypl/tastypl.go:1220 +0x3a0
I would personally be fine with either the app putting the image into the executing folder or if /tmp
does not exist, making the folder.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.