python3: we are going to make a “baby” bitcoin program that lets us keep track of buying and selling bitcoin with a menu. We are going to assume that you each have $75,000 to invest. For this project, we assume you only are going to be dealing with one currency: bitcoin (BTC). Make a menu Design a text based menu or a string based menu. If you did a text based menu for the horse racing do a string based menu on this. A numeric/text based menu gives them choices (ie choose 1 to buy, 2 to sell, etc and they enter the choice they want as a number and you go on from there to get the additional information from them). A string basic menu is more like a sentence you type in. The user can ask for the current value of bitcoin (just use a default value initially of 60k, and once you get that working change it so that your Get Live class generates a random price for bitcoin (fluctuate 5K up or down from the 60K to simulate current market fluctuations). 1.price Most students make a pseudo random price for bitcoin (you generate40-50K generated randomly). They can buy bitcoin. buy 0.5 Would buy you half a bitcoin. Make sure they have enough money to buy what they want to buy. Another acceptable way you could do this would be to have them say buy 3000 Which would let them by 3K of bitcoin (so you get the current (pseudo) price and figure out how much they can buy for that price) They can sell bitcoin. sell 0.5 Would sell half a bitcoin. Make sure they have enough bitcoin in their wallet to sell what they want to sell. Another option would be to have them say sell 3000 Which would let them sell 3K worth of their bitcoin at the current price. They can print their balance (show their current USD, the number of bitcoins they have in their wallet, and USD value of the bitcoins they have) balance They can print the history of their buy and sell transactions out. This should have the time, which you can format however you want ie: bought 1 bitcoin on September 12, 2019. history There are functions available to get the current date and time. We will go over this. We will be using rand/random to generate a (fake) live value of bitcoin. Initially you can just use 60000 as the value when you first get started. We can use dictionary (Python) to store the command history and we will also cover making the classes for this in lecture Let’s say that you buy 1.5 bitcoin on September 15th at a market price of $10,000 per coin. Your cash balance would go down from 20K to 5K and the bitcoins in your wallet would go from none, up to 1.5. If you sold half a bitcoin for 6K dollars, your cash balance would go up to 11,000 and your number of bitcoins go down to 1.0. You might be wondering how often to update the price. You could update it every single time you start a transaction so every time you buy, sell etc you update the price., Alternatively and even easier idea is to only update it when they ask for the price. That would mean when they ask for the price you update the price and let them know, and then let the price stick until they ask for the price again. Make a Class called Wallet We need a class to store our imaginary coins in. Well, we can declare our own class, called Wallet, to help us get something done for this project. Our wallet class is going to help us store our information on a single cryptocurrency in this scenario. Hmm, if you were going to extend your program later you would have to decide if you would be able to store multiple different coin types in the wallet or if you were going to have multiple wallets for that situation. For our Wallet class, we need to store a few things 1) We need to store the ticker symbol for the coin 2) We need to store how many coins we currently have 3) We also need a “print” method in the class that will print the information out. So, this method will print out the ticker symbol (BTC) for the coin and the number of coins currently in the wallet. 4) We should also have an setter function to add coins to the wallet and a getter function to get the number of coins in the wallet. Make a Class called Ledger We need a class that is going to turn our transactions into a string and store them for our history. 1) It will store the transaction strings just so we have a record of the buy & sell commands 2) It will be able to print out the transaction history if requested We are going to use Dict (Python) for this. Make a Class called MyDate This class will call the library routines to get the current date. It will have a function in it that returns that date as a string. We need this for our transaction history Make a Class called GetLive This is going to fetch the current live value of bitcoin. (For now we fake it by generating a random number between 55l and 65k (or whatever makes sense when you get this assignment since bitcoin price is all over the place).
python3:
we are going to make a “baby” bitcoin program that lets us keep track of buying and selling bitcoin with a menu.
We are going to assume that you each have $75,000 to invest. For this project, we assume you only are going to be dealing with one currency: bitcoin (BTC).
Make a menu
Design a text based menu or a string based menu. If you did a text based menu for the horse racing do a string based menu on this. A numeric/text based menu gives them choices (ie choose 1 to buy, 2 to sell, etc and they enter the choice they want as a number and you go on from there to get the additional information from them). A string basic menu is more like a sentence you type in.
The user can ask for the current value of bitcoin (just use a default value initially of 60k, and once you get that working change it so that your Get Live class generates a random price for bitcoin (fluctuate 5K up or down from the 60K to simulate current market fluctuations).
1.price
Most students make a pseudo random price for bitcoin (you generate40-50K generated randomly).
- They can buy bitcoin.
buy 0.5
Would buy you half a bitcoin. Make sure they have enough money to buy what they want to buy. Another acceptable way you could do this would be to have them say
buy 3000
Which would let them by 3K of bitcoin (so you get the current (pseudo) price and figure out how much they can buy for that price)
- They can sell bitcoin.
sell 0.5
Would sell half a bitcoin. Make sure they have enough bitcoin in their wallet to sell what they want to sell. Another option would be to have them say
sell 3000
Which would let them sell 3K worth of their bitcoin at the current price.
- They can print their balance (show their current USD, the number of bitcoins they have in their wallet, and USD value of the bitcoins they have)
balance
- They can print the history of their buy and sell transactions out. This should have the time, which you can format however you want ie: bought 1 bitcoin on September 12, 2019.
history
There are functions available to get the current date and time. We will go over this. We will be using rand/random to generate a (fake) live value of bitcoin. Initially you can just use 60000 as the value when you first get started. We can use dictionary (Python) to store the command history and we will also cover making the classes for this in lecture
Let’s say that you buy 1.5 bitcoin on September 15th at a market price of $10,000 per coin. Your cash balance would go down from 20K to 5K and the bitcoins in your wallet would go from none, up to 1.5. If you sold half a bitcoin for 6K dollars, your cash balance would go up to 11,000 and your number of bitcoins go down to 1.0.
You might be wondering how often to update the price. You could update it every single time you start a transaction so every time you buy, sell etc you update the price., Alternatively and even easier idea is to only update it when they ask for the price. That would mean when they ask for the price you update the price and let them know, and then let the price stick until they ask for the price again.
Make a Class called Wallet
We need a class to store our imaginary coins in. Well, we can declare our own class, called Wallet, to help us get something done for this project. Our wallet class is going to help us store our information on a single cryptocurrency in this scenario. Hmm, if you were going to extend your program later you would have to decide if you would be able to store multiple different coin types in the wallet or if you were going to have multiple wallets for that situation.
For our Wallet class, we need to store a few things
1) We need to store the ticker symbol for the coin 2) We need to store how many coins we currently have 3) We also need a “print” method in the class that will print the information out. So, this method will print out the ticker symbol (BTC) for the coin and the number of coins currently in the wallet. 4) We should also have an setter function to add coins to the wallet and a getter function to get the number of coins in the wallet.
Make a Class called Ledger
We need a class that is going to turn our transactions into a string and store them for our history.
1) It will store the transaction strings just so we have a record of the buy & sell commands 2) It will be able to print out the transaction history if requested
We are going to use Dict (Python) for this.
Make a Class called MyDate
This class will call the library routines to get the current date. It will have a function in it that returns that date as a string. We need this for our transaction history
Make a Class called GetLive
This is going to fetch the current live value of bitcoin. (For now we fake it by generating a random number between 55l and 65k (or whatever makes sense when you get this assignment since bitcoin price is all over the place).
Trending now
This is a popular solution!
Step by step
Solved in 2 steps