WIT.AI: Switching between stories - wit.ai

I'm trying to do a simple story that would go something like this:
U: What's the stock symbol for Google?
A: The stock symbol for Google is GOOGL.
U: Give me a stock quote.
A: The current price for GOOGLE is 796.95.
But I'd also like the user to be able to do:
U: Give me a stock quote for GOOGL.
A: The current price for GOOGLE is 796.95.
In addition, I'd like the user to be able to use shorthand and shorten the above to:
U: symbol google
A: The stock symbol for Google is GOOGL.
U: quote
A: The current price for GOOGLE is 796.95.
and
U: quote GOOGL
A: The current price for GOOGLE is 796.95.
or
U: GOOGL quote
A: The current price for GOOGLE is 796.95.
and also:
U: quote
A: What symbol would you like a quote for?
U: GOOGL
A: The current price for GOOGLE is 796.95.
But I can't seem to find a way of structuring the above without WIT.AI freaking out or producing outputs that just dont' work.
I'd paste in some of the iterations I'd try but it's challenging with a UI front end and non-concise code output.
Thanks in advance.

I was able to get this working by adding both an "intent" and "verb". Additionally, I avoided trying to train the "quote" by itself use case.

Related

Alpha Vantage API not working for Brazilian stocks

I am trying to fetch Brazilian stock prices with Alpha Vantage API. For this example, I'll talk about PETR4.
I have used Alpha Vantage Search Endpoint. It returns the symbol of the currency:
{
"bestMatches": [
{
"1. symbol": "PETR4.SAO", ...
} }
Nevertheless, the TIME_SERIES_DAILY endpoint (or any other as a matter of fact) returns an error:
"Error Message": "Invalid API call. Please retry or visit the
documentation (https://www.alphavantage.co/documentation/) for
TIME_SERIES_DAILY."
Notice that it works with GOOG ticker, for example.
Try this: https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=PETR4.SA&apikey=xxx
For all tickers from Alpha Vantage, you need to try the "ticker.exchange". PETR4 is listed on the B3 exchange.
However, a number of Brazilian tickers were listed on the Sao Paolo exchange, which had the suffix .SA. This exchange has since merged with the B3 exchange, and it's suffix has not been changed. A good reference can be seen on the yahoo finance entry of the same ticker.
I'm facing the same issue. This is the outcome when I pass function=SYMBOL_SEARCH and keywords=TOTVS, for instance:
{'1. symbol': 'TOTS3.SAO',
'2. name': 'TOTVS S.A',
However, when trying to reach function=OVERVIEW for symbol TOTS3.SAO, the query returns empty. Same is true for TOTS3, TOTS.SA, TOTS%2ESAO, TOTS%2ESA, TOTS\.SA and TOTS\.SAO

zipline: How to find the sid of symbol such as "AAPL"

I want to use the data in the zipline to do some research. (not in the backtesting )
So how can I find the sid from symbol in a just "helloworld.py"?
zipline.assets.asset, it seems that the asset is implmented in c language.
Thanks
Arthur

how to match concept values in chatscript

If i use a ~concept, how would I know what the user typed?
this is like an entity in typical NLP frameworks.
eg
u: (I am from ~country )
^keep() ^repeat()
you come from _0?
If the user types I am from FRANCE there seems no way to extract the value FRANCE for ~country to echo back to the user or to use it later with perhaps $country=_0
I thought the _0 might help with that, but no workie
This will work but doesn't use concepts just wildcards
u: (I was born [in near close by] _* )
^keep() ^repeat()
you were born in _0?
ref docs
https://github.com/ChatScript/ChatScript/blob/master/WIKI/OVERVIEWS-AND-TUTORIALS/ChatScript-Tutorial.md#short-term-memory--_
seems _ before the ~concept will allow capturing:
u: (I am from _~country )

DAX / Xetra on alphavantage

I am very very happy with Alphavantage.
BUT I can't find the german stocks (Xetra)
I have tried:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=xtr:lin&apikey=MYKEY
(But this works https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=NYSE:DIN&apikey=MYKEY)
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=Lin.be&apikey=MYKEY
(But this works: https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=Novo-b.CO&apikey=MYKEY)
So my question is - has anyone had any luck getting german stocks on Alphavanta (or another free service. Realtime is not crucial, but obviously a plus).
I use the "Search Endpoint" function to find german stocks on alphavantage.
Let's say you look for "BASF" you could query:
https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords=BASF&apikey=[your API key]&datatype=csv
You get a list with possible matches:
symbol,name,type,region,marketOpen,marketClose,timezone,currency,matchScore
BASFY,BASF SE,Equity,United States,09:30,16:00,UTC-05,USD,0.8889
BFFAF,BASF SE,Equity,United States,09:30,16:00,UTC-05,USD,0.8889
BASFX,BMO Short Tax-Free Fund Class A,Mutual Fund,United States,09:30,16:00,UTC- 05,USD,0.8889
BAS.DEX,BASF SE,Equity,XETRA,08:00,20:00,UTC+02,EUR,0.7273
BAS.FRK,BASF SE,Equity,Frankfurt,08:00,20:00,UTC+02,EUR,0.7273
BASA.DEX,BASF SE,Equity,XETRA,08:00,20:00,UTC+02,EUR,0.7273
BAS.BER,BASF SE NA O.N.,Equity,Berlin,08:00,20:00,UTC+02,EUR,0.7273
BASF.NSE,BASF India Limited,Equity,India/NSE,09:15,15:30,UTC+5.5,INR,0.6000
See documentation: https://www.alphavantage.co/documentation/
It seems to work with the yahoo symbols on alphavantage, at least for a few stocks (I did not check all). BASF for example works with:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=BASF.TI&apikey=MYKEY
The alphavantage symbols for German securities consist of the Xetra symbol + .DE. For example EUNL.DE (for iShares MSCI World Core ETF). You can find a list of all Xetra stocks here.

Printing watson entity found in text (input)

I have a situation, where user asks for "I want to buy us dolars". I have already defined the intent for the question "I want to buy". What I need, is to identify which currency user is talking about (buying).
For that, I created an Entity "money", with a value "currency", and its synonyms (us dollar, euros, ienes, ....).
The issue is, that the node recognizes #items:buying and #money:currency. How can I get which currency was found, and use it onto the context/output?
I tried using and also
but it always returns an empty value.
entities[0] returns me only the buying stuff, the first recognized thing. I need the second, specifically by name, in order to customize my conversation flow.
Thanks a lot.
To resolve this, first switch on #sys-currency system entity.
After that, this example should work once training is complete.
Condition: #sys-currency
Response: Currency: <? #sys-currency.unit ?>. Total: <? #sys-currency ?>
However it assumes that you are writing the currency correctly. For example:
20 USD
$20
20 dollars
More details here:
https://www.ibm.com/watson/developercloud/doc/conversation/system-entities.html#sys-currency-entity
To address the other point of finding the value of the recognised text of the entity, you would use:
<? entities[0].literal ?>