View this plugin on these servers
(PM me to have your server added here)
Features
- Add to your economy by allowing players to purchase virtual stocks based on the real world stock market. This plugin hooks into Yahoo Finance making it possible for players to buy virtual stocks of any company on a stock exchange that is listed on Yahoo Finance. (There may be a 15 minute delay on price updates, this is due to the nature of the YahooFinance API)
- Currency conversion, is a player buying a stock such as the Canadian Pizza Pizza Stock? Currency will be converted to USD from CAD before being charged from the player’s account based on real time exchange rates with forex backup support.
- After-hours trading, this plugin supports the latest real time rates including support for up to date after hours rates.
- Stock Broker NPCs, allows the spawning of NPCs that provide all command functionality through an interactive user interface.
- Stock information tool, allows users to quickly look up all statistics pertaining to a stock in game, including information such as: Company Name, Stock Exchange company is listed on, Current Price, Trading Currency, Stock Symbol, Day High, Day Low, Today’s Open Price, Volume, Previous Close Price, Year High and Year Low including historical information for the past year.
- Compare tools, allow users to compare a minimum of two and a maximum of three stocks at the same time side-by-side for the player to choose which stock is the best buy.
- Stock leaderboard, allows users to quickly view the top 54 stock market players sorted in descending order by portfolio value.
- Portfolio, stock and transactions tool, allows users to quickly view details on all their current stocks as well as transaction history which allows users to view all of their past transactions in addition to stock history which displays server wide transactions of a specific stock.
- Administrative tools, including a reload command allowing administrators to quickly reload the configuration file in game without needing to restart the server in addition to a purge command for quickly and easily wiping the MySQL tables.
- Fully customizable messages with variables and colour codes, all messages are defined in the config.yml file in addition to options of implementing items such as broker fees, including a percentage and a set rate.
- Developer API, documented below, allows for developers to hook into this plugin and retrieve data.
- Abuse prevention, toggle this setting on in the config, enforces a one day waiting period between selling a purchased stock. Used to prevent abuse in potential API delays.
- Chest Interface with multiple pages support, all data is displayed in chest interfaces to make it easy for the user to view the information they are looking for quickly and efficiently. All the data not fitting on one chest page? Multiple page support exists which will provide a way to view multiple pages of data.
- Efficient, MySQL/SQLite with use of a connection pool. Database querying and API lookup is done Async in order to ensure delays don’t stall the main server thread.
- Vault and Vault-compatible Economy Plugin
- Citizens (Optional, only needed if NPCs are enabled in the config)
- New York Stock Exchange
- NASDAQ
- Toronto Stock Exchange
** <> are required arguments, {} are optional arguments. **
/stock help - stockmarket.use
/stock tutorial - stockmarket.use
/stock lookup <SYMBOL> - Lookup a stock by symbol - stockmarket.lookup
/stock list - List 26 popular stocks, in addition to directing users to YahooFinance to view the thousands of other stocks supported by this plugin - stockmarket.use
/stock buy <symbol> <quantity> - Buy a stock - stockmarket.use
/stock sell <symbol> <quantity> - Sell a stock - stockmarket.use
/stock compare <SYMBOL1>,<SYMBOL2>,{SYMBOL3} - Compare a minimum of two stocks with a maximum of three - stockmarket.compare
/stock portfolio {player} - View a portfolio, no arguments would provide the executor’s portfolio, while providing an argument would provide the target player’s portfolio. - stockmarket.portfolio and stockmarket.portfolio.other
/stock cportfolio {player} - View a combined portfolio, a portfolio which shows all stocks of the same type combined in one, no arguments would provide the executor’s portfolio, while providing an argument would provide the target player’s portfolio. - stockmarket.portfolio and stockmarket.portfolio.other
/stock transactions {player} - View transaction history, no arguments would provide the executor's history, while providing an argument would provide the target player's history. stockmarket.transactions and stockmarket.transactions.other
/stock shistory <symbol> - View the transaction history of the specified stock - stockmarket.stockhistory
/stock leaderboard - View the top 45 players on the leaderboard, sorted by portfolio value. - stockmarket.leaderboard
/stock leaderboard profit - View the top 45 players on the leaderboard, sorted by profit margin. - stockmarket.leaderboard
Aliases for non-administrator commands: /stocks, /sm, /stockmarket
/sma reload - Reload the configuration file - stockmarket.admin
/sma broker - Spawn a Broker NPC, if enabled in the config file - stockmarket.admin
/sma broker simple - Spawn a simple Broker NPC, if brokers are enabled in the config file. - stockmarket.admin
/sma broker remove - Remove a Broker NPC by hitting them after executing this command, if you execute this command by mistake hit a block and it will disable itself - stockmarket.admin
stockmarket.nocommandbypass - Bypass for users if commands are disabled.
Code (Text):
database:
# Whether MySQL is enabled, setting this to false makes use of SQLite
# which requires no setup.
mysql-enabled: true
# MySQL server IP Address
ip: "localhost"
# MySQL server port
port: 3306
# MySQL database
database: "stockmarket"
# MySQL username
username: "root"
# MySQL password
password: "password"
options:
# Whether NPCs are enabled or not, if set to true Citizens is required.
npc-enabled: true
# Whether commands are enabled or disabled, useful if you want players to use broker NPCs only.
commands-disabled: true
# Account broker fees are paid to, should be one word. Set to "" to disable.
fees-account: ""
# Account stock purchases are paid to, should be one word. Set to "" to disable.
stock-account: ""
# Account stock sales are paid from, should be one word. Set to "" to disable.
stock-purchasing-account: ""
# Price multiplier, set to 0 to disable.
# Used if stock prices need to be inflated for your server economy (ex. 60
# dollar stock would become 600 with a 10 multiplier)
multiplier: 10
# Prevents users from buying stocks that don’t have a USD price
prevent-non-usd-sale: false
# Convert non-USD stocks to USD (ex. CAD, EUR, GBP would be
# converted to USD)
convert-non-usd-to-usd: true
# Prevents users from buying or selling stocks at a zero value (usually
# caused by some sort of error on YahooFinance’s end). This is STRONGLY
# recommended to remain at true, invalid stocks may also return a zero
# value.
prevent-sale-of-zero-value: true
# Prevents people from buying and selling within the specified number of
# seconds, this is to prevent user’s abusing the data delay by knowing
# what will happen to the price of a stock in critical scenarios
# (ex. a company’s profit earning announcements)
abuse-prevention: true
# The number of seconds abuse prevention should be enforced for
abuse-prevention-time: 3600
# Whether to enforce a minimum stock purchase price
penny-stock-check: true
# If penny-stock-check is true, penny-stock-minimum is the minimum
# price of a stock to allow it to be purchased.
penny-stock-minimum: 5
# If set to false, users will only be charged broker fees on stock purchases.
charge-broker-on-sale: true
# A flat rate added on to all transactions to simulate real broker fees. Set to
# 0 to disable.
broker-fee-flat: 10
# A percentage added on to stock value (base price * (purchasing/selling
# quantity) to simulate real broker fees. Set to 0 to disable.
broker-fee-percent: 0
# If true, players will not be able to buy or sell when the corresponding
# market in real life is closed.
disable-trading-when-closed: false
# If true, the simple broker inventory will close on purchase/sale
close-inventory-on-simple: false
messages:
# Used in certain scenarios, tell users to inform you if this message pops up
# as an error corresponds in the server log.
error-occured: "&4An error occurred, Yahoo Finance may be down."
# Used in case an error occurs with conversion, this will most likely and
# should never happen.
purchase-currency-not-supported: "&4The stock you are trying to buy has an unsupported original currency."
# Used when user tries to purchase a stock that is not of USD currency if it
# is toggled on under options
no-purchase-non-USD: "&4You can not purchase stocks which are not of USD currency."
# Used when user attempts to sell more of a stock than they own
no-stock-to-sell: "&4You can not sell <symbol> as you do not own enough of the stock."
# Used when a user tries to sell a stock they bought within 24 hours, used if
# abuse prevention is true
day-not-passed: "&4You can not sell &c<symbol> &4for another &c<hours> &4hours."
# Used when a user tries to purchase/sell a stock with a zero value, used if
# prevent zero value is true
invalid-price: "&4<symbol> &ccurrently has an invalid price and can not be bought/sold."
# Used when user tries to purchase more of a stock than the user can
# afford.
not-enough-money: "&4You can not afford <quantity> of <symbol> with a grand total of <total>."
# Used when a user purchases a stock, displays purchase summary
bought-stock:
- "&4Purchase Summary (<date>):"
- "&4You purchased &c<quantity> &4of &c<company> (<symbol>)"
- "&4Stock Value: &c<stock-value>"
- "&4Broker Fees: &c<broker-fees>"
- "&4Grand Total: &c<total>"
# Used when a user sells a stock, this portion is the header.
sold-stock:
- "&4Sale Summary:"
- "&4You sold &c<quantity> &4of &c<company> (<symbol>)"
# Used when a user sells a stock, this portion is the portion that will repeat
# depending on how many individual transactions of a stock are sold from.
stock-sold-report:
- "&4Stock ID: &c<stock-id> &4- Quantity: &c<quantity-of-stock>"
- " &4Stock Value: &c<stock-value> &4- Broker Fees: &c<broker-fees> &4- Total: &c<total>"
- " &4Purchased for: &c<purchase> &4- Net Gain/Loss: &c<net>"
# Footer of stock sale summary
stock-sold-footer: "&4Total Net: &c<total-net>"
# Used when a user specifies an invalid forex quote
invalid-forex-quote: "&4You specified an invalid Forex quote (Proper example: USDEUR)."
# Used when a user specifies an invalid quantity
invalid-quantity: "&4You specified an invalid quantity."
# Used when the user uses the compare command incorrectly.
improper-compare-syntax: "&cIncorrect syntax"
# Used when the user tries to use the compare command to compare only
# one stock.
compare-minimum-two: "&cYou need to compare at least two stocks."
# Used when the user tries to compare more than three stocks
compare-maximum-three: "&cYou can only compare three stocks at a time with the compare command."
# Used when the user specifies an invalid stock symbol.
invalid-stock: "&cThat stock could not be found."
# Used when the user uses a command incorrectly.
invalid-syntax: "&cYou did not use the proper command syntax."
# Used when the config is reloaded successfully.
config-reloaded: "&cSuccessfully reloaded configuration file."
# Used when the user attempts to use a command that he does not have
# permission for.
no-permission: "&cYou do not have permission to use that command."
# Used when the console is uses to execute a player only command.
you-need-to-be-a-player: "Stock Market - You need to be a player to use that command."
# Used when the portfolio is attempted to be opened for a player who has
# no portfolio stocks.
no-stocks-to-list: "&cThe specified player owns no stocks, portfolio not generated."
# Used when the history is attempted to be opened for a player who has
# no transaction history.
no-transactions-to-list: "&cThe specified player has no transactions, history not generated."
# Used when there are no players to list for the leaderboard.
no-stock-players: "&4There are no stock players, leaderboard not generated."
# Used when there are no transactions for a specified stock
no-stock-transactions-to-list: "&cThe specified stock has no transactions, history not generated."
# Used to broadcast when a player purchases a stock, set to "" to disable
stock-purchase-broadcast: "&4Stock Market &8>> &4<player> &chas purchased &4<quantity> &cof &4<symbol> &cfor a value of &4<purchase-value> &cwith applied broker fees of &4<broker-fees> &cfor a grand total of &4<grand-total>&c."
# Used to broadcast when a player sells a stock, set to "" to disable
stock-sale-broadcast: "&4Stock Market &8>> &4<player> &chas sold &4<quantity> &cof &4<symbol> &cfor a value of &4<purchase-value> &cwith applied broker fees of &4<broker-fees> &cfor a grand total of &4<grand-total> &c(Inital: &4<inital-value> &cNet: &4<net>&c)."
# Used when no historical data is found, usually for companies less than a
# year old.
no-historical-data: "&cNo historical data found, this is most likely caused by the company not have existing for the past year."
# Used when the player uses the help command.
help:
- "&cWe run a virtual stock market, for a list of stocks you can buy, visit YahooFinance."
- "&cStocks are a great way to earn money by investing in virtual stocks in companies you think will be sucessful on the stock market."
- "&cOur virtual broker will charge you <percent>% in addition to a flat rate of <flat-rate> on each transaction."
# Used when a stock broker is spawned
stock-broker-spawned: "&4Spawned stock broker."
# Used to let the user know what to do when they execute the remove command.
stock-broker-removal: "&4Hit the stock broker you would like to remove."
# Used when a stock broker is removed.
stock-broker-removed: "&4Stock broker removed."
# Used when a player has removal mode on and does not hit a Stock Broker NPC.
stock-broker-no-npc: "&4You did not hit a stock broker, removal mode disabled."
# Used when attempts are made to spawn or kill stock brokers when npcs are disabled in the config.
stock-brokers-disabled: "&4Stock Brokers are disabled in the config, command failed."
# Used when a player attempts to use a stock market command while commands are disabled.
stock-commands-disabled: "&4Stock Market commands are disabled, make use of our Stock Brokers!"
# Used to let the user know how to lookup symbols through the broker.
stock-broker-stock-symbol-lookup: "&4Chat disabled. &cEnter the stock symbol you want to lookup in chat (Example: AAPL)."
# Used to let the user know how to lookup forex stocks through the broker.
stock-broker-forex-symbol-lookup: "&4Chat disabled. &cEnter the forex symbol you want to lookup in chat (Example: EURUSD)."
# Used to let the user know how to use the compare command through the broker.
stock-broker-compare: "&4Chat disabled. &cEnter the symbols you want to compare in chat (Example: AAPL,GOOG,TSCO.L)."
# Used to let the user know how to use the portfolio command through the broker.
stock-broker-portfolio: "&4Chat disabled. &cEnter the player you want to view the portfolio of in chat."
# Used to let the user know how to use the stock history command through the broker.
stock-broker-stock-history: "&4Chat disabled. &cEnter the symbol you want to view the history of in chat (Example: AAPL)."
# Used to let the user know how to use the transaction history command through the broker.
stock-broker-transaction-history: "&4Chat disabled. &cEnter the player you want to view the transaction history of in chat."
# Used to let the user know how to use the buy command through the broker.
stock-broker-buy-stocks: "&4Chat disabled. &cEnter the symbol and the amount you would like to buy of the stock. (Example: AAPL 2)"
# Used to let the user know how to use the sell command through the broker.
stock-broker-sell-stocks: "&4Chat disabled. &cEnter the symbol and the amount you would like to sell of the stock. (Example: AAPL 2)"
# Used to let the user know when they provide incorrect arguments to the broker.
stock-broker-invalid-provided: "&4You provided invalid arguments to the stock broker."
# Used to let the user know when the stock market corresponding to the symbol they selected is closed.
no-trading-when-market-is-closed: "&4The stock market corresponding to the symbol you selected is closed, therefore you can not make any transactions with that symbol."
# Used when a user attempts to purchase a stock with a price that is below
# penny-stock-minimum when penny-stock-check is true.
penny-stock-minimum-not-met: "&4You can not buy that stock as it's price is too low."
Events
StockPurchaseEvent - Called when a stock is purchased.
- getPlayer() (Player) - Returns player who purchased the stock.
- getSymbol() (String) - Returns the stock symbol purchased.
- getQuantity() (Integer) - Returns the quantity purchased.
- getStockValue() (String) - Returns the stock value (current price * quantity) in a formatted string.
- getBrokerFees() (String) - Returns the broker fees applied in a formatted string.
- getGrandTotal() (String) - Returns the grand total in a formatted string.
StockSaleEvent - Called when a stock is sold
- getPlayer() (Player) - Returns player who sold the stock.
- getStockSymbol() (String) - Returns the stock symbol sold.
- getQuantity() (Integer) - Returns the quantity sold.
- getStockValue() (String) - Returns the stock value (current price * quantity) in a formatted string.
- getBrokerFees() (String) - Returns the broker fees applied in a formatted string.
- getGrandTotal() (String) - Returns the grand total in a formatted string.
- getInitialPurchase() (String) - Returns the initial purchase value in a formatted string.
- getNetOnTransaction() (String) - Returns the net on the sale in a formatted string.
This API is still very basic, the API will continue to grow as the plugin grows.
- getPortfolioValue (UUID playerUUID) - Returns the specified player's portfolio value in a formatted string. If player is not found, returns a portfolio value of 0.00.
- getProfitMargin (UUID playerUUID) - Returns the specified player's profit margin in a formatted string. If player is not found, returns a profit margin of 0.00.
- getSortedPortfolioValues() - Returns Map<UUID, Double> where UUID is the player UUID, and double is their portfolio value. The map is organized in descending order from largest to smallest.
1. Add the following to your plugin.yml
Code (Text):
depend: [StockMarket]
2. Use StockMarket API
Code (Java):
StockMarketAPI stockMarketAPI = StockMarket.getStockMarketAPI();
String formattedPortfolioValue = stockMarketAPI.getPortfolioValue(pUUID);
String formattedProfitMargin = stockMarketAPI.getProfitMargin(pUUID);
Map<UUID, Double> topMap = stockMarketAPI.getSortedPortfolioValues();
Reporting Bugs and making suggestions
If reporting a bug or making a suggestion, please do it via either a PM or in the discussion thread. If reporting a bug, please make sure to include your server version, plugin version, server log, in addition to the scenario which produced the bug (If for example was the lookup command, include which stock symbol produced it.)
Please do not leave negative reviews based on bugs, feel free to contact me and I will be more than happy to help you with your issues and push updates to resolve any bugs.
Terms of Service
By purchasing/using this plugin, you agree to the following.
- No refunds will be provided under any circumstance.
- Reviews must reflect your experience based on the plugin description, do not post a bad review because of an issue which you did not attempt to resolve with me first or because you believe this plugin needs an extra feature.