henrydatei / wikifolio-api

A Python API-Wrapper for the unofficial wikifolio API
GNU General Public License v3.0
17 stars 4 forks source link

2FA #3

Open Jenseman33 opened 1 year ago

Jenseman33 commented 1 year ago

Hi, first of all best thanks for coding the API ! Unfortunately it is only possible to order with 2FA active at Wikifolio. You wrote that you implemented it but it needs further testing. Is there any newer information on this yet? I am also willing to test this :D Thanks BG Jens

henrydatei commented 1 year ago

Yes, I have implemented 2FA using TOTP. This needs some sort of initial key and than you can use

from wikifolio import Wikifolio

wf = Wikifolio("email", "password", "wikifolioID", "2FA key")
print(wf.performance_ever)

If you make a quote order than the TOTP package will generate a number from you initial key and verify the trade with that.

Unfortunately my wikifolio doesn't use 2FA and I can't activate it without sending my passport etc. to wikifolio, I can never try if everything is working. So if you make any changes please submit a pull request.

Jenseman33 commented 1 year ago

I am sorry, but it doesn´t work. print(wf.performance_ever) works fine, but I can´t place an order. I tested the following with pyotp and it generates the correct wikifolio OTP.

import pyotp
totp = pyotp.TOTP("ABCDEFGHIJKLMN")
print("Current OTP:", totp.now())

I don´t see where you are using the temporary key. To me it looks like you are missing the "totp.now()" in the following part, but I am new to python and can´t figure out how to add it.

if self.twoFA_key != None:
      auth = requests.post('https://www.wikifolio.com/api/totp/verify', data = self.twoFA_key, cookies = self.cookie)
      cookies = auth.cookies

Maybe I am completely wrong.

henrydatei commented 1 year ago

I'm also new to using TOTP but I've adapted your working code into the buy and sell quote functions. I don't know if you have to use 2FA when doing limit orders, maybe you can help me with that.

Jenseman33 commented 1 year ago

Doesn´t work :D I think the original key for the TOTP needs to stay in the link but also the temporary key. How do you know how the "https://www.wikifolio.com/api/totp/verify" link has to look? I can show you an 2FA Order in Wikifolio if that helps. Before every trade wikifolio ask for the 2FA so a limit order also needs the 2FA. This is my Discord name if you want a quick view at a 2FA order. Jens#6865 I am from Germany.

Jenseman33 commented 1 year ago

The quote order doesn´t work for me. I get the following error and with my limited skills I can´t fix it:

"websocket._exceptions.WebSocketBadStatusException: Handshake status 400 Bad Request"

Feel free to write me if you need 2FA login data. I will keep using your wikifolio api without the order option. Thanks that you made it public!

henrydatei commented 1 year ago

I think currently no orders at all work, even limit orders:

{
 "success":false,
 "reason":"An error of unclarified origin has occurred. If the error persists, contact support@wikifolio.com."
}
henrydatei commented 1 year ago

I've asked other creators of API wrappers if they have the same issues: https://github.com/RienNeVaPlus/wikifolio/issues/22

quantomas commented 1 year ago

Hi everybody, this is a cool package. I have tested it on my wikifolio. I don't use 2FA. The package works fine with limit and stop-limit-orders (I have added several methods into the class). Never encountered any issues. My wikifolio is not yet investible. But with the current wikifolio (test phase), no problems so far. As far as I know, 2FA is optional. What don't you simply change your login procedure to the old style (mail and password)?

quantomas commented 1 year ago

Summary: everything in this package (I don't use everything, but portfolio assets, executed trades, orders are very important for me) was tested by me for several months, I have also added many usefull things. Currently, I cannot check the 2FA feature. My wikifolio is not investible yet. I will check the situation once I have applied for the "emission process". It looks that 2FA is mandatory in this case. We will see.

quantomas commented 1 year ago

Very important suggestion for everbody using this package! Don't overdo the API calls. The wikifolio team is not stupid, make pauses/delays between EVERY api action, for example a few seconds. Otherwise it is likely that your IP or account gets blocked. Don't abuse this package to "make a full copy" of the wikifolios on our machine. Only use what you really need!

Jenseman33 commented 1 year ago

2FA is mandatory for investable wikifolios and you can't deactivate 2FA afterwards. It is still possible to get the wikifolio information with 2FA activated but the order options wont work.

quantomas commented 1 year ago

2FA is mandatory for investable wikifolios and you can't deactivate 2FA afterwards. It is still possible to get the wikifolio information with 2FA activated but the order options wont work.

Do you know if wikifolio is going to offer an "api-like interface" for orders? Otherwise it is VERY tedious to place hundreds of orders everyday. From my point of view, a professional trading style requires this amount of orders every single day.