{"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"-831:input_1","from_node_id":"-819:data_1"},{"to_node_id":"-843:input_1","from_node_id":"-831:data_1"},{"to_node_id":"-867:input_1","from_node_id":"-843:data_1"},{"to_node_id":"-879:input_1","from_node_id":"-843:data_1"},{"to_node_id":"-891:input_1","from_node_id":"-843:data_1"},{"to_node_id":"-903:input_1","from_node_id":"-843:data_1"}],"nodes":[{"node_id":"-819","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n import requests\n response = requests.post(\"https://www.f2pool.com/coins\", data={\"sort_by\": \"output24h\", \"sort_type\": \"desc\"})\n data = response.json()\n ds = DataSource.write_pickle(data)\n return Outputs(data_1=ds)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-819"},{"name":"input_2","node_id":"-819"},{"name":"input_3","node_id":"-819"}],"output_ports":[{"name":"data_1","node_id":"-819"},{"name":"data_2","node_id":"-819"},{"name":"data_3","node_id":"-819"}],"cacheable":true,"seq_num":1,"comment":"coins","comment_collapsed":false},{"node_id":"-831","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n # date 没有实际使用,更新这个值缓存可以更新\n def fetch_coin_data(currency_code, date=None):\n import requests\n response = requests.post(\n \"https://www.f2pool.com/coins-chart\",\n data={\"currency_code\": currency_code, \"history_days\": \"30d\", \"interval\": \"60m\"}\n )\n try:\n data = response.json()\n df = pd.DataFrame(data[\"data\"][\"chart_data\"])\n df[\"timestamp\"] = pd.to_datetime(df['timestamp'], unit=\"ms\")\n ds = DataSource.write_df(df)\n except Exception as e:\n T.log.exception(e)\n ds = None\n return Outputs(data=ds)\n\n coins = input_1.read()\n i = 0\n for coin in coins[\"data\"][\"top100\"]:\n i += 1\n T.log.info(f'fetch {i}/{len(coins[\"data\"][\"top100\"])} {coin[\"code\"]} ..')\n coin[\"data_ds\"] = M.cached.v3(\n run=fetch_coin_data,\n params={\"currency_code\": coin[\"code\"], \"date\": \"2021-08-17\"}\n ).data\n\n data = DataSource.write_pickle(coins)\n\n return Outputs(data_1=data)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-831"},{"name":"input_2","node_id":"-831"},{"name":"input_3","node_id":"-831"}],"output_ports":[{"name":"data_1","node_id":"-831"},{"name":"data_2","node_id":"-831"},{"name":"data_3","node_id":"-831"}],"cacheable":true,"seq_num":2,"comment":"获取算力和价格数据","comment_collapsed":false},{"node_id":"-843","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n data = input_1.read()\n if 'all_df' in data[\"data\"]:\n del data[\"data\"][\"all_df\"]\n N_START = 0\n N_END = 10\n T.log.warn(f\"处理数据范围 [{N_START}, {N_END})\")\n for i, coin in enumerate(data[\"data\"][\"top100\"][N_START:N_END]):\n T.log.info(f'process data {i+1}/{len(data[\"data\"][\"top100\"])} {coin[\"code\"]}')\n if \"data_ds\" not in coin:\n continue\n df = coin[\"data_ds\"].read()\n df.set_index(\"timestamp\", inplace=True)\n df[\"price_0\"] = df[\"price\"] / df[\"price\"].iloc[0]\n df[\"hashrate_0\"] = df[\"hashrate\"] / df[\"hashrate\"].iloc[0]\n df[\"price_per_hashrate\"] = df[\"price_0\"] / df[\"hashrate_0\"]\n\n # 处理异常数据\n if df[\"hashrate_0\"].max() > 10:\n T.log.warn(f'{coin[\"code\"]}, 异常数据, hashrate_0.max() is {df[\"hashrate_0\"].max()}')\n continue\n\n df.columns = coin[\"code\"] + \"_\" + df.columns\n # coin[\"data_df\"] = df\n if \"all_df\" not in data[\"data\"]:\n data[\"data\"][\"all_df\"] = df\n else:\n data[\"data\"][\"all_df\"][df.columns] = df\n return Outputs(data_1=data)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-843"},{"name":"input_2","node_id":"-843"},{"name":"input_3","node_id":"-843"}],"output_ports":[{"name":"data_1","node_id":"-843"},{"name":"data_2","node_id":"-843"},{"name":"data_3","node_id":"-843"}],"cacheable":false,"seq_num":3,"comment":"数据预处理","comment_collapsed":false},{"node_id":"-867","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n plot_options = {\n \"chart\": {\n \"height\": 800,\n },\n \"plotOptions\": {\n \"series\": {\n # \"compare\": 'percent',\n # \"showInNavigator\": True\n }\n }\n }\n T.plot(\n input_1[\"data\"][\"all_df\"],\n title=\"算力\",\n y=[c for c in data[\"data\"][\"all_df\"].columns if c.endswith(\"hashrate_0\")], # [\"price_0\", \"hashrate_0\", \"price_per_hashrate\"],\n options=plot_options\n )\n\n return Outputs()\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-867"},{"name":"input_2","node_id":"-867"},{"name":"input_3","node_id":"-867"}],"output_ports":[{"name":"data_1","node_id":"-867"},{"name":"data_2","node_id":"-867"},{"name":"data_3","node_id":"-867"}],"cacheable":false,"seq_num":5,"comment":"算力趋势","comment_collapsed":false},{"node_id":"-879","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n plot_options = {\n \"chart\": {\n \"height\": 800,\n },\n \"plotOptions\": {\n \"series\": {\n # \"compare\": 'percent',\n # \"showInNavigator\": True\n }\n }\n }\n T.plot(\n input_1[\"data\"][\"all_df\"],\n title=\"价格\",\n y=[c for c in data[\"data\"][\"all_df\"].columns if c.endswith(\"price_0\")], # [\"price_0\", \"hashrate_0\", \"price_per_hashrate\"],\n options=plot_options\n )\n\n return Outputs()\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-879"},{"name":"input_2","node_id":"-879"},{"name":"input_3","node_id":"-879"}],"output_ports":[{"name":"data_1","node_id":"-879"},{"name":"data_2","node_id":"-879"},{"name":"data_3","node_id":"-879"}],"cacheable":false,"seq_num":4,"comment":"价格趋势","comment_collapsed":false},{"node_id":"-891","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n plot_options = {\n \"chart\": {\n \"height\": 800,\n },\n \"plotOptions\": {\n \"series\": {\n # \"compare\": 'percent',\n # \"showInNavigator\": True\n }\n }\n }\n T.plot(\n input_1[\"data\"][\"all_df\"],\n title=\"价格/算力\",\n y=[c for c in data[\"data\"][\"all_df\"].columns if c.endswith(\"price_per_hashrate\")], # [\"price_0\", \"hashrate_0\", \"price_per_hashrate\"],\n options=plot_options\n )\n\n return Outputs()\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-891"},{"name":"input_2","node_id":"-891"},{"name":"input_3","node_id":"-891"}],"output_ports":[{"name":"data_1","node_id":"-891"},{"name":"data_2","node_id":"-891"},{"name":"data_3","node_id":"-891"}],"cacheable":false,"seq_num":6,"comment":"价格/算力趋势","comment_collapsed":false},{"node_id":"-903","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"def bigquant_run(input_1, input_2, input_3):\n plot_options = {\n \"chart\": {\n \"height\": 800,\n },\n \"plotOptions\": {\n \"series\": {\n # \"compare\": 'percent',\n # \"showInNavigator\": True\n }\n }\n }\n T.plot(\n input_1[\"data\"][\"all_df\"],\n title=\"价格 vs 算力\",\n y=[c for c in data[\"data\"][\"all_df\"].columns if c.endswith(\"_0\")], # [\"price_0\", \"hashrate_0\", \"price_per_hashrate\"],\n options=plot_options\n )\n\n return Outputs()\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-903"},{"name":"input_2","node_id":"-903"},{"name":"input_3","node_id":"-903"}],"output_ports":[{"name":"data_1","node_id":"-903"},{"name":"data_2","node_id":"-903"},{"name":"data_3","node_id":"-903"}],"cacheable":false,"seq_num":7,"comment":"价格趋势","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-819' Position='282.9435729980469,133.19387817382812,200,200'/><node_position Node='-831' Position='328.4577941894531,251.87100219726562,200,200'/><node_position Node='-843' Position='354.33740234375,375.15191650390625,200,200'/><node_position Node='-867' Position='163.17971801757812,527.8353576660156,200,200'/><node_position Node='-879' Position='474.4544677734375,526.5917053222656,200,200'/><node_position Node='-891' Position='791.468505859375,526.9677429199219,200,200'/><node_position Node='-903' Position='540.3040771484375,679.6363830566406,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
[2021-08-17 12:04:15.312180] INFO: moduleinvoker: cached.v3 开始运行..
[2021-08-17 12:04:15.319297] INFO: moduleinvoker: 命中缓存
[2021-08-17 12:04:15.320792] INFO: moduleinvoker: cached.v3 运行完成[0.008633s].
[2021-08-17 12:04:15.325249] INFO: moduleinvoker: cached.v3 开始运行..
[2021-08-17 12:04:15.330352] INFO: moduleinvoker: 命中缓存
[2021-08-17 12:04:15.331519] INFO: moduleinvoker: cached.v3 运行完成[0.006274s].
[2021-08-17 12:04:15.334235] INFO: moduleinvoker: cached.v3 开始运行..
[2021-08-17 12:04:15.342689] WARNING: AI: 处理数据范围 [0, 10)
[2021-08-17 12:04:15.343672] INFO: AI: process data 1/100 btc
[2021-08-17 12:04:15.373167] INFO: AI: process data 2/100 eth
[2021-08-17 12:04:15.422784] INFO: AI: process data 3/100 doge
[2021-08-17 12:04:15.461271] INFO: AI: process data 4/100 ltc
[2021-08-17 12:04:15.511749] INFO: AI: process data 5/100 etc
[2021-08-17 12:04:15.562140] INFO: AI: process data 6/100 rvn
[2021-08-17 12:04:15.610370] INFO: AI: process data 7/100 bch
[2021-08-17 12:04:15.651154] INFO: AI: process data 8/100 zec
[2021-08-17 12:04:15.708801] INFO: AI: process data 9/100 dcr
[2021-08-17 12:04:15.744088] INFO: AI: process data 10/100 xmr
[2021-08-17 12:04:15.798528] INFO: moduleinvoker: cached.v3 运行完成[0.464263s].
[2021-08-17 12:04:15.804474] INFO: moduleinvoker: cached.v3 开始运行..
[2021-08-17 12:04:15.852458] INFO: moduleinvoker: cached.v3 运行完成[0.047987s].
[2021-08-17 12:04:15.855770] INFO: moduleinvoker: cached.v3 开始运行..
[2021-08-17 12:04:15.910140] INFO: moduleinvoker: cached.v3 运行完成[0.054342s].
[2021-08-17 12:04:15.915155] INFO: moduleinvoker: cached.v3 开始运行..
[2021-08-17 12:04:15.955579] INFO: moduleinvoker: cached.v3 运行完成[0.040419s].
[2021-08-17 12:04:15.959225] INFO: moduleinvoker: cached.v3 开始运行..
[2021-08-17 12:04:16.030922] INFO: moduleinvoker: cached.v3 运行完成[0.071685s].