Voice assistant for operations on the Moscow Exchange: “Alice, buy Yandex shares”

- Alice, buy one Yandex.

- Order to buy Yandex at market price, ticker: YNDX, number of shares: 1, to confirm, say “I confirm”, to cancel, say “no”.

- I confirm.

- The application has been executed.





I am making an open source voice interface for performing securities transactions on the Moscow Exchange. I was hatching the idea from childhood. I remember the first time a voice assistant saw me in a movie about twenty years ago, while I didn’t even have a wired telephone in my house. And now I have an unlimited Internet connection, a brokerage account, which I can manage through a smartphone. Over twenty years, technology has become more affordable.



How it all began



A year and a half ago, Yandex.Station appeared in my house. I began to notice that sometimes, lying in bed, I was too lazy to reach out for my smartphone to read the news, and then I asked Alice to tell how the world had changed while I was sleeping. From the first days I appreciated the convenience of voice assistants, and expected millions of developers to pounce on voice interfaces in the same way as they once pounced on the development of mobile applications for all occasions.



As time passed, useless bank voice assistants appeared in Alice's skills catalog (no offense to developers). At Sberbank, for example, the assistant voiced the terms of the loan and offered to come to the branch, at Tinkoff the same thing, only instead of the branch he offered to go to the website to fill out an application. Guys who developed this, please do not be offended by me, but I really don’t want to go anywhere, neither to the department, nor to the site, I want to be able to transfer 100 rubles to a friend with the phrase: “Alice, send 100 rubles to Sasha.”



The idea is on the surface, but for some reason, no one has yet implemented it. Why? Maybe no one uses voice assistants? Maybe there are legal restrictions? Are there security issues? Something else? Please share in the comments if you know.



At some point, I just got out of bed and started doing a private skill for Alice to voice control my brokerage account. I went through my brokers and settled on Tinkoff Investments OpenAPI. Then he plunged into studying the capabilities of the Yandex.Dialogi platform for a month, and after a while he bought the first securities through a voice assistant on the Moscow Stock Exchange - one lot of VTB Bank. I hope this deal goes down in history.



From the very beginning, I decided that I would not hide the source code so that anyone who wants to can set up a voice assistant for themselves: https://github.com/denismosolov/oliver



Take a pie from the shelf and finally tell us about the problems



There are many companies, but I am alone



When I say to Alice: “Buy one share of Yandex,” the Yandex.Dialogs platform extracts the name of the security from the phrase and converts it into a special FIGI (Financial Instrument Global Identifier) identifier needed to interact with the trading platform through OpenAPI. This is how FIGI looks for Yandex shares traded on the Moscow Exchange: BBG006L8G4H1.



The conversion to FIGI only happens for those company names that I described in the Entities in Dialogues section . You can read more about this in the documentation . For example, here is a snippet of entity code:



entity EFigi:
    values:
        BBG005DXJS36:
            %exact
            TCS
            %lemma
            ()?
            ()?
            ()?
               ()?


This work is very laborious, you need to describe all the companies that are traded on the Moscow and St. Petersburg stock exchanges, but the result can be useful for traders, investors, developers of voice assistants and even companies whose shares are traded on stock exchanges. Here is a file describing the EFigi entity on GitHub , I am slowly adding to it.



People call the same companies in different ways, for example, someone will say “Sberbank”, and someone will say “Sberbank”. Ordinary shares of Sberbank and preferred (prefs) are traded on the stock exchange. I would like to take into account all the popular options.



The company trades on two exchanges in different currencies



TCS Group Global Depositary Receipts can be bought on the Moscow Exchange for rubles, or on the St. Petersburg Exchange for dollars. In a good way, the voice assistant should clarify in which currency to buy receipts, but sometimes, this can be understood from the context.



For example, when I say: “Sell one share in TCS Group”, and I only have shares in rubles on my account, then I need to sell in rubles on the Moscow Exchange without specifying. If I have TCS Group shares in rubles and dollars on my account, then Alice should ask a clarifying question: "Do you have TCS Group global depositary receipts in rubles and dollars, in what currency do you want to sell?"



I have not yet implemented this and TCS Group is always bought and sold for dollars. But, I hope, I will soon take up placing applications for the purchase and sale of securities at a given price (limit applications), and there I will teach a voice assistant to pour shares on different exchanges in the currency that will be in the purchase or sale price.



Recognition errors



People ask, what will happen if Alice recognizes something wrong, for example, buys the wrong paper or the wrong amount? For this, I have provided for the confirmation of transactions. After Alice recognizes the buy or sell command, she says the details of the transaction and waits for confirmation. If confirmation does not follow, then the transaction will not take place.



The message when confirming the transaction is: “Application for <purchase | sale> <$ value_name_name> at <$ price_to_one_paper>, ticker: <$ ticker>, number of shares: <$ quantity>, for confirmation, confirm, for cancellation, say no. ”



Such confirmation is perfectly audible, but there is one flaw. Alice does not read the name of the ticker well, for example, YNCX, it sounds like a yinx.



I wanted to write a function that would parse tickers by letter, and for each letter played a sound from the sound of the English alphabet. The code would take a YNDX string as input, and return a string like this in tts format:



<speaker audio="sounds-y.opus"><speaker audio="sounds-n.opus"><speaker audio="sounds-d.opus"><speaker audio="sounds-x.opus">


Alice will play sounds, and in theory everything will sound good.



Security when making transactions





To use OpenAPI, you have to disable confirmation of SMS transactions in Tinkoff Investments, and this creates security risks. For example, an investor went for a walk with his dog, and the children decided to play with Alice and sold all the shares.



The first thing that comes to mind is to use a code word to confirm transactions, but children can easily overhear and remember it. And the other options that came to my mind will require the developers of voice assistants to make great efforts. The coolest thing is the identification of a person by voice, i.e. make it so that only the account owner could make a deal, and Alice would politely refuse any other person. Judging by the fact that Alice knows how to memorize people by voice , work in this direction is underway. But it doesn't seem to be that easy to do.



Another option that comes to mind is the confirmation of transactions by a fingerprint, like on smartphones, but for this a fingerprint reader must be built into the smart speaker, but this will probably not be very practical, and most likely will increase the cost smart speakers.



If you know how to confirm transactions in similar applications abroad or just want to share an idea, then please write in the comments.



Instead of a conclusion



As a former colleague says: “Everything will be fine, but a little later.” I believe that banks and brokers will sooner or later realize all this, but for now, it remains the lot of enthusiasts and makers like me.



See you in the future!



All Articles