2

I am attempting to automate my strategy and have added a comment into the strategy entry/exits with = "Buy {{ticker}} q=xxxx" as an example. I then use this {{strategy.order.comment}} in the alert message.

What returns is a ticker code like BTCUSDT.P which is not accepted by Bybit - they are expecting BTCUSDT.

As I've coded that comment parameter section to be copied easily across all entries/TP/SLs, I am now unsure how to resolve this without manually hardcoding each individual entry/exit.

Are there any suggestions to trimming the .P values from the tickers? I assume there's possibly a library somewhere or one that could be created to do so?

I've spent a good part of this afternoon research Stack, google, youtube but without finding anything remotely helpful. Has anyone else come across this and been able to resolve it?

e2e4
  • 3,428
  • 6
  • 18
  • 30
Durrr
  • 23
  • 2

1 Answers1

2

The built-in placeholder values ({{ticker}} for ex) cannot be changed, but you can manually trim the ".P" part and include it in the comment= and then use the {{strategy.order.comment}} placeholder with all the information you need.

Use the str.replace_all() to get rid of ".P":

myTicker = str.replace_all(syminfo.ticker, ".P", "")

Update:

strategy.entry("My Short Entry Id", strategy.short, comment = "Buy " + myTicker + " q=xxxx")
e2e4
  • 3,428
  • 6
  • 18
  • 30
  • Sorry to be a nuisance but I am unable to add this updated string into the 'comment' section, I guess that's due to me having {{plot("myTicker")}} while it's not a plot. What's the syntax to replace ticker with this? – Durrr Feb 16 '23 at 04:50
  • You don't have to use placeholders for the string variables in a `comment=` parameter. Updated my answer with an example. – e2e4 Feb 17 '23 at 13:31