Skip to content

Instantly share code, notes, and snippets.

@3cBotPlus
Last active October 13, 2022 01:22
Show Gist options
  • Save 3cBotPlus/813e1054d4e3b6e3bfd7ae4d6f086685 to your computer and use it in GitHub Desktop.
Save 3cBotPlus/813e1054d4e3b6e3bfd7ae4d6f086685 to your computer and use it in GitHub Desktop.
Convert CSV exported TradingView List of Trades to CSV List of Deals
#!/usr/bin/awk -f
#
# Author hBroker(3cBotPlus ltda)
# USAGE EXAMPLE
# ./trades2deals.awk tradeslist.csv > dealslist.csv
#
# Don´t forget to make it executable with chmod +x trades2deals.awk
BEGIN{FS="," ;print "Deal","SO Filled","Finalized","Created" }
(NR>1) {
gsub(/"/, "", $3); split($3,a,/[.]/);split(a[1],d,/[#]/);split(a[3],so,/[#]/);
if (a[2]=="TakeProfit") {Finalized=$4; SOFilled=so[2]};
if (d[2]==prev && a[2]=="Base") {Created=$4}; prev=d[2];
if (d[2]==prev && a[2]!="Base") {next}; prev=d[2];
print d[2],SOFilled,Finalized,Created}
@3cBotPlus
Copy link
Author

This simple script rewrites the tradingview list of trades into a list of deals(3Commas DCA bot style)
For each deal processed by the 3cBotPlus Strategy Tester you can get the number of Safety Order(SO) filled, the datetime of the deal creation and the datetime of finalization(the take profit execution).
This script works with a list of completed deal. Please take care to not export a not ended deal on the top of the list.
The intent of this script is the study of the past performance realized by the 3BotPlus strategy tester, especially by using list of trades generated with DeepBackTesting.
By importing the generated list of deals in a spreadsheet tool(Excel, Google, Numeric, etc..) you can easily create your custom charts and stats such as time duration, number of safety orders, etc..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment