Skip to content
TORNLIFE More

Stocks Spreadsheet

Started by Nobody [237547] on in API Development.

6 replies · 320 views · thread synced · 5 days ago · View on torn.com
About this thread

Posts archived: 7 / 7 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
7
Discussion span
→
People posting
6
Likes on archived posts
4
Authority score
52 / 100
Historical score
25 / 100
Story score
32 / 100
Engagement score
55 / 100
LouBaker [1162207]
each stock has its own ID

"1": { "name": "Torn City and Shanghai Banking Corporation",
"2": { "name": "Torn City Investment Banking",

and so on, i dont know the whole list

if you add the ID 2 to the API call https://api.torn.com/torn/2?selections=stocks&key=YOURKEY

will return 

"2": {
    "name": "Torn City Investment Banking",
    "acronym": "TCB",
    "director": "Mr. Paul Davies",
    "current_price": "509.871",
    "market_cap": 5094858501259,
    "total_shares": 9992446131,
    "available_shares": 810001573,
    "forecast": "Average",
    "demand": "Low",
    "benefit": {
       "requirement": 1500000,
       "description": "Entitled to receive improved interest rates"
     }

just collect info you need  here
Nobody [237547]
Thanks, I don't suppose you know how to isolate the stock price as well? Guessing "knowing how to collect the info I need" is a requirement?
Hamolicious [2232961]
Depending on what you're using, but when I was making my application, I just ran it trough a few "remove" methods and then I used a split method on the character "\" " and I got a very nice spread of each heading... If you want more info pm me and I can show you what I did.
shro [1332742]
I think it depends on which language you select. Here's an example in python 3.6



#!/usr/bin/env python
import argparse
import requests

parser = argparse.ArgumentParser(
description = 'Create a csv file of stocks symbol, forecast and current price'
)
parser.add_argument('api_key', help='The api key to use')
parser.add_argument('csv_file', help='The file to create with the csv contents')
args = parser.parse_args()

response = requests.get('https://api.torn.com/torn/?selections=stocks&key=' + args.api_key)
stocks = response.json()['stocks']

with open(args.csv_file, 'w') as f:
    f.write('{},{},{}n'.format("symbol","forecast","current price"))
    for stock in stocks.values():
        f.write('{},{},{}n'.format(stock['acronym'],stock['forecast'],stock['current_price']))


# edit -> fixed erroneous description about api key
jrm250 [1747448]
https://api.torn.com/torn/?selections=stocks&key=YOURKEY will give you the current stock prices and most of the data you need
I suggest also using
https://api.torn.com/user/?selections=stocks&key=YOURKEY will give you information about your currently owned stocks

I suggest looking going to https://www.torn.com/api.html# to see what kind of data you are able to pull out of Torn with an API Key.

Google will give users a pop up the first time saying that Torn is not a trusted site and they must click to approve/allow access if you use Google Sheets, at least it did for me.

I was looking for the same thing this morning and ended up creating a spreadsheet. I am planning to update it and make it more user friendly in the future. You can/should be able to view the code after you create a copy for help creating your own spreadsheet.

https://docs.google.com/spreadsheets/d/1pxVvyzvWmklsPI6RHH8BE2sYfAs1RtMwl5YXXaH29kc/edit?usp=sharing