def changeAsset(self, idAsset): lastPrice = Asset.getLastPrice(self, idAsset) newLastPrice = DBUpdater.randPrice(self, lastPrice) change = Asset.getChange(self, idAsset) newChange = DBUpdater.randChange(self, change) changePercentage = Asset.getChangePercentage(self, idAsset) newChangePercentage = DBUpdater.randPercentage(self, changePercentage) volume = Asset.getVolume(self, idAsset) newVolume = DBUpdater.randVolume(self, volume) Asset.updateAsset(self, idAsset, newLastPrice, newChange, newChangePercentage, newVolume) Asset.notifyObservers(self, self.user, self.tkframe) return newLastPrice
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 getVolume(self, idAtivo): return Asset.getVolume(self, idAtivo)
def getChangePercentage(self, idAtivo): return Asset.getChangePercentage(self, idAtivo)
def getChange(self, idAtivo): return Asset.getChange(self, idAtivo)
def getLastPrice(self, idAtivo): return Asset.getLastPrice(self, idAtivo)
def getAssetType(self, idAtivo): return Asset.getAssetType(self, idAtivo)
def getVolume(self, idContrato): assetId = self.getAssetId(idContrato) return Asset.getVolume(self, assetId)
def getChangePercentage(self, idContrato): assetId = self.getAssetId(idContrato) return Asset.getChangePercentage(self, assetId)
def getLastPrice(self, idContrato): assetId = self.getAssetId(idContrato) return Asset.getLastPrice(self, assetId)