Created
July 15, 2018 17:00
-
-
Save marktellez/08353f7dc7dce8b1a1eb705219ec1b2c to your computer and use it in GitHub Desktop.
Extract your tradingview paper trade journal into a csv file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trs = $($(".paper_trading table.balances")[2]).find(".tv-data-table__tbody tr").map((_, value) => $(value).find("td").map((_, value) => value.innerText)) | |
trades = Object.values(trs.map((_, tr) => [Object.values(tr).slice(0,5)])) | |
var toTimestamp = val => { | |
var parts = val.split(' ') | |
switch(parts[1]) { | |
case "Minutes": | |
var d = new Date(new Date().getTime() - (parts[0] * 60 * 60)) | |
break; | |
case "Hours": | |
var d = new Date(new Date().getTime() - (parts[0] * 60)) | |
break; | |
case "Hour": | |
var d = new Date(new Date().getTime() - (60 * 60)) | |
break; | |
default: | |
var d = new Date(`${val} ${new Date().getFullYear()}`) | |
break; | |
} | |
return `${d.getMonth()}/${d.getDate()}/${d.getFullYear()}` | |
} | |
trades = trades.slice(0, trades.length-3).map(trade => [toTimestamp(trade[0]), trade[1], trade[2], trade[3], trade[4]]) | |
var csvContent = "data:text/csv;charset=utf-8," | |
csvContent += ["Date", "Balance before", "Balance after", "Profit", "Notes"].join(', ') + "\r\n" | |
trades.forEach(rowArray => { | |
if(Array.isArray(rowArray)) { | |
var row = rowArray.join(",") | |
csvContent += row + "\r\n" | |
} | |
}) | |
var encodedUri = encodeURI(csvContent) | |
window.open(encodedUri) |
Author
marktellez
commented
May 29, 2023
via email
Sorry, I wrote that for a client a long time ago and I don't use
tradingview anymore. Ask chatgpt to give you an updated copy and it
probably can. If you need a primer on chatgpt I wrote a bunch at
https://gptfor.us
On Mon 29 May 2023 at 10:22 wencio daniel martinez ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Hi Mark, thanks for sharing. The code seems to be out dated now and not
working, might you be able to update it please? Thank you
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/marktellez/08353f7dc7dce8b1a1eb705219ec1b2c#gistcomment-4583177>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFLSDB4TOOTEQDDLITWJP43XITELRBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVA4TANZXGE3DCM5HORZGSZ3HMVZKMY3SMVQXIZI>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
--
*Marcus Tellez*
*AI Researcher and Sr. Software Engineer*
Find in-depth articles written by me on ChatGPT <https://gptfor.us/>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment