mercredi 12 mai 2021

can't break out of if statment

I am coding a simple trading bot which will execute a function every second using threading.Timer(1, MainFunc).start()

and inside this MainFunc i am getting the last price of an item and execute a sell or buy order upon a signal i send by email

and assign a profit price 1% higher than the order price and wait till price get above that profit and then trail the profit with another 1% and so on

ex: order price = 100$ 1st profit price = 101$

if lastPrice > 1st profit : 1st profit=1st profit +((order price*1)/100)

the problem is once lastPrice is greater than the 1stProfit it go into loop and 1stProfit start to increase for ever using 1%

if(GridBuy9Func  == 1  and LastPriceTICKS > GridBuyProfit9Price and GridBuyProfit9Price !=0 and LastPriceTICKS != 0 and TradedamountBuy9 !=0 ): 
        GridBuyProfit9PriceCount=GridBuyProfit9PriceCount+GlobalProfitIncrease
        PreviousGridBuyProfit9Price=GridBuyProfit9Price
        GridBuyProfit9Price=grid9BuyPrice+((grid9BuyPrice*GridBuyProfit9PriceCount)/Margin)
        LOCKPreviousGridBuyProfit9Price=1 
        LOCKPreviousGridBuyProfit9PriceTicks=LOCKPreviousGridBuyProfit9PriceTicks+1
        playsound('bird.mp3')
        print(colored('+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++','green'))

using my code once the LastPriceTICKS is > GridBuyProfit9Price GridBuyProfit9Price increase for ever and the print function execute every time the mainFunc run

so how can i fix this

Thanks

Aucun commentaire:

Enregistrer un commentaire