Initial pass at Synth-based ticker selection #1392
Reference in New Issue
Block a user
Delete Branch "synth-selector"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@josefarias Sorry to keep pinging you about this but alas...
https://github.com/user-attachments/assets/cf2821e6-2c54-4954-aecf-c8f7d1beb7eb
Selecting the item from the dropdown is filling in the input with the full hash. Not sure how to address that.
What I'm ultimately trying to do is have the fancy dropdown and then have the value on selection be something like
AAPL (NYSE)(ticker + mic code).I'm almost certainly doing something very wrong here...I just don't know what...
@securitiesis an array of hashes...@zachgoll If you could review how I'm using the Providable stuff, that'd be great. It seems to work, but just not positive I'm using it as intended.
@@ -34,7 +34,10 @@ class Account::TradesController < ApplicationControllerendThe only change with the provider here is we'll need to set the key via
Setting.synth_api_key(as we're doing inProvidable) for self hosting to work.The diff below should make that work and the combobox display work (note: I renamed
_tickers.turbo_stream.erbto_security.turbo_stream.erb)@@ -34,7 +34,10 @@ class Account::TradesController < ApplicationControllerendAnd then this is the new
_security.turbo_stream.erb:Current status: combobox seems functional, however on form submission the "ticker" field is submitting "undefined".
@Shpigford ah, the state of the PR changed after I checked out the code. But the same ideas apply.
This is pretty custom usage, where you essentially have two displays — one for each option in the listbox (HTML) and another to display in the input when an option is selected (
"#{symbol} - #{name} (#{exchange_acronym})"). This is possible with HotwireCombobox but it'll require passing in an array of objects. This is working for me locally:Additionally, I'd suggest renaming
app/views/account/trades/_tickers.turbo_stream.erbtoapp/views/account/trades/_ticker.turbo_stream.erbto avoid further confusion, since the partial is rendered once for each ticker. If you do rename, you'll have to change all the references in the partial fromtickerstoticker.@josefarias Looks like @zachgoll's changes were on the right track (they're pushed to the PR now).
@josefarias Just merged yours and @zachgoll's solutions and it works beautifully. 🙂 Thanks a ton!
@@ -0,0 +1,20 @@class Security::SynthComboboxOptionI would
include Providablein this class and access Synth assecurity_prices_providerhere so this will work for self hosters who have Synth setup:Could we use something more like
"#{symbol}|#{exchange_mic}"here, and then in the controller, we don't need all the regular expressions? Then we'd just be able to do:Rather than:
I'm assuming no symbols/exchanges has the
|character in them... But maybe there is a better delimiter to use here