unageanu-jiji 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (564) hide show
  1. data/ChangeLog +0 -0
  2. data/README +0 -0
  3. data/bin/jiji.rb +6 -0
  4. data/html/css/calendar.css +432 -0
  5. data/html/css/datatable.css +299 -0
  6. data/html/css/default.css +557 -0
  7. data/html/css/dialog.css +77 -0
  8. data/html/img/auto_trade_off.gif +0 -0
  9. data/html/img/auto_trade_on.gif +0 -0
  10. data/html/img/back_bottom.gif +0 -0
  11. data/html/img/back_middle.gif +0 -0
  12. data/html/img/back_top.gif +0 -0
  13. data/html/img/bt-create-title-1.gif +0 -0
  14. data/html/img/bt-create-title-2.gif +0 -0
  15. data/html/img/bt-create-title-3.gif +0 -0
  16. data/html/img/button_add.gif +0 -0
  17. data/html/img/button_add_gray.gif +0 -0
  18. data/html/img/button_add_over.gif +0 -0
  19. data/html/img/button_apply.gif +0 -0
  20. data/html/img/button_apply_gray.gif +0 -0
  21. data/html/img/button_apply_over.gif +0 -0
  22. data/html/img/button_calendar.gif +0 -0
  23. data/html/img/button_calendar_over.gif +0 -0
  24. data/html/img/button_cancel.gif +0 -0
  25. data/html/img/button_cancel.jpg +0 -0
  26. data/html/img/button_cancel_gray.gif +0 -0
  27. data/html/img/button_cancel_over.gif +0 -0
  28. data/html/img/button_cancel_over.jpg +0 -0
  29. data/html/img/button_close.gif +0 -0
  30. data/html/img/button_close_gray.gif +0 -0
  31. data/html/img/button_close_over.gif +0 -0
  32. data/html/img/button_ok.gif +0 -0
  33. data/html/img/button_ok_gray.gif +0 -0
  34. data/html/img/button_ok_over.gif +0 -0
  35. data/html/img/button_remove.gif +0 -0
  36. data/html/img/button_remove_gray.gif +0 -0
  37. data/html/img/button_remove_over.gif +0 -0
  38. data/html/img/button_start.gif +0 -0
  39. data/html/img/button_start_over.gif +0 -0
  40. data/html/img/button_update.gif +0 -0
  41. data/html/img/button_update_gray.gif +0 -0
  42. data/html/img/button_update_over.gif +0 -0
  43. data/html/img/circle.gif +0 -0
  44. data/html/img/delta.gif +0 -0
  45. data/html/img/dialog_info.jpg +0 -0
  46. data/html/img/dialog_input.jpg +0 -0
  47. data/html/img/dialog_warn.jpg +0 -0
  48. data/html/img/dt-arrow-dn.png +0 -0
  49. data/html/img/dt-arrow-up.png +0 -0
  50. data/html/img/foot.jpg +0 -0
  51. data/html/img/h3_bt-create_0.gif +0 -0
  52. data/html/img/h3_bt-create_1.gif +0 -0
  53. data/html/img/h3_bt-create_2.gif +0 -0
  54. data/html/img/h3_result_0.gif +0 -0
  55. data/html/img/h3_result_1.gif +0 -0
  56. data/html/img/h3_result_2.gif +0 -0
  57. data/html/img/h3_result_3.gif +0 -0
  58. data/html/img/h3_result_4.gif +0 -0
  59. data/html/img/h3_result_5.gif +0 -0
  60. data/html/img/h3_result_6.gif +0 -0
  61. data/html/img/h3_rt-setting_0.gif +0 -0
  62. data/html/img/h3_rt-setting_1.gif +0 -0
  63. data/html/img/head.jpg +0 -0
  64. data/html/img/line_white.gif +0 -0
  65. data/html/img/loading.gif +0 -0
  66. data/html/img/panel_100_bottom.gif +0 -0
  67. data/html/img/panel_100_middle.gif +0 -0
  68. data/html/img/panel_100_top.gif +0 -0
  69. data/html/img/panel_140_650_b.gif +0 -0
  70. data/html/img/panel_140_650_m.gif +0 -0
  71. data/html/img/panel_140_650_t.gif +0 -0
  72. data/html/img/panel_140_660_b.gif +0 -0
  73. data/html/img/panel_140_660_m.gif +0 -0
  74. data/html/img/panel_140_660_t.gif +0 -0
  75. data/html/img/panel_140_b.gif +0 -0
  76. data/html/img/panel_140_m.gif +0 -0
  77. data/html/img/panel_140_t.gif +0 -0
  78. data/html/img/panel_260_b.gif +0 -0
  79. data/html/img/panel_260_m.gif +0 -0
  80. data/html/img/panel_260_t.gif +0 -0
  81. data/html/img/panel_300_b.gif +0 -0
  82. data/html/img/panel_300_m.gif +0 -0
  83. data/html/img/panel_300_t.gif +0 -0
  84. data/html/img/panel_320_b.gif +0 -0
  85. data/html/img/panel_320_m.gif +0 -0
  86. data/html/img/panel_320_t.gif +0 -0
  87. data/html/img/panel_360_b.gif +0 -0
  88. data/html/img/panel_360_m.gif +0 -0
  89. data/html/img/panel_360_t.gif +0 -0
  90. data/html/img/panel_380_b.gif +0 -0
  91. data/html/img/panel_380_m.gif +0 -0
  92. data/html/img/panel_380_t.gif +0 -0
  93. data/html/img/panel_500_b.gif +0 -0
  94. data/html/img/panel_500_m.gif +0 -0
  95. data/html/img/panel_500_t.gif +0 -0
  96. data/html/img/panel_620_b.gif +0 -0
  97. data/html/img/panel_620_m.gif +0 -0
  98. data/html/img/panel_620_t.gif +0 -0
  99. data/html/img/panel_780_b.gif +0 -0
  100. data/html/img/panel_780_m.gif +0 -0
  101. data/html/img/panel_780_t.gif +0 -0
  102. data/html/img/problem.gif +0 -0
  103. data/html/img/progressbar.gif +0 -0
  104. data/html/img/result-title-1-1.gif +0 -0
  105. data/html/img/result-title-1-2.gif +0 -0
  106. data/html/img/result-title-2-1.gif +0 -0
  107. data/html/img/result-title-2-2.gif +0 -0
  108. data/html/img/result-title-3-1.gif +0 -0
  109. data/html/img/result-title-4-1.gif +0 -0
  110. data/html/img/rt-setting-title-1.gif +0 -0
  111. data/html/img/rt-setting-title-2.gif +0 -0
  112. data/html/img/s.gif +0 -0
  113. data/html/img/scroll.gif +0 -0
  114. data/html/img/separator.gif +0 -0
  115. data/html/img/sidebar_agent.png +0 -0
  116. data/html/img/sidebar_agent_edit.png +0 -0
  117. data/html/img/sidebar_agent_edit_agent.png +0 -0
  118. data/html/img/sidebar_agent_edit_agent_over.png +0 -0
  119. data/html/img/sidebar_agent_edit_agent_s.png +0 -0
  120. data/html/img/sidebar_agent_edit_over.png +0 -0
  121. data/html/img/sidebar_agent_edit_s.png +0 -0
  122. data/html/img/sidebar_agent_edit_shared_lib.png +0 -0
  123. data/html/img/sidebar_agent_edit_shared_lib_over.png +0 -0
  124. data/html/img/sidebar_agent_edit_shared_lib_s.png +0 -0
  125. data/html/img/sidebar_back.gif +0 -0
  126. data/html/img/sidebar_bt.png +0 -0
  127. data/html/img/sidebar_bt_create.png +0 -0
  128. data/html/img/sidebar_bt_create_over.png +0 -0
  129. data/html/img/sidebar_bt_create_s.png +0 -0
  130. data/html/img/sidebar_bt_result.png +0 -0
  131. data/html/img/sidebar_bt_result_over.png +0 -0
  132. data/html/img/sidebar_bt_result_s.png +0 -0
  133. data/html/img/sidebar_result_rmt.png +0 -0
  134. data/html/img/sidebar_result_rmt_over.png +0 -0
  135. data/html/img/sidebar_result_rmt_s.png +0 -0
  136. data/html/img/sidebar_rt.png +0 -0
  137. data/html/img/sidebar_rt_setting.png +0 -0
  138. data/html/img/sidebar_rt_setting_over.png +0 -0
  139. data/html/img/sidebar_rt_setting_s.png +0 -0
  140. data/html/img/sprite.png +0 -0
  141. data/html/img/submenu_agents.png +0 -0
  142. data/html/img/submenu_agents_over.png +0 -0
  143. data/html/img/submenu_agents_s.png +0 -0
  144. data/html/img/submenu_graph.png +0 -0
  145. data/html/img/submenu_graph_over.png +0 -0
  146. data/html/img/submenu_graph_s.png +0 -0
  147. data/html/img/submenu_info.png +0 -0
  148. data/html/img/submenu_info_over.png +0 -0
  149. data/html/img/submenu_info_s.png +0 -0
  150. data/html/img/submenu_log.png +0 -0
  151. data/html/img/submenu_log_over.png +0 -0
  152. data/html/img/submenu_log_s.png +0 -0
  153. data/html/img/submenu_operation.png +0 -0
  154. data/html/img/submenu_operation_over.png +0 -0
  155. data/html/img/submenu_operation_s.png +0 -0
  156. data/html/img/submenu_trade.png +0 -0
  157. data/html/img/submenu_trade_over.png +0 -0
  158. data/html/img/submenu_trade_s.png +0 -0
  159. data/html/img/td_over.gif +0 -0
  160. data/html/img/td_over_d.gif +0 -0
  161. data/html/img/td_selected.gif +0 -0
  162. data/html/img/thead.gif +0 -0
  163. data/html/img/transparent.gif +0 -0
  164. data/html/index.html +480 -0
  165. data/html/js/W3CDTF.js +131 -0
  166. data/html/js/agent-editor-page.js +350 -0
  167. data/html/js/agent-selector.js +642 -0
  168. data/html/js/app.js +226 -0
  169. data/html/js/bt-create-page.js +186 -0
  170. data/html/js/codepress/codepress.css +21 -0
  171. data/html/js/codepress/codepress.html +35 -0
  172. data/html/js/codepress/codepress.js +138 -0
  173. data/html/js/codepress/engines/gecko.js +293 -0
  174. data/html/js/codepress/engines/khtml.js +0 -0
  175. data/html/js/codepress/engines/msie.js +304 -0
  176. data/html/js/codepress/engines/older.js +0 -0
  177. data/html/js/codepress/engines/opera.js +260 -0
  178. data/html/js/codepress/images/line-numbers.gif +0 -0
  179. data/html/js/codepress/images/line-numbers.png +0 -0
  180. data/html/js/codepress/index.html +443 -0
  181. data/html/js/codepress/languages/asp.css +71 -0
  182. data/html/js/codepress/languages/asp.js +117 -0
  183. data/html/js/codepress/languages/autoit.css +13 -0
  184. data/html/js/codepress/languages/autoit.js +32 -0
  185. data/html/js/codepress/languages/csharp.css +9 -0
  186. data/html/js/codepress/languages/csharp.js +25 -0
  187. data/html/js/codepress/languages/css.css +10 -0
  188. data/html/js/codepress/languages/css.js +23 -0
  189. data/html/js/codepress/languages/generic.css +9 -0
  190. data/html/js/codepress/languages/generic.js +25 -0
  191. data/html/js/codepress/languages/html.css +13 -0
  192. data/html/js/codepress/languages/html.js +59 -0
  193. data/html/js/codepress/languages/java.css +7 -0
  194. data/html/js/codepress/languages/java.js +24 -0
  195. data/html/js/codepress/languages/javascript.css +8 -0
  196. data/html/js/codepress/languages/javascript.js +30 -0
  197. data/html/js/codepress/languages/perl.css +11 -0
  198. data/html/js/codepress/languages/perl.js +27 -0
  199. data/html/js/codepress/languages/php.css +12 -0
  200. data/html/js/codepress/languages/php.js +61 -0
  201. data/html/js/codepress/languages/ruby.css +10 -0
  202. data/html/js/codepress/languages/ruby.js +26 -0
  203. data/html/js/codepress/languages/sql.css +10 -0
  204. data/html/js/codepress/languages/sql.js +30 -0
  205. data/html/js/codepress/languages/text.css +5 -0
  206. data/html/js/codepress/languages/text.js +9 -0
  207. data/html/js/codepress/languages/vbscript.css +71 -0
  208. data/html/js/codepress/languages/vbscript.js +117 -0
  209. data/html/js/codepress/languages/xsl.css +15 -0
  210. data/html/js/codepress/languages/xsl.js +103 -0
  211. data/html/js/codepress/license.txt +458 -0
  212. data/html/js/container-min.js +1 -0
  213. data/html/js/container-utils.js +78 -0
  214. data/html/js/dialog.js +270 -0
  215. data/html/js/edit_area/autocompletion.js +493 -0
  216. data/html/js/edit_area/edit_area.css +507 -0
  217. data/html/js/edit_area/edit_area.js +510 -0
  218. data/html/js/edit_area/edit_area_compressor.php +408 -0
  219. data/html/js/edit_area/edit_area_full.gz +0 -0
  220. data/html/js/edit_area/edit_area_full.js +38 -0
  221. data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
  222. data/html/js/edit_area/edit_area_full_with_plugins.js +39 -0
  223. data/html/js/edit_area/edit_area_functions.js +1098 -0
  224. data/html/js/edit_area/edit_area_loader.js +1070 -0
  225. data/html/js/edit_area/elements_functions.js +337 -0
  226. data/html/js/edit_area/highlight.js +283 -0
  227. data/html/js/edit_area/images/Thumbs.db +0 -0
  228. data/html/js/edit_area/images/autocompletion.gif +0 -0
  229. data/html/js/edit_area/images/close.gif +0 -0
  230. data/html/js/edit_area/images/fullscreen.gif +0 -0
  231. data/html/js/edit_area/images/go_to_line.gif +0 -0
  232. data/html/js/edit_area/images/help.gif +0 -0
  233. data/html/js/edit_area/images/highlight.gif +0 -0
  234. data/html/js/edit_area/images/load.gif +0 -0
  235. data/html/js/edit_area/images/move.gif +0 -0
  236. data/html/js/edit_area/images/newdocument.gif +0 -0
  237. data/html/js/edit_area/images/opacity.png +0 -0
  238. data/html/js/edit_area/images/processing.gif +0 -0
  239. data/html/js/edit_area/images/redo.gif +0 -0
  240. data/html/js/edit_area/images/reset_highlight.gif +0 -0
  241. data/html/js/edit_area/images/save.gif +0 -0
  242. data/html/js/edit_area/images/search.gif +0 -0
  243. data/html/js/edit_area/images/smooth_selection.gif +0 -0
  244. data/html/js/edit_area/images/spacer.gif +0 -0
  245. data/html/js/edit_area/images/statusbar_resize.gif +0 -0
  246. data/html/js/edit_area/images/undo.gif +0 -0
  247. data/html/js/edit_area/keyboard.js +145 -0
  248. data/html/js/edit_area/langs/cs.js +65 -0
  249. data/html/js/edit_area/langs/de.js +65 -0
  250. data/html/js/edit_area/langs/dk.js +65 -0
  251. data/html/js/edit_area/langs/en.js +65 -0
  252. data/html/js/edit_area/langs/eo.js +65 -0
  253. data/html/js/edit_area/langs/es.js +62 -0
  254. data/html/js/edit_area/langs/fr.js +65 -0
  255. data/html/js/edit_area/langs/hr.js +65 -0
  256. data/html/js/edit_area/langs/it.js +65 -0
  257. data/html/js/edit_area/langs/ja.js +65 -0
  258. data/html/js/edit_area/langs/mk.js +65 -0
  259. data/html/js/edit_area/langs/nl.js +65 -0
  260. data/html/js/edit_area/langs/pl.js +65 -0
  261. data/html/js/edit_area/langs/pt.js +65 -0
  262. data/html/js/edit_area/langs/ru.js +65 -0
  263. data/html/js/edit_area/langs/sk.js +65 -0
  264. data/html/js/edit_area/license_apache.txt +7 -0
  265. data/html/js/edit_area/license_bsd.txt +10 -0
  266. data/html/js/edit_area/license_lgpl.txt +458 -0
  267. data/html/js/edit_area/manage_area.js +466 -0
  268. data/html/js/edit_area/plugins/charmap/charmap.js +90 -0
  269. data/html/js/edit_area/plugins/charmap/css/charmap.css +64 -0
  270. data/html/js/edit_area/plugins/charmap/images/charmap.gif +0 -0
  271. data/html/js/edit_area/plugins/charmap/jscripts/map.js +373 -0
  272. data/html/js/edit_area/plugins/charmap/langs/cs.js +6 -0
  273. data/html/js/edit_area/plugins/charmap/langs/de.js +6 -0
  274. data/html/js/edit_area/plugins/charmap/langs/dk.js +6 -0
  275. data/html/js/edit_area/plugins/charmap/langs/en.js +6 -0
  276. data/html/js/edit_area/plugins/charmap/langs/eo.js +6 -0
  277. data/html/js/edit_area/plugins/charmap/langs/es.js +6 -0
  278. data/html/js/edit_area/plugins/charmap/langs/fr.js +6 -0
  279. data/html/js/edit_area/plugins/charmap/langs/hr.js +6 -0
  280. data/html/js/edit_area/plugins/charmap/langs/it.js +6 -0
  281. data/html/js/edit_area/plugins/charmap/langs/ja.js +6 -0
  282. data/html/js/edit_area/plugins/charmap/langs/mk.js +6 -0
  283. data/html/js/edit_area/plugins/charmap/langs/nl.js +6 -0
  284. data/html/js/edit_area/plugins/charmap/langs/pl.js +6 -0
  285. data/html/js/edit_area/plugins/charmap/langs/pt.js +6 -0
  286. data/html/js/edit_area/plugins/charmap/langs/ru.js +6 -0
  287. data/html/js/edit_area/plugins/charmap/langs/sk.js +6 -0
  288. data/html/js/edit_area/plugins/charmap/popup.html +24 -0
  289. data/html/js/edit_area/plugins/test/css/test.css +3 -0
  290. data/html/js/edit_area/plugins/test/images/Thumbs.db +0 -0
  291. data/html/js/edit_area/plugins/test/images/test.gif +0 -0
  292. data/html/js/edit_area/plugins/test/langs/cs.js +4 -0
  293. data/html/js/edit_area/plugins/test/langs/de.js +4 -0
  294. data/html/js/edit_area/plugins/test/langs/dk.js +4 -0
  295. data/html/js/edit_area/plugins/test/langs/en.js +4 -0
  296. data/html/js/edit_area/plugins/test/langs/eo.js +4 -0
  297. data/html/js/edit_area/plugins/test/langs/es.js +4 -0
  298. data/html/js/edit_area/plugins/test/langs/fr.js +4 -0
  299. data/html/js/edit_area/plugins/test/langs/hr.js +4 -0
  300. data/html/js/edit_area/plugins/test/langs/it.js +4 -0
  301. data/html/js/edit_area/plugins/test/langs/ja.js +4 -0
  302. data/html/js/edit_area/plugins/test/langs/mk.js +4 -0
  303. data/html/js/edit_area/plugins/test/langs/nl.js +4 -0
  304. data/html/js/edit_area/plugins/test/langs/pl.js +4 -0
  305. data/html/js/edit_area/plugins/test/langs/pt.js +4 -0
  306. data/html/js/edit_area/plugins/test/langs/ru.js +4 -0
  307. data/html/js/edit_area/plugins/test/langs/sk.js +4 -0
  308. data/html/js/edit_area/plugins/test/test.js +110 -0
  309. data/html/js/edit_area/plugins/test/test2.js +1 -0
  310. data/html/js/edit_area/reg_syntax.js +164 -0
  311. data/html/js/edit_area/reg_syntax/basic.js +69 -0
  312. data/html/js/edit_area/reg_syntax/brainfuck.js +44 -0
  313. data/html/js/edit_area/reg_syntax/c.js +62 -0
  314. data/html/js/edit_area/reg_syntax/coldfusion.js +119 -0
  315. data/html/js/edit_area/reg_syntax/cpp.js +65 -0
  316. data/html/js/edit_area/reg_syntax/css.js +84 -0
  317. data/html/js/edit_area/reg_syntax/html.js +50 -0
  318. data/html/js/edit_area/reg_syntax/js.js +93 -0
  319. data/html/js/edit_area/reg_syntax/pas.js +82 -0
  320. data/html/js/edit_area/reg_syntax/perl.js +88 -0
  321. data/html/js/edit_area/reg_syntax/php.js +156 -0
  322. data/html/js/edit_area/reg_syntax/python.js +144 -0
  323. data/html/js/edit_area/reg_syntax/robotstxt.js +24 -0
  324. data/html/js/edit_area/reg_syntax/ruby.js +67 -0
  325. data/html/js/edit_area/reg_syntax/sql.js +55 -0
  326. data/html/js/edit_area/reg_syntax/tsql.js +87 -0
  327. data/html/js/edit_area/reg_syntax/vb.js +52 -0
  328. data/html/js/edit_area/reg_syntax/xml.js +56 -0
  329. data/html/js/edit_area/regexp.js +135 -0
  330. data/html/js/edit_area/resize_area.js +82 -0
  331. data/html/js/edit_area/search_replace.js +174 -0
  332. data/html/js/edit_area/template.html +99 -0
  333. data/html/js/json-broker-client.js +61 -0
  334. data/html/js/page-manager.js +93 -0
  335. data/html/js/prototype.js +4184 -0
  336. data/html/js/result-page.js +707 -0
  337. data/html/js/rt-setting-page.js +122 -0
  338. data/html/js/sidebar.js +246 -0
  339. data/html/js/templates.js +208 -0
  340. data/html/js/utils.js +716 -0
  341. data/html/js/uuid.js +103 -0
  342. data/html/swf/chart.swf +0 -0
  343. data/lib/jiji/agent/agent.rb +93 -0
  344. data/lib/jiji/agent/agent_manager.rb +133 -0
  345. data/lib/jiji/agent/agent_registry.rb +248 -0
  346. data/lib/jiji/agent/permitter.rb +128 -0
  347. data/lib/jiji/agent/util.rb +16 -0
  348. data/lib/jiji/collector.rb +219 -0
  349. data/lib/jiji/command.rb +129 -0
  350. data/lib/jiji/configuration.rb +80 -0
  351. data/lib/jiji/dao/rate_dao.rb +149 -0
  352. data/lib/jiji/dao/timed_data_dao.rb +334 -0
  353. data/lib/jiji/dao/trade_result_dao.rb +128 -0
  354. data/lib/jiji/error.rb +33 -0
  355. data/lib/jiji/models.rb +169 -0
  356. data/lib/jiji/observer.rb +105 -0
  357. data/lib/jiji/operator.rb +405 -0
  358. data/lib/jiji/output.rb +165 -0
  359. data/lib/jiji/process.rb +182 -0
  360. data/lib/jiji/process_manager.rb +189 -0
  361. data/lib/jiji/registry.rb +255 -0
  362. data/lib/jiji/server.rb +115 -0
  363. data/lib/jiji/service/agent_service.rb +131 -0
  364. data/lib/jiji/service/hello_service.rb +10 -0
  365. data/lib/jiji/service/output_service.rb +58 -0
  366. data/lib/jiji/service/process_service.rb +78 -0
  367. data/lib/jiji/service/rate_service.rb +33 -0
  368. data/lib/jiji/service/system_service.rb +14 -0
  369. data/lib/jiji/service/trade_result_service.rb +32 -0
  370. data/lib/jiji/single_click_client.rb +95 -0
  371. data/lib/jiji/util/block_to_session.rb +70 -0
  372. data/lib/jiji/util/cache.rb +79 -0
  373. data/lib/jiji/util/csv_append_support.rb +15 -0
  374. data/lib/jiji/util/file_lock.rb +86 -0
  375. data/lib/jiji/util/fix_yaml_bug.rb +11 -0
  376. data/lib/jiji/util/iterator.rb +70 -0
  377. data/lib/jiji/util/json_broker.rb +53 -0
  378. data/lib/jiji/util/json_rpc_requestor.rb +30 -0
  379. data/lib/jiji/util/synchronize_interceptor.rb +41 -0
  380. data/lib/jiji/util/thread_use_generator.rb +52 -0
  381. data/lib/jiji/util/util.rb +179 -0
  382. data/swf/build.xml +23 -0
  383. data/swf/chart/FxChart-config.xml +9 -0
  384. data/swf/chart/FxChart.mxml +17 -0
  385. data/swf/chart/fx/chart/Chart.as +155 -0
  386. data/swf/chart/fx/chart/ctrl/AutoUpdate.as +96 -0
  387. data/swf/chart/fx/chart/ctrl/Controller.as +258 -0
  388. data/swf/chart/fx/chart/ctrl/Event.as +75 -0
  389. data/swf/chart/fx/chart/model/Model.as +226 -0
  390. data/swf/chart/fx/chart/model/TimedData.as +40 -0
  391. data/swf/chart/fx/chart/ui/AbstractChartUI.as +59 -0
  392. data/swf/chart/fx/chart/ui/AbstractDrawChartUI.as +63 -0
  393. data/swf/chart/fx/chart/ui/Constants.as +233 -0
  394. data/swf/chart/fx/chart/ui/InformationWindow.as +224 -0
  395. data/swf/chart/fx/chart/ui/LayerManager.as +95 -0
  396. data/swf/chart/fx/chart/ui/Loading.as +32 -0
  397. data/swf/chart/fx/chart/ui/Pointer.as +59 -0
  398. data/swf/chart/fx/chart/ui/RangeInfoWindow.as +84 -0
  399. data/swf/chart/fx/chart/ui/RenderingContext.as +54 -0
  400. data/swf/chart/fx/chart/ui/ScaleSelector.as +95 -0
  401. data/swf/chart/fx/chart/ui/Scroll.as +240 -0
  402. data/swf/chart/fx/chart/ui/ScrollBar.as +378 -0
  403. data/swf/chart/fx/chart/ui/Stage.as +97 -0
  404. data/swf/chart/fx/chart/ui/TradeDetailWindow.as +146 -0
  405. data/swf/chart/fx/chart/ui/TradeResult.as +334 -0
  406. data/swf/chart/fx/chart/ui/Window.as +96 -0
  407. data/swf/chart/fx/chart/ui/candle/Axis.as +112 -0
  408. data/swf/chart/fx/chart/ui/candle/Candle.as +79 -0
  409. data/swf/chart/fx/chart/ui/candle/CandleChart.as +81 -0
  410. data/swf/chart/fx/chart/ui/graph/Graph.as +198 -0
  411. data/swf/chart/fx/chart/ui/graph/GraphManager.as +177 -0
  412. data/swf/chart/fx/chart/ui/resource/buy.gif +0 -0
  413. data/swf/chart/fx/chart/ui/resource/cursor_hand.gif +0 -0
  414. data/swf/chart/fx/chart/ui/resource/diff_label.gif +0 -0
  415. data/swf/chart/fx/chart/ui/resource/down.gif +0 -0
  416. data/swf/chart/fx/chart/ui/resource/down_buy.gif +0 -0
  417. data/swf/chart/fx/chart/ui/resource/down_buy_1.gif +0 -0
  418. data/swf/chart/fx/chart/ui/resource/down_buy_2.gif +0 -0
  419. data/swf/chart/fx/chart/ui/resource/down_buy_3.gif +0 -0
  420. data/swf/chart/fx/chart/ui/resource/down_sell.gif +0 -0
  421. data/swf/chart/fx/chart/ui/resource/down_sell_1.gif +0 -0
  422. data/swf/chart/fx/chart/ui/resource/down_sell_2.gif +0 -0
  423. data/swf/chart/fx/chart/ui/resource/down_sell_3.gif +0 -0
  424. data/swf/chart/fx/chart/ui/resource/draw_buy.gif +0 -0
  425. data/swf/chart/fx/chart/ui/resource/draw_sell.gif +0 -0
  426. data/swf/chart/fx/chart/ui/resource/end_label.gif +0 -0
  427. data/swf/chart/fx/chart/ui/resource/fixed.gif +0 -0
  428. data/swf/chart/fx/chart/ui/resource/loading.gif +0 -0
  429. data/swf/chart/fx/chart/ui/resource/max_label.gif +0 -0
  430. data/swf/chart/fx/chart/ui/resource/min_label.gif +0 -0
  431. data/swf/chart/fx/chart/ui/resource/scroll_bar.gif +0 -0
  432. data/swf/chart/fx/chart/ui/resource/scroll_bar_a.gif +0 -0
  433. data/swf/chart/fx/chart/ui/resource/scroll_bar_handle.gif +0 -0
  434. data/swf/chart/fx/chart/ui/resource/scroll_bar_handle_a.gif +0 -0
  435. data/swf/chart/fx/chart/ui/resource/scroll_bar_handle_o.gif +0 -0
  436. data/swf/chart/fx/chart/ui/resource/scroll_bar_left.gif +0 -0
  437. data/swf/chart/fx/chart/ui/resource/scroll_bar_left_a.gif +0 -0
  438. data/swf/chart/fx/chart/ui/resource/scroll_bar_left_o.gif +0 -0
  439. data/swf/chart/fx/chart/ui/resource/scroll_bar_o.gif +0 -0
  440. data/swf/chart/fx/chart/ui/resource/scroll_bar_right.gif +0 -0
  441. data/swf/chart/fx/chart/ui/resource/scroll_bar_right_a.gif +0 -0
  442. data/swf/chart/fx/chart/ui/resource/scroll_bar_right_o.gif +0 -0
  443. data/swf/chart/fx/chart/ui/resource/scroll_handle.gif +0 -0
  444. data/swf/chart/fx/chart/ui/resource/scroll_info_handle.gif +0 -0
  445. data/swf/chart/fx/chart/ui/resource/scroll_left_button.gif +0 -0
  446. data/swf/chart/fx/chart/ui/resource/scroll_left_button_d.gif +0 -0
  447. data/swf/chart/fx/chart/ui/resource/scroll_left_button_down.gif +0 -0
  448. data/swf/chart/fx/chart/ui/resource/scroll_left_button_g.gif +0 -0
  449. data/swf/chart/fx/chart/ui/resource/scroll_left_button_o.gif +0 -0
  450. data/swf/chart/fx/chart/ui/resource/scroll_left_button_up.gif +0 -0
  451. data/swf/chart/fx/chart/ui/resource/scroll_outer.gif +0 -0
  452. data/swf/chart/fx/chart/ui/resource/scroll_outer_left.gif +0 -0
  453. data/swf/chart/fx/chart/ui/resource/scroll_outer_right.gif +0 -0
  454. data/swf/chart/fx/chart/ui/resource/scroll_right_button.gif +0 -0
  455. data/swf/chart/fx/chart/ui/resource/scroll_right_button_d.gif +0 -0
  456. data/swf/chart/fx/chart/ui/resource/scroll_right_button_down.gif +0 -0
  457. data/swf/chart/fx/chart/ui/resource/scroll_right_button_g.gif +0 -0
  458. data/swf/chart/fx/chart/ui/resource/scroll_right_button_o.gif +0 -0
  459. data/swf/chart/fx/chart/ui/resource/scroll_right_button_up.gif +0 -0
  460. data/swf/chart/fx/chart/ui/resource/scroll_slider_left.gif +0 -0
  461. data/swf/chart/fx/chart/ui/resource/scroll_slider_right.gif +0 -0
  462. data/swf/chart/fx/chart/ui/resource/sell.gif +0 -0
  463. data/swf/chart/fx/chart/ui/resource/start_label.gif +0 -0
  464. data/swf/chart/fx/chart/ui/resource/stripe.gif +0 -0
  465. data/swf/chart/fx/chart/ui/resource/stripe_b.gif +0 -0
  466. data/swf/chart/fx/chart/ui/resource/stripe_r.gif +0 -0
  467. data/swf/chart/fx/chart/ui/resource/unfixed.gif +0 -0
  468. data/swf/chart/fx/chart/ui/resource/up.gif +0 -0
  469. data/swf/chart/fx/chart/ui/resource/up_buy.gif +0 -0
  470. data/swf/chart/fx/chart/ui/resource/up_buy_1.gif +0 -0
  471. data/swf/chart/fx/chart/ui/resource/up_buy_2.gif +0 -0
  472. data/swf/chart/fx/chart/ui/resource/up_buy_3.gif +0 -0
  473. data/swf/chart/fx/chart/ui/resource/up_sell.gif +0 -0
  474. data/swf/chart/fx/chart/ui/resource/up_sell_1.gif +0 -0
  475. data/swf/chart/fx/chart/ui/resource/up_sell_2.gif +0 -0
  476. data/swf/chart/fx/chart/ui/resource/up_sell_3.gif +0 -0
  477. data/swf/chart/fx/net/StubFactory.as +113 -0
  478. data/swf/chart/fx/util/ListenerSupport.as +55 -0
  479. data/swf/chart/fx/util/PositionManager.as +94 -0
  480. data/swf/chart/fx/util/ScaleFormatter.as +156 -0
  481. data/swf/chart/fx/util/Util.as +61 -0
  482. data/swf/chart/log.as +40 -0
  483. data/swf/lib/corelib.swc +0 -0
  484. data/test/BackCollectorTest/basic/2008-08-04/AUDJPY.csv +5 -0
  485. data/test/BackCollectorTest/basic/2008-08-04/USDJPY.csv +5 -0
  486. data/test/BackCollectorTest/basic/2008-08-04/ZARJPY.csv +5 -0
  487. data/test/BackCollectorTest/basic/2008-08-05/AUDJPY.csv +5 -0
  488. data/test/BackCollectorTest/basic/2008-08-05/USDJPY.csv +5 -0
  489. data/test/BackCollectorTest/basic/2008-08-05/ZARJPY.csv +5 -0
  490. data/test/BackCollectorTest/basic/2008-08-06/AUDJPY.csv +5 -0
  491. data/test/BackCollectorTest/basic/2008-08-06/USDJPY.csv +5 -0
  492. data/test/BackCollectorTest/basic/2008-08-06/ZARJPY.csv +5 -0
  493. data/test/BackCollectorTest/basic/2008-08-07/AUDJPY.csv +5 -0
  494. data/test/BackCollectorTest/basic/2008-08-07/USDJPY.csv +5 -0
  495. data/test/BackCollectorTest/basic/2008-08-07/ZARJPY.csv +5 -0
  496. data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-04.csv +5 -0
  497. data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-05.csv +5 -0
  498. data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-06.csv +5 -0
  499. data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-07.csv +5 -0
  500. data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-04.csv +5 -0
  501. data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-05.csv +5 -0
  502. data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-06.csv +5 -0
  503. data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-07.csv +5 -0
  504. data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-04.csv +5 -0
  505. data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-05.csv +5 -0
  506. data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-06.csv +5 -0
  507. data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-07.csv +5 -0
  508. data/test/BackCollectorTest/lack/2008-08-04/AUDJPY.csv +5 -0
  509. data/test/BackCollectorTest/lack/2008-08-04/USDJPY.csv +5 -0
  510. data/test/BackCollectorTest/lack/2008-08-04/ZARJPY.csv +5 -0
  511. data/test/BackCollectorTest/lack/2008-08-06/AUDJPY.csv +5 -0
  512. data/test/BackCollectorTest/lack/2008-08-06/USDJPY.csv +5 -0
  513. data/test/BackCollectorTest/lack/2008-08-06/ZARJPY.csv +5 -0
  514. data/test/BackCollectorTest/lack/2008-08-07/AUDJPY.csv +5 -0
  515. data/test/BackCollectorTest/lack/2008-08-07/USDJPY.csv +5 -0
  516. data/test/BackCollectorTest/lack/2008-08-07/ZARJPY.csv +5 -0
  517. data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-04.csv +5 -0
  518. data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-06.csv +5 -0
  519. data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-07.csv +5 -0
  520. data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-04.csv +5 -0
  521. data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-06.csv +5 -0
  522. data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-07.csv +5 -0
  523. data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-04.csv +5 -0
  524. data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-06.csv +5 -0
  525. data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-07.csv +5 -0
  526. data/test/ProcessManagerTest/agents/moving_average.rb +95 -0
  527. data/test/ProcessManagerTest/conf/configuration.yaml +19 -0
  528. data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-21.csv +5853 -0
  529. data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-22.csv +5821 -0
  530. data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-23.csv +5921 -0
  531. data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-24.csv +5956 -0
  532. data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-25.csv +5796 -0
  533. data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-21.csv +5853 -0
  534. data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-22.csv +5821 -0
  535. data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-23.csv +5921 -0
  536. data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-24.csv +5956 -0
  537. data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-25.csv +5796 -0
  538. data/test/all_tests.rb +26 -0
  539. data/test/service/all_service_tests.rb +10 -0
  540. data/test/service/test_AgentService.rb +185 -0
  541. data/test/service/test_OutputService.rb +33 -0
  542. data/test/service/test_RateService.rb +56 -0
  543. data/test/test_AgentManager.rb +307 -0
  544. data/test/test_AgentRegistory.rb +566 -0
  545. data/test/test_BackTestCollector.rb +281 -0
  546. data/test/test_BlockToSession.rb +74 -0
  547. data/test/test_CSV.rb +85 -0
  548. data/test/test_Collector.rb +246 -0
  549. data/test/test_Configuration.rb +61 -0
  550. data/test/test_Configuration_a.yaml +6 -0
  551. data/test/test_Operator.rb +501 -0
  552. data/test/test_Output.rb +169 -0
  553. data/test/test_Output_registry.rb +49 -0
  554. data/test/test_PeriodicallyAgent.rb +180 -0
  555. data/test/test_Permitter.rb +217 -0
  556. data/test/test_Process.rb +186 -0
  557. data/test/test_ProcessManager.rb +312 -0
  558. data/test/test_RateDao.rb +697 -0
  559. data/test/test_SingleClickClient.rb +115 -0
  560. data/test/test_SynchronizeInterceptor.rb +75 -0
  561. data/test/test_TradeResultDao.rb +487 -0
  562. data/test/test_configuration.yaml +16 -0
  563. data/test/testutils.rb +37 -0
  564. metadata +750 -0
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $: << "../lib"
4
+
5
+
6
+ require "runit/testcase"
7
+ require "runit/cui/testrunner"
8
+ require "jiji/configuration"
9
+ require "jiji/single_click_client"
10
+ require "testutils.rb"
11
+ require 'logger'
12
+ require 'csv'
13
+
14
+
15
+ #==SingleClickClientのテスト。
16
+ class SingleClickClientTest < RUNIT::TestCase
17
+
18
+ include Test::Constants
19
+
20
+ def setup
21
+ l = Logger.new STDOUT
22
+ @c = JIJI::SingleClickClient.new( ACCOUNT, CONF, l )
23
+ end
24
+
25
+ def teardown
26
+ @c.close
27
+ end
28
+
29
+ # 正常系のテスト
30
+ def test_basic
31
+ 3.times {
32
+ assert( @c.request {|fx|
33
+ sleep 5
34
+ fx.list_currency_pairs
35
+ }.size > 0 )
36
+ }
37
+ end
38
+
39
+ # リクエストでエラーとなった場合の操作
40
+ def test_request_error
41
+ begin
42
+ @c.request {|fx|
43
+ fx.list_orders( 1000 ) # エラーコードが不正。
44
+ }
45
+ fail
46
+ rescue RuntimeError
47
+ end
48
+
49
+ # エラー後もリクエストを処理できる。
50
+ 3.times {
51
+ assert( @c.request {|fx|
52
+ sleep 5
53
+ fx.list_currency_pairs
54
+ }.size > 0)
55
+ }
56
+ end
57
+
58
+ # out of sessionで再ログインのテスト
59
+ def test_out_of_session
60
+ init = false
61
+ @c.request {|fx|
62
+ begin
63
+ raise "fail.Out Of Session." unless init
64
+ ensure
65
+ init = true
66
+ end
67
+ }
68
+
69
+ # エラー後もリクエストを処理できる。
70
+ 3.times {
71
+ assert( @c.request {|fx|
72
+ sleep 5
73
+ fx.list_currency_pairs
74
+ }.size > 0)
75
+ }
76
+ end
77
+
78
+ # 接続時にエラーになった場合
79
+ # ログ出力がされることを確認。
80
+ def test_login_error
81
+ l = Logger.new STDOUT
82
+
83
+ # 接続先が不正
84
+ conf = JIJI::Configuration.new
85
+ conf.set [:securities,:host], "notfound.com"
86
+ c = JIJI::SingleClickClient.new( ACCOUNT, conf, l ) # エラーは発生しない。
87
+
88
+ # 接続失敗状態でリクエストを送付すると、常に接続失敗の例外が返される。
89
+ 3.times {
90
+ begin
91
+ c.request {|fx| fx.list_currency_pairs }
92
+ fail
93
+ rescue JIJI::FatalError
94
+ assert_equals JIJI::ERROR_NOT_CONNECTED, $!.code
95
+ end
96
+ }
97
+ c.close
98
+
99
+ # アカウントが不正
100
+ account = Struct.new(:user,:password).new( "illegal", "illegal" )
101
+ c = JIJI::SingleClickClient.new( account, CONF, l )
102
+
103
+ # 接続失敗状態でリクエストを送付すると、常に接続失敗の例外が返される。
104
+ 3.times {
105
+ begin
106
+ c.request {|fx| fx.list_currency_pairs }
107
+ fail
108
+ rescue JIJI::FatalError
109
+ assert_equals JIJI::ERROR_NOT_CONNECTED, $!.code
110
+ end
111
+ }
112
+ c.close
113
+
114
+ end
115
+ end
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $: << "../lib"
4
+
5
+ require "runit/testcase"
6
+ require "runit/cui/testrunner"
7
+ require 'rubygems'
8
+ require 'needle'
9
+ require 'jiji/util/synchronize_interceptor'
10
+ require 'fileutils'
11
+
12
+ class SynchronizeInterceptorTest < RUNIT::TestCase
13
+
14
+ def setup
15
+ @dir = File.dirname(__FILE__) + "/CSVTest.tmp"
16
+ FileUtils.mkdir_p @dir
17
+ end
18
+
19
+ def teardown
20
+ FileUtils.rm_rf @dir
21
+ end
22
+
23
+ def test_basic
24
+
25
+ # レジストリ
26
+ p = proc {
27
+ 5.times {|i| print "#{i},"; sleep 0.1 }
28
+ }
29
+ registry = Needle::Registry.define {|builder|
30
+ builder.loop_no { p }
31
+ builder.loop_x1 { p }
32
+ builder.loop_x2 { p }
33
+ builder.loop_y1 { p }
34
+ builder.loop_y2 { p }
35
+ }
36
+
37
+ # インターセプタを適用
38
+ registry.intercept( :loop_x1 ).with { SynchronizeInterceptor }.with_options( :id=>"x" )
39
+ registry.intercept( :loop_x2 ).with { SynchronizeInterceptor }.with_options( :id=>"x" )
40
+ registry.intercept( :loop_y1 ).with { SynchronizeInterceptor }.with_options( :id=>"y" )
41
+ registry.intercept( :loop_y2 ).with { SynchronizeInterceptor }.with_options( :id=>"y" )
42
+
43
+ loops = [
44
+ :loop_no, :loop_x1, :loop_x2, :loop_y1, :loop_y2
45
+ ]
46
+ loops.each {|a|
47
+ loops.each {|b|
48
+ puts "\n\n---#{a} x #{b}"
49
+ [registry[a],registry[b]].map {|x|
50
+ Thread.fork(x) {|l| l.call }
51
+ }.each{|t| t.value }
52
+ }
53
+ }
54
+ end
55
+
56
+ # 同じインターセプタが2重に適用されている場合のテスト
57
+ def test_dual
58
+ registry = Needle::Registry.new {|r|
59
+ r.register( :a ) {
60
+ proc { puts "aaa" }
61
+ }
62
+ r.register( :b ) {
63
+ a = r.a
64
+ proc { a.call; puts "bbb" }
65
+ }
66
+ }
67
+ registry.intercept( :a ).with { SynchronizeInterceptor }.with_options( :id=>"x" )
68
+ registry.intercept( :b ).with { SynchronizeInterceptor }.with_options( :id=>"x" )
69
+
70
+ b = registry.b
71
+ 3.times{|i| b.call }
72
+ end
73
+
74
+
75
+ end
@@ -0,0 +1,487 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $: << "../lib"
4
+
5
+
6
+ require "runit/testcase"
7
+ require "runit/cui/testrunner"
8
+ require 'jiji/dao/trade_result_dao'
9
+ require 'jiji/operator'
10
+ require 'fileutils'
11
+ require 'rubygems'
12
+ require "testutils"
13
+
14
+ class TradeResultDaoTest < RUNIT::TestCase
15
+
16
+ include Test::Constants
17
+
18
+ def setup
19
+ @dir = File.dirname(__FILE__) + "/TradeResultDaoTest.tmp"
20
+ FileUtils.mkdir_p @dir
21
+
22
+ @dao = JIJI::Dao::TradeResultDao.new( @dir, [ "30s", "1m", "5m" ] )
23
+ end
24
+
25
+ def teardown
26
+ FileUtils.rm_rf @dir
27
+ end
28
+
29
+ def test_basic
30
+
31
+ pair_infos = {
32
+ ClickClient::FX::USDJPY => Info.new( 10000 ),
33
+ ClickClient::FX::AUDUSD => Info.new( 10000 )
34
+ }
35
+
36
+ op = JIJI::Operator.new @dao
37
+ op.conf = CONF
38
+ op.next_rates( JIJI::Rates.new( pair_infos, {
39
+ :USDJPY => JIJI::Rate.new( 101.0, 101.05, -250, 250 ),
40
+ :AUDUSD => JIJI::Rate.new( 101.0, 101.05, -250, 250 )
41
+ }, Time.local(2008,8,7,0,0,0)))
42
+
43
+ assert_equals @dao.list_positions("30s"), {}
44
+ assert_equals read_profit_or_loss("30s"), []
45
+ assert_equals @dao.list_positions("1m"), {}
46
+ assert_equals read_profit_or_loss("1m"), []
47
+
48
+ op.next_rates( JIJI::Rates.new( pair_infos, {
49
+ :USDJPY => JIJI::Rate.new( 101.03, 101.08, -250, 250 ),
50
+ :AUDUSD => JIJI::Rate.new( 101.03, 101.08, -250, 250 )
51
+ }, Time.local(2008,8,7,0,0,40)))
52
+
53
+ assert_equals @dao.list_positions("30s"), {}
54
+ assert_equals read_profit_or_loss("30s"), [
55
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s]
56
+ ]
57
+ assert_equals @dao.list_positions("1m"), {}
58
+ assert_equals read_profit_or_loss("1m"), []
59
+
60
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,50)), {}
61
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,50)), {}
62
+
63
+ # 注文
64
+ p1 = op.buy( 1, :USDJPY, "a" )
65
+ op.next_rates( JIJI::Rates.new( pair_infos, {
66
+ :USDJPY => JIJI::Rate.new( 101.0, 101.05, -250, 250 ),
67
+ :AUDUSD => JIJI::Rate.new( 101.0, 101.05, -250, 250 )
68
+ }, Time.local(2008,8,7,0,1,1) ))
69
+
70
+ p1_props = {
71
+ :open_interest_no=>"",
72
+ :count=>1,
73
+ :rate=>101.08,
74
+ :state=>1,
75
+ :fix_rate=>nil,
76
+ :date=>1218034840,
77
+ :pair=>:USDJPY,
78
+ :fix_date=>0,
79
+ :sell_or_buy=>:buy,
80
+ :price=>1010800.0,
81
+ :trader=>"a",
82
+ :position_id=>p1.position_id,
83
+ :profit_or_loss=>-500.0,
84
+ :swap=>0
85
+ }
86
+ assert_equals @dao.list_positions("30s"), {
87
+ p1.position_id=> p1_props
88
+ }
89
+ assert_equals read_profit_or_loss("30s"), [
90
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
91
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s]
92
+ ]
93
+ assert_equals @dao.list_positions("1m"), {
94
+ p1.position_id=> p1_props
95
+ }
96
+ assert_equals read_profit_or_loss("1m"), [
97
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s]
98
+ ]
99
+
100
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
101
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
102
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,2)), {
103
+ p1.position_id=> p1_props
104
+ }
105
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,2)), {
106
+ p1.position_id=> p1_props
107
+ }
108
+
109
+ # 注文
110
+ p2 = op.sell( 1, :USDJPY, "b" )
111
+ p2_props = p2.values
112
+ op.next_rates( JIJI::Rates.new( pair_infos, {
113
+ :USDJPY => JIJI::Rate.new( 100.0, 100.05, -250, 250 ),
114
+ :AUDUSD => JIJI::Rate.new( 100.0, 100.05, -250, 250 )
115
+ }, Time.local(2008,8,7,0,1,21) ))
116
+
117
+ # プロパティは購入/売却/コミット時にのみ更新される。
118
+ assert_equals @dao.list_positions("30s"), {
119
+ p1.position_id=> p1_props,
120
+ p2.position_id=> p2_props
121
+ }
122
+ assert_equals read_profit_or_loss("30s"), [
123
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
124
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s]
125
+ ]
126
+ assert_equals @dao.list_positions("1m"), {
127
+ p1.position_id=> p1_props,
128
+ p2.position_id=> p2_props
129
+ }
130
+ assert_equals read_profit_or_loss("1m"), [
131
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s]
132
+ ]
133
+
134
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
135
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
136
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
137
+ p1.position_id=> p1_props
138
+ }
139
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
140
+ p1.position_id=> p1_props
141
+ }
142
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,1,10), Time.local(2008,8,7,0,1,30)), {
143
+ p1.position_id=> p1_props,
144
+ p2.position_id=> p2_props
145
+ }
146
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,1,10), Time.local(2008,8,7,0,1,30)), {
147
+ p1.position_id=> p1_props,
148
+ p2.position_id=> p2_props
149
+ }
150
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,30)), {
151
+ p1.position_id=> p1_props,
152
+ p2.position_id=> p2_props
153
+ }
154
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,30)), {
155
+ p1.position_id=> p1_props,
156
+ p2.position_id=> p2_props
157
+ }
158
+
159
+ # 次のレート
160
+ # 取引データ、損益データが記録される
161
+ op.next_rates( JIJI::Rates.new( pair_infos, {
162
+ :USDJPY => JIJI::Rate.new( 100.1, 100.15, -250, 250 ),
163
+ :AUDUSD => JIJI::Rate.new( 100.1, 100.15, -250, 250 )
164
+ }, Time.local(2008,8,7,0,1,33) ))
165
+
166
+ assert_equals @dao.list_positions("30s"), {
167
+ p1.position_id=> p1_props,
168
+ p2.position_id=> p2_props
169
+ }
170
+ assert_equals read_profit_or_loss("30s"), [
171
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
172
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s],
173
+ ["-1300", "0", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,1,30).to_i.to_s]
174
+ ]
175
+ assert_equals @dao.list_positions("1m"), {
176
+ p1.position_id=> p1_props,
177
+ p2.position_id=> p2_props
178
+ }
179
+ assert_equals read_profit_or_loss("1m"), [
180
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s]
181
+ ]
182
+
183
+ # 約定
184
+ op.commit(p1)
185
+ p1_props = p1.values
186
+ assert_equals @dao.list_positions("30s"), {
187
+ p1.position_id=> p1_props,
188
+ p2.position_id=> p2_props
189
+ }
190
+ assert_equals read_profit_or_loss("30s"), [
191
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
192
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s],
193
+ ["-1300", "0", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,1,30).to_i.to_s]
194
+ ]
195
+ assert_equals @dao.list_positions("1m"), {
196
+ p1.position_id=> p1_props,
197
+ p2.position_id=> p2_props
198
+ }
199
+ assert_equals read_profit_or_loss("1m"), [
200
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s]
201
+ ]
202
+
203
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
204
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
205
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
206
+ p1.position_id=> p1_props
207
+ }
208
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
209
+ p1.position_id=> p1_props
210
+ }
211
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,1,10), Time.local(2008,8,7,0,1,30)), {
212
+ p1.position_id=> p1_props,
213
+ p2.position_id=> p2_props
214
+ }
215
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,1,10), Time.local(2008,8,7,0,1,30)), {
216
+ p1.position_id=> p1_props,
217
+ p2.position_id=> p2_props
218
+ }
219
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,30)), {
220
+ p1.position_id=> p1_props,
221
+ p2.position_id=> p2_props
222
+ }
223
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,30)), {
224
+ p1.position_id=> p1_props,
225
+ p2.position_id=> p2_props
226
+ }
227
+
228
+ # 次のレート
229
+ # 取引データ、損益データが記録される
230
+ op.next_rates( JIJI::Rates.new( pair_infos, {
231
+ :USDJPY => JIJI::Rate.new( 101.0, 101.05, -250, 250 ),
232
+ :AUDUSD => JIJI::Rate.new( 101.0, 101.05, -250, 250 )
233
+ }, Time.local(2008,8,7,0,2,0) ))
234
+ assert_equals @dao.list_positions("30s"), {
235
+ p1.position_id=> p1_props,
236
+ p2.position_id=> p2_props
237
+ }
238
+ assert_equals read_profit_or_loss("30s"), [
239
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
240
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s],
241
+ ["-1300", "0", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,1,30).to_i.to_s],
242
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,30).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s]
243
+ ]
244
+ assert_equals @dao.list_positions("1m"), {
245
+ p1.position_id=> p1_props,
246
+ p2.position_id=> p2_props
247
+ }
248
+ assert_equals read_profit_or_loss("1m"), [
249
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,1,0).to_i.to_s],
250
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s]
251
+ ]
252
+
253
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
254
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,30)), {}
255
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
256
+ p1.position_id=> p1_props
257
+ }
258
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
259
+ p1.position_id=> p1_props
260
+ }
261
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,1,10), Time.local(2008,8,7,0,1,30)), {
262
+ p1.position_id=> p1_props,
263
+ p2.position_id=> p2_props
264
+ }
265
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,1,10), Time.local(2008,8,7,0,2,0)), {
266
+ p1.position_id=> p1_props,
267
+ p2.position_id=> p2_props
268
+ }
269
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,30)), {
270
+ p1.position_id=> p1_props,
271
+ p2.position_id=> p2_props
272
+ }
273
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,2,0)), {
274
+ p1.position_id=> p1_props,
275
+ p2.position_id=> p2_props
276
+ }
277
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,1,35), Time.local(2008,8,7,0,2,0)), {
278
+ p2.position_id=> p2_props
279
+ }
280
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,1,35), Time.local(2008,8,7,0,2,0)), {
281
+ p2.position_id=> p2_props
282
+ }
283
+
284
+ # 次
285
+ op.next_rates( JIJI::Rates.new( pair_infos, {
286
+ :USDJPY => JIJI::Rate.new( 100.5, 100.55, -250, 250 ),
287
+ :AUDUSD => JIJI::Rate.new( 100.5, 100.55, -250, 250 )
288
+ }, Time.local(2008,8,7,0,2,31) ))
289
+ assert_equals @dao.list_positions("30s"), {
290
+ p1.position_id=> p1_props,
291
+ p2.position_id=> p2_props
292
+ }
293
+ assert_equals read_profit_or_loss("30s"), [
294
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
295
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s],
296
+ ["-1300", "0", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,1,30).to_i.to_s],
297
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,30).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s],
298
+ ["-5300", "-9800", "0.0", Time.local(2008,8,7,0,2,0).to_i.to_s, Time.local(2008,8,7,0,2,30).to_i.to_s]
299
+ ]
300
+ assert_equals @dao.list_positions("1m"), {
301
+ p1.position_id=> p1_props,
302
+ p2.position_id=> p2_props
303
+ }
304
+ assert_equals read_profit_or_loss("1m"), [
305
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,1,0).to_i.to_s],
306
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s]
307
+ ]
308
+
309
+ # p2をコミット
310
+ op.commit(p2)
311
+ p2_props = p2.values
312
+ op.next_rates( JIJI::Rates.new( pair_infos, {
313
+ :USDJPY => JIJI::Rate.new( 100.5, 100.55, -250, 250 ),
314
+ :AUDUSD => JIJI::Rate.new( 100.5, 100.55, -250, 250 )
315
+ }, Time.local(2008,8,7,0,3,0) ))
316
+ assert_equals @dao.list_positions("30s"), {
317
+ p1.position_id=> p1_props,
318
+ p2.position_id=> p2_props
319
+ }
320
+ assert_equals read_profit_or_loss("30s"), [
321
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
322
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s],
323
+ ["-1300", "0", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,1,30).to_i.to_s],
324
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,30).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s],
325
+ ["-5300", "-9800", "0.0", Time.local(2008,8,7,0,2,0).to_i.to_s, Time.local(2008,8,7,0,2,30).to_i.to_s],
326
+ ["-5300", "-5300", "0.5", Time.local(2008,8,7,0,2,30).to_i.to_s, Time.local(2008,8,7,0,3,0).to_i.to_s]
327
+ ]
328
+ assert_equals @dao.list_positions("1m"), {
329
+ p1.position_id=> p1_props,
330
+ p2.position_id=> p2_props
331
+ }
332
+ assert_equals read_profit_or_loss("1m"), [
333
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,1,0).to_i.to_s],
334
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s],
335
+ ["-5300", "-5300", "0.5", Time.local(2008,8,7,0,2,0).to_i.to_s, Time.local(2008,8,7,0,3,0).to_i.to_s]
336
+ ]
337
+
338
+ # 次
339
+ op.next_rates( JIJI::Rates.new( pair_infos, {
340
+ :USDJPY => JIJI::Rate.new( 101.5, 101.55, -250, 250 ),
341
+ :AUDUSD => JIJI::Rate.new( 101.5, 101.55, -250, 250 )
342
+ }, Time.local(2008,8,7,0,3,31) ))
343
+ assert_equals @dao.list_positions("30s"), {
344
+ p1.position_id=> p1_props,
345
+ p2.position_id=> p2_props
346
+ }
347
+ assert_equals read_profit_or_loss("30s"), [
348
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s],
349
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,30).to_i.to_s, Time.local(2008,8,7,0,0,60).to_i.to_s],
350
+ ["-1300", "0", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,1,30).to_i.to_s],
351
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,30).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s],
352
+ ["-5300", "-9800", "0.0", Time.local(2008,8,7,0,2,0).to_i.to_s, Time.local(2008,8,7,0,2,30).to_i.to_s],
353
+ ["-5300", "-5300", "0.5", Time.local(2008,8,7,0,2,30).to_i.to_s, Time.local(2008,8,7,0,3,0).to_i.to_s],
354
+ ["-5300", "-5300", "0.5", Time.local(2008,8,7,0,3,0).to_i.to_s, Time.local(2008,8,7,0,3,30).to_i.to_s]
355
+ ]
356
+ assert_equals @dao.list_positions("1m"), {
357
+ p1.position_id=> p1_props,
358
+ p2.position_id=> p2_props
359
+ }
360
+ assert_equals read_profit_or_loss("1m"), [
361
+ ["-800", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,1,0).to_i.to_s],
362
+ ["-10300", "-9800", "0.0", Time.local(2008,8,7,0,1,0).to_i.to_s, Time.local(2008,8,7,0,2,0).to_i.to_s],
363
+ ["-5300", "-5300", "0.5", Time.local(2008,8,7,0,2,0).to_i.to_s, Time.local(2008,8,7,0,3,0).to_i.to_s]
364
+ ]
365
+
366
+ # コミット済みデータは削除される
367
+ assert_equals op.positions.length, 0
368
+
369
+ # 部分取得
370
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,50)), {}
371
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
372
+ p1.position_id=> p1_props
373
+ }
374
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,2,0), Time.local(2008,8,7,0,2,30)), {
375
+ p2.position_id=> p2_props,
376
+ }
377
+ assert_equals @dao.list_positions("30s", Time.local(2008,8,7,0,3,0), Time.local(2008,8,7,0,3,30)), {}
378
+
379
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,0,50)), {}
380
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,0,0), Time.local(2008,8,7,0,1,0)), {
381
+ p1.position_id=> p1_props,
382
+ }
383
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,2,1), Time.local(2008,8,7,0,3,0)), {
384
+ p2.position_id=> p2_props,
385
+ }
386
+ assert_equals @dao.list_positions("1m", Time.local(2008,8,7,0,3,1), Time.local(2008,8,7,0,7,0)), {}
387
+
388
+ end
389
+
390
+ # flush のテスト。
391
+ def test_flush()
392
+ pair_infos = {
393
+ ClickClient::FX::USDJPY => Info.new( 10000 ),
394
+ ClickClient::FX::AUDUSD => Info.new( 10000 )
395
+ }
396
+
397
+ op = JIJI::Operator.new @dao
398
+ op.conf = CONF
399
+ op.next_rates( JIJI::Rates.new( pair_infos, {
400
+ :USDJPY => JIJI::Rate.new( 101.0, 101.05, -250, 250 ),
401
+ :AUDUSD => JIJI::Rate.new( 101.0, 101.05, -250, 250 )
402
+ }, Time.local(2008,8,7,0,0,0)))
403
+
404
+ assert_equals @dao.list_positions("30s"), {}
405
+ assert_equals @dao.list_positions("1m"), {}
406
+ assert_equals @dao.list_positions("5m"), {}
407
+
408
+ op.next_rates( JIJI::Rates.new( pair_infos, {
409
+ :USDJPY => JIJI::Rate.new( 101.03, 101.08, -250, 250 ),
410
+ :AUDUSD => JIJI::Rate.new( 101.03, 101.08, -250, 250 )
411
+ }, Time.local(2008,8,7,0,0,40)))
412
+
413
+ assert_equals @dao.list_positions("30s"), {}
414
+ assert_equals read_profit_or_loss("30s"), [
415
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s]
416
+ ]
417
+ assert_equals @dao.list_positions("1m"), {}
418
+ assert_equals read_profit_or_loss("1m"), []
419
+ assert_equals @dao.list_positions("5m"), {}
420
+ assert_equals read_profit_or_loss("5m"), []
421
+
422
+ # 注文
423
+ p1 = op.buy( 1, :USDJPY, "a" )
424
+ op.next_rates( JIJI::Rates.new( pair_infos, {
425
+ :USDJPY => JIJI::Rate.new( 101.0, 101.05, -250, 250 ),
426
+ :AUDUSD => JIJI::Rate.new( 101.0, 101.05, -250, 250 )
427
+ }, Time.local(2008,8,7,0,0,50) ))
428
+
429
+ # 1mは経過していないので、バッファ内のデータは保存されていない。
430
+ p1_props = {
431
+ :open_interest_no=>"",
432
+ :count=>1,
433
+ :rate=>101.08,
434
+ :state=>1,
435
+ :fix_rate=>nil,
436
+ :date=>1218034840,
437
+ :pair=>:USDJPY,
438
+ :fix_date=>0,
439
+ :sell_or_buy=>:buy,
440
+ :price=>1010800.0,
441
+ :trader=>"a",
442
+ :position_id=>p1.position_id,
443
+ :profit_or_loss=>-500.0,
444
+ :swap=>0
445
+ }
446
+ assert_equals @dao.list_positions("30s"), {
447
+ p1.position_id=> p1_props
448
+ }
449
+ assert_equals read_profit_or_loss("30s"), [
450
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s]
451
+ ]
452
+ assert_equals @dao.list_positions("1m"), {
453
+ p1.position_id=> p1_props
454
+ }
455
+ assert_equals read_profit_or_loss("1m"), []
456
+ assert_equals @dao.list_positions("5m"), {
457
+ p1.position_id=> p1_props
458
+ }
459
+ assert_equals read_profit_or_loss("5m"), []
460
+
461
+ # 強制書き出し
462
+ # ポジションデータのみ強制的に書き出される。
463
+ @dao.flush( Time.local(2008,8,7,0,0,55) )
464
+ assert_equals @dao.list_positions("30s"), {
465
+ p1.position_id=> p1_props
466
+ }
467
+ assert_equals read_profit_or_loss("30s"), [
468
+ ["0", "0", "0.0", Time.local(2008,8,7,0,0,0).to_i.to_s, Time.local(2008,8,7,0,0,30).to_i.to_s]
469
+ ]
470
+ assert_equals @dao.list_positions("1m"), {
471
+ p1.position_id=> p1_props # データが書き出される
472
+ }
473
+ assert_equals read_profit_or_loss("1m"), []
474
+ assert_equals @dao.list_positions("5m"), {
475
+ p1.position_id=> p1_props # データが書き出される
476
+ }
477
+ assert_equals read_profit_or_loss("5m"), []
478
+ end
479
+
480
+
481
+ def read_profit_or_loss( scale, start_date=nil, end_date=nil )
482
+ list = []
483
+ @dao.each( scale, start_date, end_date ) {|row| list << row }
484
+ return list
485
+ end
486
+
487
+ end