Skip to content

Commit bef34e1

Browse files
authored
Merge pull request #2 from gurpreetatwal/allow-multiple-tickers
feat: allow multiple customer tickers
2 parents 16c21f2 + a6e6df8 commit bef34e1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

polystock.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ def mostactive():
4040
output = str(day_active.at[0, 'Symbol']) + ': ' + str(round(si.get_live_price(day_active.at[0, 'Symbol']), roundNumber))
4141
return output
4242

43-
def customticker(ticker):
43+
def customticker(tickers):
4444
"""Returns: stock price and ticker of a stock with format 'TICKER': 'PRICE'.
4545
Parameter: the ticker to get a stock price on and to display.
46-
Precondition: ticker is a string."""
46+
Precondition: ticker is a string[]."""
4747

48-
tickerPrice = si.get_live_price(ticker)
49-
output = ticker + ': ' + str(round(tickerPrice, roundNumber))
50-
return output
48+
output = []
49+
for ticker in tickers:
50+
tickerPrice = si.get_live_price(ticker)
51+
output.append(ticker + ': ' + str(round(tickerPrice, roundNumber)))
52+
53+
return ' '.join(output)
5154

5255
def topcrypto():
5356
"""Returns: cryptocurrency with the highest price in a given day and its name
@@ -67,7 +70,7 @@ def addArguments():
6770
parser.add_argument('--biggestgainer', help='Prints the stock with the biggest gain in a given day.', action='store_true')
6871
parser.add_argument('--mostactive', help='Prints the most active stock in a given day.', action='store_true')
6972
parser.add_argument('--topcrypto', help='Prints the top cryptocurrency by market cap in a given day.', action='store_true')
70-
parser.add_argument('--customticker', help='Display the price of a custom ticker.', type=str)
73+
parser.add_argument('--customticker', action='append', help='Display the price of a custom ticker.', type=str)
7174

7275
args = parser.parse_args()
7376

0 commit comments

Comments
 (0)