def OnToggle(self, event): exch_conn = setapi( self.key_input.GetValue(), self.sec_input.GetValue(), self.passphrase.GetValue()) #connects to exchange and saves it state = event.GetEventObject().GetValue() #print(self.state) #rint("onnnd") #print(event.GetEventObject().GetValue()) if state == True: #print(self.state) self.state = 1 event.GetEventObject().SetLabel("Stop") #change button text self.start.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggleOff) while self.state == 1: time.sleep(1) price = getcurprice(self.mkt_input.GetValue()) #print(price) self.pricetkr.SetLabel(str(price)) #gotta turn it to a strong self.stattkr.SetLabel("Waiting for appropriate price.") wx.Yield() else: event.GetEventObject().SetLabel("Start")
import actionscoinbase key = '38862b81fe15448a1242279edcb13180' sec = 'I3rTOMLIcqNFrdGn/8HT2aVnHJH/n3bqu2F2aTJeUaiRUqoS7uf0YB8DJ20owVbXWE6n4l7tPJFTBrqJUQe57Q==' api = actionscoinbase.setapi(key, sec, 'Hu0ch3!@#') test = actionscoinbase.sellit('BTC-USD', .001, api) print(test)
def startbot(self, event): done = 0 bought = 0 round = 1 state = event.GetEventObject().GetValue() exch_conn = setapi( self.key_input.GetValue(), self.sec_input.GetValue(), self.passphrase.GetValue()) #connects to exchange and saves it market = self.mkt_input.GetValue() btarget = float(self.buy_tgt.GetValue()) buy_limit = self.buy_limit.GetValue() min_profit = float(self.min_profit.GetValue()) stp_loss = float(self.stop_loss.GetValue()) while done == 0 and state == True: #print('round =', round) time.sleep(1) cprice = float(getcurprice(market)) #get the price #update ticker self.pricetkr.SetLabel(str(cprice)) #update the button lol event.GetEventObject().SetLabel("Stop") boughtp = 0 print('round: ' + str(round)) if round == 1: sellprice = setsell(float(cprice), min_profit) lossprice = setsloss(cprice, stp_loss) print('got price:' + str(cprice)) print('sellprice is ', str(sellprice)) if cprice <= btarget and bought == 0: numberbought = buyit(market, buy_limit, exch_conn) boughtp = cprice print('bought for ', boughtp) bought = 1 sellprice = setsell(boughtp, min_profit) round += 1 self.stattkr.SetLabel("bought price is " + str(boughtp)) elif cprice >= btarget and bought == 0: print('price is too high:', cprice) if cprice < lossprice and bought == 1: soldprice = sellit(market, numberbought, exch_conn) print('STOPLOSS MET: selling for ', cprice) round = 1 bought = 0 done = 1 self.start.SetValue(False) print('bought = ', str(bought)) if cprice > boughtp and bought == 1: # if the price is up set it as the new bought price #sellit(numberbought) print('sellprice is ', sellprice, 'in loop') print('were up') stp_loss = float(self.stop_loss.GetValue()) lossprice = setsloss(cprice, stp_loss) print('Sellprice is now ', sellprice, ' with stoploss') else: #print('price is ', cprice) #print('nothing') round += 1 wx.Yield() self.start.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggleOff) state = event.GetEventObject().GetValue()