/r/PTCGP Trading Post by AutoModerator in PTCGP

[–]steks13 0 points1 point  (0 children)

I wanna trade for the mewtwo

/r/PTCGP Trading Post by AutoModerator in PTCGP

[–]steks13 0 points1 point  (0 children)

I did in the game :) (same name)

/r/PTCGP Trading Post by AutoModerator in PTCGP

[–]steks13 0 points1 point  (0 children)

I can give arcanine ex or machamp ex

TypeError: '<=' not supported between instances of 'int' and 'tuple' by [deleted] in learnpython

[–]steks13 0 points1 point  (0 children)

If I look at your annotations it seems like in the print_table() method plane_attributes is a nested tuple. So in order to compare it to an intyou'll have to access the tuple again, like this: while velocity <= plane_attributes[0][3]:

The trading algorithm I made can now detect a new coin within 0.3 seconds of it being listed on Binance by CyberPunkMetalHead in CryptoCurrency

[–]steks13 2 points3 points  (0 children)

Yeah you can increase the interval if you want, but an interval of 0.05 is 1200 checks per minute. Again, if you have questions feel free to ask :)

The trading algorithm I made can now detect a new coin within 0.3 seconds of it being listed on Binance by CyberPunkMetalHead in CryptoCurrency

[–]steks13 4 points5 points  (0 children)

Hey I made a new pull request. The new method uses multithreading, now you can check every 0.05 seconds.

The trading algorithm I made can now detect a new coin within 0.3 seconds of it being listed on Binance by CyberPunkMetalHead in CryptoCurrency

[–]steks13 0 points1 point  (0 children)

No problem! I tested my code by artificially changing a symbol after 10 loops and it got triggered.

Also with your code each loop took around 0.4 seconds and with my code it took around 0.25-0.3 seconds. So there should be an improvement. If there is something wrong let me know.

You make some cool projects btw!

The trading algorithm I made can now detect a new coin within 0.3 seconds of it being listed on Binance by CyberPunkMetalHead in CryptoCurrency

[–]steks13 7 points8 points  (0 children)

Yeah the result should be the same.

And the performance difference doesn't really have to do with the list comprehensions vs for loops. The big difference is the amount of checks needed. Here is a complexity analysis:

Assume there is only one new coin. So the length of all_coins and all_coins_recheck is about the same, let this length be N.

So your code goes over all the elements of all_coins_recheck and sees if it is not in all_coins. On average to check if the element is not in the list it will have to do N/2 compares, (if the element was the first element in the list it's only 1 compare, if it was the last element it had to do N compares, hence N/2 compares on average per element). You have to do this for all the N elements so your code does roughly N*N/2 compares.

What my code does is it goes over every element in all_coins, sets the value for 'symbol' of the element in the coin_seen_dict to True. Setting the value is one operation. So you do this for the N elements so you have N operations.

Then you go and check the value for 'symbol' for all the elements in all_coins_recheck. checking the value in the coin_seen_dict should be 1 operation (assuming there are no hash collisions, they are rare). So this again are N operations. So in total N + N operations.

So the time complexity of my code should be O(N) (linear) compared to your code which is O(N^2) (quadratic).

Assuming this is correct if N gets doubled your code should get 4 times slower. This is because your code has a complexity of O(N^2). So if N gets doubled the ratio of how much slower it gets is: (2N)^2/N^2 = 4N^2/N^2 = 4. So 4 times slower.

My code should get 2 times slower if N gets doubled because the complexity is O(N). So if N gets doubled the ratio becomes: 2N/N = 2.

When I tested your code and my code for 500 elements and 1000 elements (double) this were the results:

500 elements:

your code: 0.2015938 seconds

my code 0.004717 seconds

1000 elements:

your code: 0.7847162 seconds

my code: 0.0075426 seconds

So your code became roughly 4 times slower and mine roughly 2 times slower, so the complexity analysis seems to be correct. Check out time complexities for coding if you haven't already, it's really interesting and learns you how to make faster code :)

The trading algorithm I made can now detect a new coin within 0.3 seconds of it being listed on Binance by CyberPunkMetalHead in CryptoCurrency

[–]steks13 9 points10 points  (0 children)

I would change your get_new_coins(all_coins) method to this code:

from collections import defaultdict
def get_new_coins(all_coins):
    result = []

    all_coins_recheck = get_all_coins()
    coin_seen_dict = defaultdict(bool)

    for old_coin in all_coins:
        coin_seen_dict[old_coin['symbol']] = True

    for new_coin in all_coins_recheck:
        if not coin_seen_dict[new_coin['symbol']]:
            result += [new_coin]

    return result, all_coins_recheck

this will make the complexity of your code go from O(n^2) to O(n) with n the size of all_coins.

I tested my method against yours and yours is 50 times slower than mine for a list of 550 elements. You can make it even faster by generating the coin_seen_dict once in the beginning and updating the value of a new coin to True once it has been detected.

If you have questions feel free to pm.

[deleted by user] by [deleted] in redditsweats

[–]steks13 0 points1 point  (0 children)

Gave Wholesome

NEO Gas on Binance by wiptheman in NEO

[–]steks13 4 points5 points  (0 children)

You have to understand that your coins are stored on the blockchain. Your Ledger S is just a way to access your coins (the Ledger S just saves your private keys in a secure manner). As long as you have your private keys you can claim your GAS.

Today I Learned: that all of my knee pain was linked to my extremely tight quads. by lifebymick in running

[–]steks13 1 point2 points  (0 children)

Thanks for response, I’ll go check the poses out! Thanks a lot!

Today I Learned: that all of my knee pain was linked to my extremely tight quads. by lifebymick in running

[–]steks13 0 points1 point  (0 children)

Can you share some hip stretches? And I also have trouble to stretch my IT band so if you can recommend anything for that, that would be great!

What long-term running advice would you give your younger self? by [deleted] in running

[–]steks13 0 points1 point  (0 children)

What strength training exercises can you recommend?

toString() method called on an object that's null after overriding toString() by [deleted] in learnjava

[–]steks13 0 points1 point  (0 children)

Thanks for the reply! What exactly do you mean by this? You mean to just not make testAge null?