Exemple #1
0
 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 "-"
Exemple #2
0
 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 "-"
Exemple #3
0
 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)
Exemple #4
0
 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")
Exemple #5
0
 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)
Exemple #6
0
    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)
Exemple #7
0
    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)
Exemple #8
0
 def getStopLoss(self, idContrato):
     return Contract.getStopLoss(self, idContrato)
Exemple #9
0
 def getTakeProfit(self, idContrato):
     return Contract.getTakeProfit(self, idContrato)
Exemple #10
0
 def getEndOfContract(self, idContrato):
     return Contract.getEndOfContract(self, idContrato)
Exemple #11
0
 def getAssetId(self, idContrato):
     return Contract.getAssetId(self, idContrato)
Exemple #12
0
 def getSellPrice(self, idContrato):
     return Contract.getSellPrice(self, idContrato)
Exemple #13
0
 def getNumberOfAssets(self, idContrato):
     return Contract.getNumberOfAssets(self, idContrato)
Exemple #14
0
 def getAssetId(self, idContrato):
     assetId = Contract.getAssetId(self, idContrato)
     return assetId
Exemple #15
0
 def observerUpdate(self):
     self.tableContents = Contract.getAvailableContracts(self)
Exemple #16
0
 def getBuyPrice(self, idContrato):
     return Contract.getBuyPrice(self, idContrato)
Exemple #17
0
 def getStatus(self, idContrato):
     return Contract.getStatus(self, idContrato)