Pixabay Image
Happy Friday everyone! I am on my stacking journey, and decided to let ChatGPT write me a Python Script to get the cheapest silver online. This was my first attempt at automation of purchases of silver bars and rounds. I plan on dollar cost averaging rounds and bars, and decided to set some cash aside for silver purchased when automation suggests it.
*Notice- the content below was generated by ChatGPT app on my Android phone on 11/8/2024:
import requests
from bs4 import BeautifulSoup
import pandas as pd
Define a function to get the silver price from JM Bullion
def get_jmbullion_price():
url = 'https://www.jmbullion.com/silver/bars/'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.content, 'html.parser')
# Find price from a typical element (this will change based on site layout)
price = soup.find('span', {'class': 'price-value'}).text.strip()
return float(price.replace('$', '').replace(',', ''))
Define a function to get the silver price from Apmex
def get_apmex_price():
url = 'https://www.apmex.com/category/37932/silver'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.content, 'html.parser')
# Look for price on the product page (this will change based on site layout)
price = soup.find('span', {'class': 'price'}).text.strip()
return float(price.replace('$', '').replace(',', ''))
Define a function to get the silver price from Kitco
def get_kitco_price():
url = 'https://www.kitco.com/charts/live_silver.html'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
# Extract the spot price (may vary depending on layout)
spot_price = soup.find('td', {'class': 'live_silver'}).text.strip()
return float(spot_price.replace('$', '').replace(',', ''))
Compare prices from different dealers
def compare_silver_prices():
prices = {
'JM Bullion': get_jmbullion_price(),
'Apmex': get_apmex_price(),
'Kitco': get_kitco_price(),
}
# Convert to DataFrame for easier analysis
price_df = pd.DataFrame(list(prices.items()), columns=['Dealer', 'Price'])
print("Silver Price Comparison (in USD per ounce):")
print(price_df)
# Find the cheapest price
cheapest_dealer = price_df.loc[price_df['Price'].idxmin()]
print(f"\nCheapest Silver: {cheapest_dealer['Dealer']} at ${cheapest_dealer['Price']:.2f} per ounce")
Main execution
if name == 'main':
compare_silver_prices()
Silver is retailing around $32 per ounce with some ebbs and flows we can attribute to post-election jitters. I am willing to pay 2-4% premiums over spot, and am not eager to buy 100 or 1,000 ounce bars. I decided to put this out there in hopes someone finds it useful.
A basic strategy of dollar cost averaging is easy to implement and involves buying silver or other assets at regular intervals. This can help smooth out returns and weather losses.
Workplace automation has helped me to make money faster for my employer using ChatGPT and other AI programs. I believe that AI is a big part of our future, and want to automate as much as I can. I want to compare prices between dealers online to find the best deals, and this looks promising. What do you think?
Let me know if this helps you. What platform would you put this script on to if you ant to maximize your yield?
Dis is awesome man! Haven't been buying silver recently, but sure some in our community that stack silver has some thoughts and may find this useful. !BBH !DIY !DOOK
You just got DOOKed!
@pepetoken thinks your content is the shit.
They have 1/400 DOOK left to drop today.
Learn all about this shit in the toilet paper! 💩
I am lost ain't that your secondary account ? !DOOK !BBH
We are different frogs. I live near South America where frogs are poisonous. Glad to be stacking again. Years ago I had a huge stack of silver and gold I needed to sell. Now I'm back at it again.
I hear you I was in a similar situation a few years back but I got back into stacking harder then ever !DOOK !BBH
You just got DOOKed!
@bitcoinman thinks your content is the shit.
They have 1/400 DOOK left to drop today.
Learn all about this shit in the toilet paper! 💩
@pepe.voter! @bitcoinman likes your content! so I just sent 1 BBH to your account on behalf of @bitcoinman. (1/50)
(html comment removed: )
No. Dat be sum other froggie man. !BBH !DIY !DOOK
You just got DOOKed!
@pepetoken thinks your content is the shit.
They have 4/400 DOOK left to drop today.
Learn all about this shit in the toilet paper! 💩
I see so he the cool frog that stacks 🤣 !DOOK !BBH
You just got DOOKed!
@bitcoinman thinks your content is the shit.
They have 3/400 DOOK left to drop today.
Learn all about this shit in the toilet paper! 💩
Yeah, sum froggie gots to do eet man. Mi just uncool. 🤣 !DOOK !BBH !DIY Although in the past I've had hundreds of silver rounds. Then I became nomadic and lightened my load.
You just got DOOKed!
@pepetoken thinks your content is the shit.
They have 17/400 DOOK left to drop today.
Learn all about this shit in the toilet paper! 💩
@bitcoinman! @pepetoken likes your content! so I just sent 1 BBH to your account on behalf of @pepetoken. (18/100)
(html comment removed: )
You can query your personal balance by
!DIYSTATS
@pepetoken! @bitcoinman likes your content! so I just sent 1 BBH to your account on behalf of @bitcoinman. (3/50)
(html comment removed: )
You just got DOOKed!
@bitcoinman thinks your content is the shit.
They have 2/400 DOOK left to drop today.
Learn all about this shit in the toilet paper! 💩
@bitcoinman! @pepetoken likes your content! so I just sent 1 BBH to your account on behalf of @pepetoken. (4/100)
(html comment removed: )
You can query your personal balance by
!DIYSTATS
@pepetoken! @bitcoinman likes your content! so I just sent 1 BBH to your account on behalf of @bitcoinman. (2/50)
(html comment removed: )
@pepe.voter! @pepetoken likes your content! so I just sent 1 BBH to your account on behalf of @pepetoken. (1/100)
(html comment removed: )
You can query your personal balance by
!DIYSTATS
Great job, @pepe.voter !
!LADY
View or trade
LOH
tokens.@silversaver888, you successfully shared 0.0100 LOH with @pepe.voter and you earned 0.0100 LOH as tips. (1/50 calls)
Use !LADY command to share LOH! More details available in this post.
Thanks! Appreciate it!
Does it work? What results came up?