def getType(self, idContrato): sellerId = Contract.getSellerId(self, idContrato) buyerId = Contract.getBuyerId(self, idContrato) if (sellerId == "-"): return "Available to Sell" if (buyerId == "-"): return "Available to Buy" else: return "-"
def getType(self, idContrato): sellerId = Contract.getSellerId(self, idContrato) buyerId = Contract.getBuyerId(self, idContrato) if (("'" + self.user + "'") == sellerId): return "Sell" if (("'" + self.user + "'") == buyerId): return "Buy" else: return "-"
def changeContract(self, contract, newLastPrice): todayDate = date.fromtimestamp(time.time()) sellPrice = Contract.getSellPrice(self, contract) endOfContract = Contract.getEndOfContract(self, contract) takeProfit = Contract.getTakeProfit(self, contract) stopLoss = Contract.getStopLoss(self, contract) sellerId = Contract.getSellerId(self, contract) buyerId = Contract.getBuyerId(self, contract) status = Contract.getStatus(self, contract) numberOfContracts = Contract.getNumberOfAssets(self, contract) Contract.updateContract(self, contract, newLastPrice, sellerId, buyerId, sellPrice, todayDate, endOfContract, takeProfit, stopLoss, status, numberOfContracts)
def buyButtonClicked(self): contract = self.E1.get() buyerId = Contract.getBuyerId(self, contract) assetId = Contract.getAssetId(self, contract) buyPrice = Asset.getLastPrice(self, assetId) if (buyerId == 0): value = Contract.addBuyer(self, contract, self.user, buyPrice) if (not value): messagebox.showerror("Buy error", value) else: messagebox.showinfo("Buy info", "You bought the contract") else: messagebox.showerror("Buy error", "Contract already has a buyer")
def sellButtonClicked(self): asset = self.E1.get() endOfContract = self.E2.get() takeProfit = self.E3.get() stopLoss = self.E4.get() numberOfContracts = self.E5.get() result = Contract.isValidContract(self, asset, endOfContract, takeProfit, stopLoss, numberOfContracts) if(result==True): assetId = AssetType.getTypeId(self, asset) sellPrice = Asset.getLastPrice(self, assetId) Contract.createContract(self, assetId, self.user, endOfContract, sellPrice, takeProfit, stopLoss, numberOfContracts) messagebox.showinfo("sell info", "You're selling the contract") else: messagebox.showerror("Sell error", result)
def run(self): while True: newLastPrice = 0 for x in range(1, 9): newLastPrice = DBUpdater.changeAsset(self, x) contracts = Contract.getOpenAssetContracts(self, x) for contract in contracts: DBUpdater.changeContract(self, contract, newLastPrice) secondsToSleep = randint(1, 5) time.sleep(secondsToSleep)
def __init__(self, email): self.user = email self.contractsTable = tkinter.Tk() self.W = Label(self.contractsTable, text="OTP") self.L = Label(self.contractsTable, text="Contracts Available:") self.W.grid(row=1, columnspan=2) self.L.grid(row=2, columnspan=2) self.createTableContractsAvailable() self.tableContents = Contract.getAvailableContracts(self) getBack = Button(self.contractsTable, text="Back to Menu", command=self.getBackClicked) getBack.grid(columnspan=2)
def getStopLoss(self, idContrato): return Contract.getStopLoss(self, idContrato)
def getTakeProfit(self, idContrato): return Contract.getTakeProfit(self, idContrato)
def getEndOfContract(self, idContrato): return Contract.getEndOfContract(self, idContrato)
def getAssetId(self, idContrato): return Contract.getAssetId(self, idContrato)
def getSellPrice(self, idContrato): return Contract.getSellPrice(self, idContrato)
def getNumberOfAssets(self, idContrato): return Contract.getNumberOfAssets(self, idContrato)
def getAssetId(self, idContrato): assetId = Contract.getAssetId(self, idContrato) return assetId
def observerUpdate(self): self.tableContents = Contract.getAvailableContracts(self)
def getBuyPrice(self, idContrato): return Contract.getBuyPrice(self, idContrato)
def getStatus(self, idContrato): return Contract.getStatus(self, idContrato)