2

We are trying to let NetLogo take the real time data, but we didn’t found any threads helpful online that tells how.

We used historical stock price data to train our agents in the first stage. After the end of the training phase, we would like to use real time data to test the strategies generated by agents. In order to do this, we will need NetLogo to take the real time data online. Is there a way to let NetLogo to read stock prices online, eg. Yahoo Finance, and run automatically?

Could you please give us some hints on how to implement this in NetLogo? If NetLogo is incapable of doing this. Can anyone suggest other agent-based modeling tools that can do this?

Thankssssss.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
randals
  • 70
  • 3

1 Answers1

2

You can use the NetLogo web extension to get real time information from any stock price API.

Looks like Yahoo has a pretty simple API.

To use their API to, for example, get Google's latest stock price, you'd do something like:

web:make-request "http://download.finance.yahoo.com/d/quotes.csv" "GET" [["s" "GOOG"] ["f" "l1"] ["e" ".csv"]]

Currently this gives me:

observer> show web:make-request "http://download.finance.yahoo.com/d/quotes.csv" "GET" [["s" "GOOG"] ["f" "l1"] ["e" ".csv"]]
observer: ["556.65" "HTTP/1.1 200 OK"]

That result is a list where the first element is the actual contents of the response (in this case, the price as a string) and the second is the whether or not the request was successful. 200 means it worked.

Bryan Head
  • 12,360
  • 5
  • 32
  • 50
  • Thanks. However, when i put the following code in the observer. web:make-request "http://download.finance.yahoo.com/d/quotes.csv" "GET" [["s" "GOOG"] ["f" "l1"] ["e" ".csv"]] Netlogo indicates this error: ERROR: Nothing named WEB:MAKE-REQUEST has been defined – randals Mar 11 '15 at 18:33
  • BTW, my netlogo is 5.1 – randals Mar 11 '15 at 18:35
  • Woops! You need to download the extension from here: http://ccl.northwestern.edu/devel/web-e1476d6f.zip – Bryan Head Mar 11 '15 at 18:43
  • Thanks so much. Another question is how to get netlogo to do this every 30 minutes? – randals Mar 11 '15 at 19:02
  • No problem. Would you mind opening a second question on that? – Bryan Head Mar 11 '15 at 19:12