eduardo-olivares1 / Narwhal

A discord bot designed to alert users of important cryptocurrency movements and events.
MIT License
2 stars 1 forks source link

Dummy Cryptocurrency Purchasing and Selling #16

Open eduardo-olivares1 opened 3 years ago

eduardo-olivares1 commented 3 years ago

It could be interesting to have users be able to buy and sell dummy cryptocurrency at prices pulled from CoinGecko's API at any point in time and have them able to view their theoretical profit and loss. This would allow people who are unsure about purchasing cryptocurrencies be able to experience the potential that some have to offer.

The Idea

This feature would consist of 3 commands:

This would most likely require some kind of storage and a good option may be SQLite

Buy

Users could be able to "purchase" a crytpocurrency with a command like:

$buy [coin] [optional_date_arg _in _UTC]

If the user does not input the optional date argument, then the coin is simply "purchased" at the current CoinGecko listed price.

The bot could then return a message to confirm the purchase:

[user] purchased [coin_amount] [coin] @ [price]

Sell

Users could also "sell" their cyrptocurrency holdings in exchange for fiat currency (USD default) with a command like:

$sell [coin] [optional_date_arg _in _UTC]

Portfolio

Users could be given the ability to see their "portfolio" and see their profit and loss for each transaction/currency with the command:

$portfolio [optional_coin_arg]

If the user inputs the optional coin arguement, then only the data for one coin would be displayed. The portfolio command with no additional arguments would simply return a table like so:

Coin Holdings Value PNL
ETH 1.6749 $700.23 +$125.77 ( +30.24%)
BTC 0.05472 $300.55 -$1.55 ( -0.55%)

How it would work

The process would work something like this

  1. Users would buy crypto currency with the aforementioned commands
  2. A transaction tied to the user (as a foreign key) would be added to a Transactions table in the database, where the transaction id, coin purchased (as a foreign key from a Coins table), amount purchased, and purchase price would be recorded.
  3. Transactions would then be summed up and placed into "wallets" for each coin in a Wallets table that are each tied to a user for each specific coin. Each user would be have a separate unique wallet for each coin they have purchased. (e.g User A would have an ETH wallet, DOT wallet, BTC wallet, ...etc all located in the Wallets table). The sum SQL statement could look something like this: SELECT SUM(amount) FROM Transactions WHERE coin_id="[coin_id]" AND user="[user_id]";
  4. Users can then add or subtract value from those wallets by further purchases or sales. And further simple arithmetic would be done to output the value of wallets and the profit and loss for each wallet.

image

Alackey commented 3 years ago

This looks like it would be pretty fun to use. Just some questions/comments.

  1. What is the date argument used for in the buy/sell command? Does it purchase the coin at a specific date?
  2. I think showing total market value/net liquid value in the portfolio table would be useful.
  3. PostgreSQL would probably be better instead of sqlite if you're going host it somewhere. Sqlite is easy if you're just going to be running it on your computer though.
  4. I think a way to view transactions would be cool to see
eduardo-olivares1 commented 3 years ago

Accidentally closed issue.

peterderdak commented 3 years ago

A great way for people who are on the sideline to get some exposure. It would be nice if long-term you could integrate some actual purchases based on trades they've made. Awesome proj!

eduardo-olivares1 commented 3 years ago

This looks like it would be pretty fun to use. Just some questions/comments.

  1. What is the date argument used for in the buy/sell command? Does it purchase the coin at a specific date?
  2. I think showing total market value/net liquid value in the portfolio table would be useful.
  3. PostgreSQL would probably be better instead of sqlite if you're going host it somewhere. Sqlite is easy if you're just going to be running it on your computer though.
  4. I think a way to view transactions would be cool to see

Hi @Alackey ,

  1. Yes it would use historical prices to "purchase" the coin amount
  2. That is a great idea, definitely something worth implementing
  3. I had not considered PostgreSQL but I will look into it! Thanks for the feedback!
  4. That is something I have been thinking about considering and honestly seems like something I should have considered to begin with. It will definitely be a feature in the project! (Just need to figure out how to paginate in discord)