beeb / pancaketrade

Limit orders for PancakeSwap
GNU General Public License v3.0
200 stars 91 forks source link

Request: Disable PK input every run poetry trade #75

Closed geeks121 closed 2 years ago

geeks121 commented 2 years ago

Every time i'm start this bot it always ask Private key.. and for me this annoying ,, i try to change the code but it failed ,,

i think the best way is to acess .env WALLET_PK as docker do ,,

as in readme.md i have try created .env file with WALLET_PK=MYPK

in root and user_data ,,, the prompt asked for pk is still exist,,,

is this should be tagged as bug?

beeb commented 2 years ago

Please refer to https://github.com/beeb/pancaketrade#run-as-a-service where it's described how to provide the environment variable to the script

beeb commented 2 years ago

I could add parsing of a ".env" file in the future but for now .env file is not supported.

geeks121 commented 2 years ago

Please refer to https://github.com/beeb/pancaketrade#run-as-a-service where it's described how to provide the environment variable to the script

yes already do and it works with docker-compose.. but with poetry run trade .. it keep asking for the pk..

i think the best way is to safe the private key in .env or config.yml

btw where should i change the code for call parameter from config.yml?

thanks you

beeb commented 2 years ago

Running as a service is not the same as docker compose. You can run the "poetry run trade" command from a systemctl service which supports adding environment variables inside the service file, see the "pancaketrade.service" file.

Alternatively, you can also add your private key before the command in the shell if you don't mind that it gets recorded in the shell history:

$ WALLET_PK=MYPK poetry run trade
beeb commented 2 years ago

https://github.com/beeb/pancaketrade/blob/c8b7a6a3ec2b426de07d9adbcfc3a76bbb334e2f/pancaketrade.service

geeks121 commented 2 years ago

Running as a service is not the same as docker compose. You can run the "poetry run trade" command from a systemctl service which supports adding environment variables inside the service file, see the "pancaketrade.service" file.

Alternatively, you can also add your private key before the command in the shell if you don't mind that it gets recorded in the shell history:

$ WALLET_PK=MYPK poetry run trade

thank you for the info ,,, using $ WALLET_PK=MYPK poetry run trade ,, may be i can make simpe script to run this command ,, also for run as service i still no need the urgent to use it as service ...

beeb commented 2 years ago

Yes sure you can make a script for instance like:

#!/bin/sh
export WALLET_PK=MYPK
poetry run trade

and run it from the root folder of the project.

geeks121 commented 2 years ago

i think this script for alternative purpose ,, call this script run.py ,,

import subprocess
command = "WALLET_PK=MYPK poetry run trade"
ret = subprocess.run(command, capture_output=True, shell=True)
# before Python 3.7:
# ret = subprocess.run(command, stdout=subprocess.PIPE, shell=True)
print(ret.stdout.decode())
beeb commented 2 years ago

Added suggestion for .env file support at https://github.com/beeb/pancaketrade/issues/76

beeb commented 2 years ago

i think this script for alternative purpose ,, call this script run.py ,,

import subprocess
command = "WALLET_PK=MYPK poetry run trade"
ret = subprocess.run(command, capture_output=True, shell=True)
# before Python 3.7:
# ret = subprocess.run(command, stdout=subprocess.PIPE, shell=True)
print(ret.stdout.decode())

I am not sure how this would interact with the poetry tool. You can try and if it works, good. If it doesn't work, create a shell script like I showed above.

geeks121 commented 2 years ago

working

beeb commented 2 years ago

support for .env file has been added in 0.6.2

geeks121 commented 2 years ago

nice thank you