How to retrieve "stop" value of placeholder from TradingView alert - algorithmic-trading

How to retrieve stop value from TradingView alert, is there a "stop" placeholder values for TradingView alerts? I tried these methods but they did work. e.g {{open}} or {{strategy.order.stop}}.
As my understanding, it is feasible to concatenate the stop value with {{strategy.order.comment}} but there should be more appropriate method to retrieve the value from the alert. Please feel free to comment.
strategy.exit("Exit Long #1 " + str.tostring(LongStop), from_entry="Enter Long #1", stop=LongStop)

Related

IMPORTXML To Return a Value from dividendhistory.org

I want to return the value of "Yield:" from a series of stocks from a URL dividenhistory.org, for example HDIF into a Google sheet using IMPORTXML, where F7 represents the user supplied ticker.
=IMPORTXML("https://dividendhistory.org/payout/TSX/"&F7, "/html/body/div/div[2]/div[2]/p[4]")
The problem with the above is the yield value is not always located in the same paragraph, depending on the ticker. It also returns with the word "Yield:" as part of the value.
I believe I should be using the XPATH parameter which should find and return the yield value only, but I am lost. I am open to all suggestions!
I tried with a few of the tickers there, and this should work. For example:
=IMPORTXML("https://dividendhistory.org/payout/ctas/", "//p[contains(.,'Yield')]/text()")
Output:
Yield: 1.05%
Obviously, you can change 'ctas' for any user input.
Try this and see if it works on all tickers.
EDIT:
To get only the number 1.05, you need to split the result and output the 2nd part:
=index(split(IMPORTXML("https://dividendhistory.org/payout/ctas/", "//p[contains(.,'Yield')]/text()"), ": "),2)
Output:
0.0105

ngModel - delete last character

i am using mat-radio-group to bind my data. here data & value are same. which means i have 4 value binded and all 4 value are same. So to differentiate the radio buttons i added index as last value for every radio button.
Now i want to fetch this radio button value into my typescript and also eliminate the lastcharacter(which is index). so i use ngModel & ngModelChange.
I can get the output. but the `mat-radio-button' is not selecting
Here is my code
`
<mat-radio-group class="radioButtonAxis" [(ngModel)]="ngM_Fax" (ngModelChange)="onFaxChange($event)">
<mat-radio-button *ngFor='let data of resultSet;index as i' [value]='data.Fax+i'>{{data.Fax}}</mat-radio-button>
</mat-radio-group>
onFaxChange(value){
this.ngM_Fax = value.substring(0, value.length - 1);
}
`
expecting your help on this.
You are using ngModel wrong. The right value is always in this.ngM_Fax, but it has to match 100% [value]. If you want to use the variable without the index, i would suggest to use an extra variable.
Here is a working StackBlitz.

How to get actions from dynamically created button in RASA

I have create multiple button response with following , now how can get the action from clicking on this button click
class ActionSearchCat(Action):
def name(self):
return "action_search_cat"
def run(self, dispatcher, tracker, domain):
buttons = []
resp = requests.get('http://localhost:3001/api/categoryList/0')
if resp.status_code != 200:
# This means something went wrong.
raise ApiError('GET /tasks/ {}'.format(resp.status_code))
msg = resp.json().get('category_list').get('text')
for list in resp.json().get('category_list').get('choices').items():
for title, value in list.items():
buttons.append({"title": title, "payload": "/"+value})
dispatcher.utter_button_template(msg,buttons)
return []
So first of all, use dispatcher.utter_button_message(msg, buttons) instead of utter_button_template.
Now the buttons will be displayed on the channel to the end-user. After they click one, the next message your AI assistant receives will have the intent value (the payload from the selected button).
You'll have to write a story to handle this intent. If it is a unique intent to this button (i.e. you're not using something generic like Yes or No for your buttons) then the best approach would be to use the MappingPolicy. Either way, you'll also have to add the following story to your data as well:
## button_specific_action
* value
- corresponding_action_for_value

RASA FormAction ActionExecutionRejection doesn’t re-prompt for missing slot

I am trying to implement a FormAction here, and I’ve overridden validate method.
Here is the code for the same:
def validate(self, dispatcher, tracker, domain):
logger.info("Validate of single entity called")
document_number = tracker.get_slot("document_number")
# Run regex on latest_message
extracted = re.findall(regexp, tracker.latest_message['text'])
document_array = []
for e in extracted:
document_array.append(e[0])
# generate set for needed things and
document_set = set(document_array)
document_array = list(document_set)
logger.info(document_set)
if len(document_set) > 0:
if document_number and len(document_number):
document_array = list(set(document_array + document_number))
return [SlotSet("document_number", document_array)]
else:
if document_number and len(document_number):
document_array = list(set(document_array + document_number))
return [SlotSet("document_number", document_array)]
else:
# Here it doesn't have previously set slot
# So Raise an error
raise ActionExecutionRejection(self.name(),
"Please provide document number")
So, ideally as per the docs, when ActionExecutionRejection occurs, it should utter a template with name utter_ask_{slotname} but it doesn’t trigger that action.
Here is my domain.yml templates
templates:
utter_greet:
- text: "Hi, hope you are having a good day! How can I help?"
utter_ask_document_number:
- text: "Please provide document number"
utter_help:
- text: "To find the document, please say the ID of a single document or multiple documents"
utter_goodbye:
- text: "Talk to you later!"
utter_thanks:
- text: "My pleasure."
The ActionExecutionRejection doesn't by default utter a template with the name utter_ask_{slotname}, but rather leaves the form logic to allow other policies (e.g. FallbackPolicy) to take action. The utter_ask_{slotname} is the default for the happy path in which it's trying to get a required slot for the first time. This default implementation of the action rejection is there in order to handle certain unhappy paths such as if a user decides they want to exit the flow by denying, or take a detour by chatting, etc.
If you want to implement the template to re-ask for the required slot using the utterance, you could replace the ActionExecutionRejection with dispatcher.utter_template(<desired template name>, tracker). However, this will leave you with no way to exit the form action without validation -- I don't know what your intents are, but perhaps you want to also incorporate some logic based on the intent (i.e. if it's something like "deny", let the ActionExecutionRejection happen so it can exit, it it's an "enter data" type of intent make sure it asks again).

How to pass & (ampersand symbol) in ajax get or post method?

I have a text box to enter description
If i submits that need to be send through ajax and store in db.
Problem:-
Example text in textbox:- "Hi all & solve my problem"
in the next page i am getting till "Hi all"
Remaining text is missing, If I pass through get or post method using ajax.
Give me the solution. How to get all the content I placed in text box along with "&"
You need to urlencode string with escape or encodeURIComponent functions.
Yes, I have faced same type issue and find out solution that we need to pass data as a key value pair,
I had passed data in Ajax like:
data : email=" + email + "&name='" + name
But right way for passing data in Ajax is :
data: {
email : email,
name : name
}

Resources