JeeZues / TradeBot

GNU General Public License v3.0
4 stars 4 forks source link

Position numbers wrong (multiplied) #7

Closed UC-VR closed 3 years ago

UC-VR commented 3 years ago

Hi,

Same issue that was raised in a previous repo, regarding multiplication of positions, I could not reply before it was removed.

Nevertheless, I decided to do few more tests before reporting this again.

Though this might be to do with windows issues, however I've have setup ubuntu VPS and it still multiplies positions. I have multiple accounts and sub-accounts, and some are have the same multiplier between 4 and 8, while others have different one. Then I though it might be to do with naming of the accounts, so it pulls multiple positions (FS1,FS2,FS3 etc) - however that is not the case, I did change one account name to completely random name and it still picked up multiple positions. i've also tried with smaller bot count - some sub accounts have only 18/19 pairs "in the rotation pool". Same happens to the account that has all 100 pairs "in the rotation pool".

Please let me know, what kind of data I should provide, in order to help with troubleshooting this further.

Some screenshots attached. linux windows

Thanks a lot in advance! VR

JeeZues commented 3 years ago

Hi @UC-VR , Can you run with --show_all and include the bots, I want to see if anything if marked as x? Thanks, JZ

UC-VR commented 3 years ago

Hi @JeeZues,

Thanks for your reply. There you go:

removed code, strange format. attached below

let me me know if anything else might help. VR

UC-VR commented 3 years ago

code formatted strangely, attaching txt tradebot-log.txt

JeeZues commented 3 years ago

can you edit this file locally: https://github.com/JeeZues/TradeBot/blob/main/utils.py#L101 And add few lines of debug to the def get_active_positions_count(positions, bots): function, e.g. `

raw_count = 0
count = 0
for position in positions:
    if float(position['positionAmt']) != 0.0:
        raw_count += 1
        for bot in bots:
            if position['symbol'].replace('USDT','') == ''.join(bot['pairs']).replace('USDT_','') and bot['strategy'] == 'long':
                print(position['symbol'])
                count += int((float(bot['base_order_volume'])//10) - 1)
                print(f"bot['base_order_volume'] = {bot['base_order_volume']}")
                print(f"count = {count}")
        count += 1
print(f"count = {count}")
print(f"raw_count = {raw_count}")
return max(count, raw_count)

`

UC-VR commented 3 years ago

Thanks.

Added the line, restarted the bots (on unix, added --show_all)..... Took me some time here to realize that Python is "intend sensitive" language :)

attaching the log (these are the "test accounts" with many bots there, however both show different Position sizes.

I am starting to see that this might be something to do with "Base Order Volume" size, since I've started using different settings with hither than 10 base order (15/37.5 for example)

Hmm, so it probably reads bot settings, and tries to calculate exposure this way? and probably because I have multiple bots OR sometimes change settings on the fly, it goes crazy?

No, it seems that it pulls all bot settings, from API, not only those that are related to this particular account.

From Windows machine, that has only one pair running - which is BTSUSDT

It pulled all other bots for this pair (that are on different binance accounts, but are on the same 3c account):

BTSUSDT bot['base_order_volume'] = 15.0 count = 0 BTSUSDT bot['base_order_volume'] = 15.0 count = 0 BTSUSDT bot['base_order_volume'] = 15.0 count = 0 BTSUSDT bot['base_order_volume'] = 39.0 count = 2 BTSUSDT bot['base_order_volume'] = 15.0 count = 2 BTSUSDT bot['base_order_volume'] = 10.0 count = 2 count = 3 raw_count = 1

Yes, for sure! cuz 39 BO - was the high risk gambles; while 10 is probably old test bot; and all the 15s are from other sub accounts.

Thanks a lot for your help! I hope this is an easy fix :)

unix-terminal-many-bots-no-open-positions.txt windows-console-bad-formatting-1-active-deal.txt unix-term2-many-bots-many-positions-open.txt

JeeZues commented 3 years ago

Oops, it was a bug in the code. I was not accounting for same bots pairs running on multiple accounts... Now i added a filter by account so I only look at the ones belonging to that specific account. I also make the assumption that Base Orders are in increments of $10 to get the correct running count, e.g. BO of $20 counts as 2 running, etc. Maybe in the future I can adjust it to allow for cases as yours. Test the latest code and let me know if things at least are better :)

UC-VR commented 3 years ago

Thank you! it is much better now! :) will be testing further, and update if anything.

have a nice day!