Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def quitMenu():
dramaticTyping("Do you want to try again? Y/N ")
answer = raw_input("").upper()
if answer == 'Y':
main()
else:
exit()
def inputBuy():
dramaticTyping("Select the crypto curreny you want to buy? \n")
curreny = raw_input("").upper()
dramaticTyping("That's great. How much quantity you want to buy? \n")
quantity = float(raw_input(""))
return curreny, quantity
def welcome():
print("\n")
dramaticTyping("Simple Crypto Trading Simulator \n")
dramaticTyping("Hey Yo, you are back in time. It's Wednesday, March 7, 2018 7:39 AM \n")
dramaticTyping("Here are the crypto currencies you can invest. \n")
dramaticTyping("Fetching prices ... \n")
def welcome():
print("\n")
dramaticTyping("Simple Crypto Trading Simulator \n")
dramaticTyping("Hey Yo, you are back in time. It's Wednesday, March 7, 2018 7:39 AM \n")
dramaticTyping("Here are the crypto currencies you can invest. \n")
dramaticTyping("Fetching prices ... \n")
def welcome():
print("\n")
dramaticTyping("Simple Crypto Trading Simulator \n")
dramaticTyping("Hey Yo, you are back in time. It's Wednesday, March 7, 2018 7:39 AM \n")
dramaticTyping("Here are the crypto currencies you can invest. \n")
dramaticTyping("Fetching prices ... \n")
def inputBuy():
dramaticTyping("Select the crypto curreny you want to buy? \n")
curreny = raw_input("").upper()
dramaticTyping("That's great. How much quantity you want to buy? \n")
quantity = float(raw_input(""))
return curreny, quantity
def main():
welcome()
coins = fetchCoins()
currency, quantity = inputBuy()
try:
price = coins[currency]['price']
except Exception as e:
dramaticTyping("Invalid currency entered, please try again \n")
inputBuy()
runSimulation(coins[currency]['price'], quantity, currency)
quitMenu()
def runSimulation(boughtPrice, quantity, currency):
valueThen = boughtPrice * quantity
bestPrice, timestamp = fetchBestBidPriceFromDB(currency)
bestValue = bestPrice * quantity
priceDifference = (bestValue - valueThen)/float(valueThen) * 100
time = datetime.datetime.fromtimestamp(timestamp).strftime('%A, %B %-d, %Y %I:%M %p')
print("The best bid price for {} was ${} at {} \n".format(currency, bestPrice, time))
if priceDifference>0:
dramaticTyping("Your total asset value is ${}, it has increase by {}% \n".format(round(bestValue, 4), round(priceDifference,2)))
else:
dramaticTyping("Your total asset value is ${}, it has decreased by {} \n".format(round(bestValue, 4), round(priceDifference,2)))
def _excavate_asymmetric_friendships(self):
"""Recognizes cases where a character A considers another, B, to be a friend,
while B considers A to be an enemy.
"""
asymmetric_friendships = []
for person in self.simulation.town.residents:
for friend in person.friends:
if friend.dislikes(person):
asymmetric_friendships.append(AsymmetricFriendship(subjects=(person, friend)))
return asymmetric_friendships
def _excavate_business_owner_rivalries(self):
"""Recognize cases where mutual animosity exists between owners of rival businesses."""
business_owner_rivalries = []
for company in self.simulation.town.companies:
for rival_company in self.simulation.town.businesses_of_type(business_type=company.__class__.__name__):
if rival_company is not company and rival_company.owner and company.owner:
if not company.owner.person.likes(rival_company.owner.person):
if not rival_company.owner.person.likes(company.owner.person):
subjects = (company.owner.person, rival_company.owner.person)
if not any(br for br in self.business_owner_rivalries if set(br.subjects) == set(subjects)):
business_owner_rivalries.append(BusinessOwnerRivalry(subjects=subjects))
return business_owner_rivalries