harwee / IQOption-Api

** Unmaintained ** I have rewritten some of the functionality using async if you are want to use the updated code you can use the code from `async` branch
Apache License 2.0
53 stars 54 forks source link

How to determine a profit or a loss? #47

Open MightyMaxSaviorOfTheUniverse opened 5 years ago

MightyMaxSaviorOfTheUniverse commented 5 years ago

Hello

I can't seem to find any method that shows you whether you have made a profit or a lose from your last trade, or even if that trade has been concluded

Can anyone point me in the right direction with some working code examples?

Thank you in advance

djumpen commented 5 years ago

I was unable to find proper solution for this and that is why I made it in this way:

def make_bid(pair, direction):
    threadUpdater = Thread(target=update_reports)
    threadUpdater.start()
    ... (making bid)
def update_reports():
    time.sleep(2 * 60)
    for k, item in iqoption.portfolio.items():
        if item.win == "equal":
            continue
        ... (handle "k" as bid result)

This example ignores cases when result is really "equal", but it is fine for me. It is not a production solution

MightyMaxSaviorOfTheUniverse commented 5 years ago

I was unable to find proper solution for this and that is why I made it in this way:

def make_bid(pair, direction):
    threadUpdater = Thread(target=update_reports)
    threadUpdater.start()
    ... (making bid)
def update_reports():
    time.sleep(2 * 60)
    for k, item in iqoption.portfolio.items():
        if item.win == "equal":
            continue
        ... (handle "k" as bid result)

This example ignores cases when result is really "equal", but it is fine for me. It is not a production solution

MightyMaxSaviorOfTheUniverse commented 5 years ago

@djumpen @harwee

I've encountered a new problem

What do you do if Portfolio is never populated?

_dictitems([])

In such a situation it is impossible to determine a win, lose or break even.

Is there any other way to determine if a bid has ended and the result?