Stock/Ticker symbol widget

Please do! This community is for sharing and learning together :grin:

Hey Noury, let me know if you are able to get it work, I'm still trying to make it work๐Ÿ˜…

@Robbie_Tumbas Where are you stuck?

I just can't get the widget to display the price. On the flip-side, I was able to write an apple script that opens RobinHood and yahoo finance from the press of a Touch Bar button๐Ÿ‘. I'm making progress!

1 Like

Can you share the text file with the data and your script so far?
I can see if I can help figure it out :grin:


here is what the code, text file and Automator workflow looks like, lmk what I am doing wrong!

AppleScript is a bit funny when it comes to words and paragraphs. Try word 2 of paragraph 6. Paragraph is more like line number.

hm ill have to play around with it a little more, still nothing

Give this a try:

set buyPrice to "FILL IN"

set stockData to "/Users/robbietumbas/Documents/stockBTT"

set currentPrice to word 3 of paragraph 7 of stockQuote


if currentPrice is less than buyPrice then
	return StockSymbol & "-   $" & text 1 thru -3 of currentPrice
	
else
	return StockSymbol & return & "$" & text 1 thru -3 of currentPrice
	
end if

ah this is driving me insane but I am sticking with it, when you run the script does the price show up in you're script results section ?

set stockData to "/Users/robbietumbas/Documents/stockBTT"
set previousDay to word 4 of paragraph 10 of (read stockData)
set currentPrice to word 3 of paragraph 7 of (read stockData)
if previousDay is greater than currentPrice then
set gainLoss to "-"
else
set gainLoss to ""
end if

return "AAPL" & return & "$" & text 1 thru -3 of currentPrice & gainLoss


is there something wrong with my the way I am entering it ?

Not that I am seeing. Trying to run the script in Script Editor. I tend to always write the scripts there then copy/paste into BTT as SC will return errors while BTT doesn't

YESSSSSSSSS!!!!!!!!!! Thank YOU!!!!! I had the location of the file wrong the whole timeโ€‹:man_facepalming::man_facepalming::man_facepalming:

1 Like

Woohoo! It's always something so simple, at least it usually is for me. Good luck with the rest of your TB set up

Yeah thank, you are the man !! now I need to have a secondary trigger run the automation right ?

You created an app with Automator to fetch the data?
Copy the below into TextEdit and change the path to your file then copy again and paste into Named Triggers. Hopefully this makes it a bit easier for you.

[
  {
    "BTTGestureNotes" : "Fetch Stock Data Every 5 Minutes",
    "BTTTriggerType" : 678,
    "BTTTriggerTypeDescription" : "Repeating or Time Based Trigger",
    "BTTTriggerClass" : "BTTTriggerTypeOtherTriggers",
    "BTTPredefinedActionType" : 49,
    "BTTPredefinedActionName" : "Launch Application \/ Open File \/ Start Apple Script โ€ฆ",
    "BTTLaunchPath" : "file:\/\/\/Users\/jeffreyrosenkrantz\/Library\/Workflows\/fetchStocks.app",
    "BTTAdditionalConfiguration" : "{\"BTTTimedWhenToTrigger\":0,\"BTTTimedRepeatEveryXSeconds\":\"240\"}",
    "BTTEnabled2" : 1,
    "BTTAlternateModifierKeys" : 0,
    "BTTRepeatDelay" : 0,
    "BTTUUID" : "2890329A-05F7-4C80-AD2E-1697016FB651",
    "BTTNotesInsteadOfDescription" : 1,
    "BTTEnabled" : 1,
    "BTTModifierMode" : 0,
    "BTTOrder" : 23,
    "BTTDisplayOrder" : 0,
    "BTTTriggerConfig" : {
      "BTTHUDText" : "Fetching Stock Data"
    }
  }
]

Hi! I'm trying to accomplish what you guys were working on. Where is the option to past this into "Named Triggers"? I don't have that on my menu.

It is under the menu to select your input source, Named and Other Triggers

Hi,

Like Jillian, I am also attempting to do this. I'm able to pull the data from alphavantage and have installed the presets you provided. I can't get any output from the script below. I assume it's cause I don't have the variables set, specifically stockData in the code below. Where do I set the variables that you have included in this script?

set stockData to "/Users/admin/Desktop/python/stocks/stocksData.txt"

set currentPrice to word 3 of paragraph 7 of (read stockData)


if currentPrice is less than BuyPrice then
	return StockSymbol & "-   $" & text 1 thru -3 of currentPrice
	
else
	return StockSymbol & return & "$" & text 1 thru -3 of currentPrice
	
end if

Also, I noticed you included a few different apple scripts that I listed below. How are you referencing each file exactly? Are you just including all of these apple scripts in one file? Thank you in advance. I can't wait to get this working

set stockData to "/Users/robbietumbas/Documents/stockBTT"
set previousDay to word 4 of paragraph 10 of (read stockData)
set currentPrice to word 3 of paragraph 7 of (read stockData)
if previousDay is greater than currentPrice then
set gainLoss to "-"
else
set gainLoss to ""
end if

return "AAPL" & return & "$" & text 1 thru -3 of currentPrice & gainLoss

set buyPrice to "FILL IN"

set stockData to "/Users/robbietumbas/Documents/stockBTT"

set currentPrice to word 3 of paragraph 7 of stockQuote


if currentPrice is less than buyPrice then
	return StockSymbol & "-   $" & text 1 thru -3 of currentPrice
	
else
	return StockSymbol & return & "$" & text 1 thru -3 of currentPrice
	
end if