所以我有几个亚洲和加拿大指数的选择,具有正确的价值(我从enter link description here取得
,像这样:
to setup
clear-all
setup-turtles
reset-ticks
ask turtles [ set size 1 ]
end
to setup-turtles
create-threads 1
ask turtles [
setxy random-xcor random-ycor
set shape "line"
set color 65
]
end
turtles-own [age]
to go
add-age
divide
branch
transform
tick
ask turtles [ set size 1 ]
end
breed [threads thread]
breed [cylinders cylinder]
breed [circles circle]
to add-age
ask turtles [
set age age + 1
ifelse show-age?
[ set label age ]
[ set label "" ]
]
end
to divide
ask turtles [
if breed = threads or breed = cylinders [
ifelse random 100 < 50
[if (not any? other turtles-on patch-ahead 1) and
(not any? other turtles-on patch-right-and-ahead 10 1) and
(not any? other turtles-on patch-left-and-ahead 10 1)
[hatch 1
[let turn-degree (random(20) - 10)
rt turn-degree
fd 1
set age age - 1
]
]
]
[if (not any? other turtles-on patch-right-and-ahead 180 1) and
(not any? other turtles-on patch-right-and-ahead 170 1) and
(not any? other turtles-on patch-right-and-ahead 190 1)
[hatch 1
[let turn-degree (170 + random(20))
rt turn-degree
fd 1
set age age - 1
]
]
]
]]
end
to branch
ask circles [
if random 1000 < 2[
ifelse random 100 < 50
[if not any? other turtles-on patch-right-and-ahead 90 1
[hatch-threads 1
[right 90
fd 1
set age 0
set shape "line"]
]
]
[if not any? other turtles-on patch-left-and-ahead 90 1
[hatch-threads 1
[left 90
fd 1
set age 0
set shape "line"]
]
]
]]
end
to transform
ask threads[
if (age > 50) and (random 100 < 50)[
set breed cylinders
set shape "cylinder1"
]
]
ask cylinders[
if (age > 100) and (random 100 < 50) [
set breed circles
set shape "circle"
]
]
end
所以我使用这个library并使用以下方法获取数据:
<select name="symbols[]">
<option label="Straits Times" value="^STI">Straits Times</option>
</select>
我得到一个数组,其中包含我选择的值,但它不包含有关这些值的信息:
function getYahooIndexes($params)
{
$query = new YahooFinanceQuery;
$symbol = $params["symbols"];
$data = $query->indexList($symbol)->get();
return $data;
}
我使用了他建议的方法:
["data"]=>
array(5) {
[0]=>
object(stdClass)#234 (2) {
["symbol"]=>
string(7) "^GSPTSE"
["components"]=>
array(0) {
}
}
[1]=>
object(stdClass)#240 (2) {
["symbol"]=>
string(8) "CADUSD=X"
["components"]=>
array(0) {
}
在源代码中,indexList方法如下所示:
indexList(array $symbol)
Query for an index which returns the symbol and name of the components. Several symbols may be passed as an array.
See http://finance.yahoo.com/intlindices?e=europe for more symbols to world indices. The caret ^ character must be part of the symbol.
$symbol = array('^GDAXI');
$data = $query->indexList($symbol)->get();
我是后端开发的初学者,所以如果我没有解释得太好,我很抱歉,我会尽力向您提供您需要的详细信息。提前感谢您的帮助!