Joshbazz / polymarket_copy_trader

An automated bot for tailing the trades of the top ranked wallets on Polymarket monthly
5 stars 1 forks source link

Few questions #2

Open niel96 opened 4 hours ago

niel96 commented 4 hours ago

hi,

i seen this script and i'm interested in using it. But have a few questions. Say you copy a whale account and don't have as much money, can you copy everything 1 on 1 but with smaller amounts? Like for example 10% of original amount.

Do gas fees need to be paid when using this script? Because how i understand it, polymarket pays the matic gas fees but when running an automatic script this is an extra cost?

What if a whale puts in an order and the bot tries to copy but price doesn't hit again? Order just stays up?

Regards

Joshbazz commented 2 hours ago

Yes, it is specifically made to trade in smaller amounts than the Whale being copied. You can tweak as necessary, but right now, this logic is located within trade_tailer.py. Specifically, in lines 69 - 72, you will see a variable named trade_risk:

my_balance = n.get_wallet_balance('0x90e9bF6c345B68eE9fd8D4ECFAddb7Ee4F14c8f4')
trade_risk = 0.15
risk_size = my_balance * trade_risk
print(f'Risk Size USD is: {risk_size}')  # type -> float

trade_risk is a percentage of your total wallet balance that you are comfortable using for each trade. So if you have $1,000 in your wallet, and trade_risk = 0.15, each trade the bot takes will be equivalent to a $150 trade. This is very simplistic and should definitely be expanded on.

Gas is handled by Polymarket by the Proxy Wallet infrastructure to the best of my knowledge. After your wallet is initiated and set up for using Polymarket via API, you do not need gas. Upon initial set up to interact with Polymarket programmatically, you will need to send a small amount of MATIC (POL) to the address associated with your Proxy Wallet address and set allowances for their contracts to send and receive money out of your account automatically. Instructions for this can be found here (https://github.com/Polymarket/py-clob-client) and the allowances code here (https://gist.github.com/poly-rodr/44313920481de58d5a3f6d1f8226bd5e).

If a whale tries puts in an order and the bot copies but the price doesn't hit again, the bot will currently create a market order in the direction of the trade. This can also be seen in the trade_tailer.py:

price = client.get_last_trade_price(trade['asset'])
price = float(price['price'])
print(f"Market Title: {trade['title']}")
print(f"current market price is {price}")
# price = trade['price']
size = risk_size / price
side = trade['side']
asset = trade['asset']

These are the parameters that will be used to execute the trade, if all other parameters are met. The trade will be executed if conditions are met within the Try/Except block, and execution of a trade looks as follows:

else:
    # Attempt to execute the trade
    create_order(client, price, size, side, asset)
    # Update the trade status to prevent re-execution
    trade['bot_executed'] = True
    # Save the immediate update back to JSON file
    with open(json_file_path, 'w') as file:
        json.dump(trades, file, indent=4)

else:
    print('No active position, creating trade...')
    create_order(client, price, size, side, asset)
    trade['bot_executed'] = True

    # Save the immediate update back to JSON file
    with open(json_file_path, 'w') as file:
        json.dump(trades, file, indent=4)

You'll see that the operative function here is:

create_order(client, price, size, side, asset)

So in reality, you can edit the parameters needed to make the trade however you want