unageanu-jiji 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +0 -0
- data/README +0 -0
- data/bin/jiji.rb +6 -0
- data/html/css/calendar.css +432 -0
- data/html/css/datatable.css +299 -0
- data/html/css/default.css +557 -0
- data/html/css/dialog.css +77 -0
- data/html/img/auto_trade_off.gif +0 -0
- data/html/img/auto_trade_on.gif +0 -0
- data/html/img/back_bottom.gif +0 -0
- data/html/img/back_middle.gif +0 -0
- data/html/img/back_top.gif +0 -0
- data/html/img/bt-create-title-1.gif +0 -0
- data/html/img/bt-create-title-2.gif +0 -0
- data/html/img/bt-create-title-3.gif +0 -0
- data/html/img/button_add.gif +0 -0
- data/html/img/button_add_gray.gif +0 -0
- data/html/img/button_add_over.gif +0 -0
- data/html/img/button_apply.gif +0 -0
- data/html/img/button_apply_gray.gif +0 -0
- data/html/img/button_apply_over.gif +0 -0
- data/html/img/button_calendar.gif +0 -0
- data/html/img/button_calendar_over.gif +0 -0
- data/html/img/button_cancel.gif +0 -0
- data/html/img/button_cancel.jpg +0 -0
- data/html/img/button_cancel_gray.gif +0 -0
- data/html/img/button_cancel_over.gif +0 -0
- data/html/img/button_cancel_over.jpg +0 -0
- data/html/img/button_close.gif +0 -0
- data/html/img/button_close_gray.gif +0 -0
- data/html/img/button_close_over.gif +0 -0
- data/html/img/button_ok.gif +0 -0
- data/html/img/button_ok_gray.gif +0 -0
- data/html/img/button_ok_over.gif +0 -0
- data/html/img/button_remove.gif +0 -0
- data/html/img/button_remove_gray.gif +0 -0
- data/html/img/button_remove_over.gif +0 -0
- data/html/img/button_start.gif +0 -0
- data/html/img/button_start_over.gif +0 -0
- data/html/img/button_update.gif +0 -0
- data/html/img/button_update_gray.gif +0 -0
- data/html/img/button_update_over.gif +0 -0
- data/html/img/circle.gif +0 -0
- data/html/img/delta.gif +0 -0
- data/html/img/dialog_info.jpg +0 -0
- data/html/img/dialog_input.jpg +0 -0
- data/html/img/dialog_warn.jpg +0 -0
- data/html/img/dt-arrow-dn.png +0 -0
- data/html/img/dt-arrow-up.png +0 -0
- data/html/img/foot.jpg +0 -0
- data/html/img/h3_bt-create_0.gif +0 -0
- data/html/img/h3_bt-create_1.gif +0 -0
- data/html/img/h3_bt-create_2.gif +0 -0
- data/html/img/h3_result_0.gif +0 -0
- data/html/img/h3_result_1.gif +0 -0
- data/html/img/h3_result_2.gif +0 -0
- data/html/img/h3_result_3.gif +0 -0
- data/html/img/h3_result_4.gif +0 -0
- data/html/img/h3_result_5.gif +0 -0
- data/html/img/h3_result_6.gif +0 -0
- data/html/img/h3_rt-setting_0.gif +0 -0
- data/html/img/h3_rt-setting_1.gif +0 -0
- data/html/img/head.jpg +0 -0
- data/html/img/line_white.gif +0 -0
- data/html/img/loading.gif +0 -0
- data/html/img/panel_100_bottom.gif +0 -0
- data/html/img/panel_100_middle.gif +0 -0
- data/html/img/panel_100_top.gif +0 -0
- data/html/img/panel_140_650_b.gif +0 -0
- data/html/img/panel_140_650_m.gif +0 -0
- data/html/img/panel_140_650_t.gif +0 -0
- data/html/img/panel_140_660_b.gif +0 -0
- data/html/img/panel_140_660_m.gif +0 -0
- data/html/img/panel_140_660_t.gif +0 -0
- data/html/img/panel_140_b.gif +0 -0
- data/html/img/panel_140_m.gif +0 -0
- data/html/img/panel_140_t.gif +0 -0
- data/html/img/panel_260_b.gif +0 -0
- data/html/img/panel_260_m.gif +0 -0
- data/html/img/panel_260_t.gif +0 -0
- data/html/img/panel_300_b.gif +0 -0
- data/html/img/panel_300_m.gif +0 -0
- data/html/img/panel_300_t.gif +0 -0
- data/html/img/panel_320_b.gif +0 -0
- data/html/img/panel_320_m.gif +0 -0
- data/html/img/panel_320_t.gif +0 -0
- data/html/img/panel_360_b.gif +0 -0
- data/html/img/panel_360_m.gif +0 -0
- data/html/img/panel_360_t.gif +0 -0
- data/html/img/panel_380_b.gif +0 -0
- data/html/img/panel_380_m.gif +0 -0
- data/html/img/panel_380_t.gif +0 -0
- data/html/img/panel_500_b.gif +0 -0
- data/html/img/panel_500_m.gif +0 -0
- data/html/img/panel_500_t.gif +0 -0
- data/html/img/panel_620_b.gif +0 -0
- data/html/img/panel_620_m.gif +0 -0
- data/html/img/panel_620_t.gif +0 -0
- data/html/img/panel_780_b.gif +0 -0
- data/html/img/panel_780_m.gif +0 -0
- data/html/img/panel_780_t.gif +0 -0
- data/html/img/problem.gif +0 -0
- data/html/img/progressbar.gif +0 -0
- data/html/img/result-title-1-1.gif +0 -0
- data/html/img/result-title-1-2.gif +0 -0
- data/html/img/result-title-2-1.gif +0 -0
- data/html/img/result-title-2-2.gif +0 -0
- data/html/img/result-title-3-1.gif +0 -0
- data/html/img/result-title-4-1.gif +0 -0
- data/html/img/rt-setting-title-1.gif +0 -0
- data/html/img/rt-setting-title-2.gif +0 -0
- data/html/img/s.gif +0 -0
- data/html/img/scroll.gif +0 -0
- data/html/img/separator.gif +0 -0
- data/html/img/sidebar_agent.png +0 -0
- data/html/img/sidebar_agent_edit.png +0 -0
- data/html/img/sidebar_agent_edit_agent.png +0 -0
- data/html/img/sidebar_agent_edit_agent_over.png +0 -0
- data/html/img/sidebar_agent_edit_agent_s.png +0 -0
- data/html/img/sidebar_agent_edit_over.png +0 -0
- data/html/img/sidebar_agent_edit_s.png +0 -0
- data/html/img/sidebar_agent_edit_shared_lib.png +0 -0
- data/html/img/sidebar_agent_edit_shared_lib_over.png +0 -0
- data/html/img/sidebar_agent_edit_shared_lib_s.png +0 -0
- data/html/img/sidebar_back.gif +0 -0
- data/html/img/sidebar_bt.png +0 -0
- data/html/img/sidebar_bt_create.png +0 -0
- data/html/img/sidebar_bt_create_over.png +0 -0
- data/html/img/sidebar_bt_create_s.png +0 -0
- data/html/img/sidebar_bt_result.png +0 -0
- data/html/img/sidebar_bt_result_over.png +0 -0
- data/html/img/sidebar_bt_result_s.png +0 -0
- data/html/img/sidebar_result_rmt.png +0 -0
- data/html/img/sidebar_result_rmt_over.png +0 -0
- data/html/img/sidebar_result_rmt_s.png +0 -0
- data/html/img/sidebar_rt.png +0 -0
- data/html/img/sidebar_rt_setting.png +0 -0
- data/html/img/sidebar_rt_setting_over.png +0 -0
- data/html/img/sidebar_rt_setting_s.png +0 -0
- data/html/img/sprite.png +0 -0
- data/html/img/submenu_agents.png +0 -0
- data/html/img/submenu_agents_over.png +0 -0
- data/html/img/submenu_agents_s.png +0 -0
- data/html/img/submenu_graph.png +0 -0
- data/html/img/submenu_graph_over.png +0 -0
- data/html/img/submenu_graph_s.png +0 -0
- data/html/img/submenu_info.png +0 -0
- data/html/img/submenu_info_over.png +0 -0
- data/html/img/submenu_info_s.png +0 -0
- data/html/img/submenu_log.png +0 -0
- data/html/img/submenu_log_over.png +0 -0
- data/html/img/submenu_log_s.png +0 -0
- data/html/img/submenu_operation.png +0 -0
- data/html/img/submenu_operation_over.png +0 -0
- data/html/img/submenu_operation_s.png +0 -0
- data/html/img/submenu_trade.png +0 -0
- data/html/img/submenu_trade_over.png +0 -0
- data/html/img/submenu_trade_s.png +0 -0
- data/html/img/td_over.gif +0 -0
- data/html/img/td_over_d.gif +0 -0
- data/html/img/td_selected.gif +0 -0
- data/html/img/thead.gif +0 -0
- data/html/img/transparent.gif +0 -0
- data/html/index.html +480 -0
- data/html/js/W3CDTF.js +131 -0
- data/html/js/agent-editor-page.js +350 -0
- data/html/js/agent-selector.js +642 -0
- data/html/js/app.js +226 -0
- data/html/js/bt-create-page.js +186 -0
- data/html/js/codepress/codepress.css +21 -0
- data/html/js/codepress/codepress.html +35 -0
- data/html/js/codepress/codepress.js +138 -0
- data/html/js/codepress/engines/gecko.js +293 -0
- data/html/js/codepress/engines/khtml.js +0 -0
- data/html/js/codepress/engines/msie.js +304 -0
- data/html/js/codepress/engines/older.js +0 -0
- data/html/js/codepress/engines/opera.js +260 -0
- data/html/js/codepress/images/line-numbers.gif +0 -0
- data/html/js/codepress/images/line-numbers.png +0 -0
- data/html/js/codepress/index.html +443 -0
- data/html/js/codepress/languages/asp.css +71 -0
- data/html/js/codepress/languages/asp.js +117 -0
- data/html/js/codepress/languages/autoit.css +13 -0
- data/html/js/codepress/languages/autoit.js +32 -0
- data/html/js/codepress/languages/csharp.css +9 -0
- data/html/js/codepress/languages/csharp.js +25 -0
- data/html/js/codepress/languages/css.css +10 -0
- data/html/js/codepress/languages/css.js +23 -0
- data/html/js/codepress/languages/generic.css +9 -0
- data/html/js/codepress/languages/generic.js +25 -0
- data/html/js/codepress/languages/html.css +13 -0
- data/html/js/codepress/languages/html.js +59 -0
- data/html/js/codepress/languages/java.css +7 -0
- data/html/js/codepress/languages/java.js +24 -0
- data/html/js/codepress/languages/javascript.css +8 -0
- data/html/js/codepress/languages/javascript.js +30 -0
- data/html/js/codepress/languages/perl.css +11 -0
- data/html/js/codepress/languages/perl.js +27 -0
- data/html/js/codepress/languages/php.css +12 -0
- data/html/js/codepress/languages/php.js +61 -0
- data/html/js/codepress/languages/ruby.css +10 -0
- data/html/js/codepress/languages/ruby.js +26 -0
- data/html/js/codepress/languages/sql.css +10 -0
- data/html/js/codepress/languages/sql.js +30 -0
- data/html/js/codepress/languages/text.css +5 -0
- data/html/js/codepress/languages/text.js +9 -0
- data/html/js/codepress/languages/vbscript.css +71 -0
- data/html/js/codepress/languages/vbscript.js +117 -0
- data/html/js/codepress/languages/xsl.css +15 -0
- data/html/js/codepress/languages/xsl.js +103 -0
- data/html/js/codepress/license.txt +458 -0
- data/html/js/container-min.js +1 -0
- data/html/js/container-utils.js +78 -0
- data/html/js/dialog.js +270 -0
- data/html/js/edit_area/autocompletion.js +493 -0
- data/html/js/edit_area/edit_area.css +507 -0
- data/html/js/edit_area/edit_area.js +510 -0
- data/html/js/edit_area/edit_area_compressor.php +408 -0
- data/html/js/edit_area/edit_area_full.gz +0 -0
- data/html/js/edit_area/edit_area_full.js +38 -0
- data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
- data/html/js/edit_area/edit_area_full_with_plugins.js +39 -0
- data/html/js/edit_area/edit_area_functions.js +1098 -0
- data/html/js/edit_area/edit_area_loader.js +1070 -0
- data/html/js/edit_area/elements_functions.js +337 -0
- data/html/js/edit_area/highlight.js +283 -0
- data/html/js/edit_area/images/Thumbs.db +0 -0
- data/html/js/edit_area/images/autocompletion.gif +0 -0
- data/html/js/edit_area/images/close.gif +0 -0
- data/html/js/edit_area/images/fullscreen.gif +0 -0
- data/html/js/edit_area/images/go_to_line.gif +0 -0
- data/html/js/edit_area/images/help.gif +0 -0
- data/html/js/edit_area/images/highlight.gif +0 -0
- data/html/js/edit_area/images/load.gif +0 -0
- data/html/js/edit_area/images/move.gif +0 -0
- data/html/js/edit_area/images/newdocument.gif +0 -0
- data/html/js/edit_area/images/opacity.png +0 -0
- data/html/js/edit_area/images/processing.gif +0 -0
- data/html/js/edit_area/images/redo.gif +0 -0
- data/html/js/edit_area/images/reset_highlight.gif +0 -0
- data/html/js/edit_area/images/save.gif +0 -0
- data/html/js/edit_area/images/search.gif +0 -0
- data/html/js/edit_area/images/smooth_selection.gif +0 -0
- data/html/js/edit_area/images/spacer.gif +0 -0
- data/html/js/edit_area/images/statusbar_resize.gif +0 -0
- data/html/js/edit_area/images/undo.gif +0 -0
- data/html/js/edit_area/keyboard.js +145 -0
- data/html/js/edit_area/langs/cs.js +65 -0
- data/html/js/edit_area/langs/de.js +65 -0
- data/html/js/edit_area/langs/dk.js +65 -0
- data/html/js/edit_area/langs/en.js +65 -0
- data/html/js/edit_area/langs/eo.js +65 -0
- data/html/js/edit_area/langs/es.js +62 -0
- data/html/js/edit_area/langs/fr.js +65 -0
- data/html/js/edit_area/langs/hr.js +65 -0
- data/html/js/edit_area/langs/it.js +65 -0
- data/html/js/edit_area/langs/ja.js +65 -0
- data/html/js/edit_area/langs/mk.js +65 -0
- data/html/js/edit_area/langs/nl.js +65 -0
- data/html/js/edit_area/langs/pl.js +65 -0
- data/html/js/edit_area/langs/pt.js +65 -0
- data/html/js/edit_area/langs/ru.js +65 -0
- data/html/js/edit_area/langs/sk.js +65 -0
- data/html/js/edit_area/license_apache.txt +7 -0
- data/html/js/edit_area/license_bsd.txt +10 -0
- data/html/js/edit_area/license_lgpl.txt +458 -0
- data/html/js/edit_area/manage_area.js +466 -0
- data/html/js/edit_area/plugins/charmap/charmap.js +90 -0
- data/html/js/edit_area/plugins/charmap/css/charmap.css +64 -0
- data/html/js/edit_area/plugins/charmap/images/charmap.gif +0 -0
- data/html/js/edit_area/plugins/charmap/jscripts/map.js +373 -0
- data/html/js/edit_area/plugins/charmap/langs/cs.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/de.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/dk.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/en.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/eo.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/es.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/fr.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/hr.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/it.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/ja.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/mk.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/nl.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/pl.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/pt.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/ru.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/sk.js +6 -0
- data/html/js/edit_area/plugins/charmap/popup.html +24 -0
- data/html/js/edit_area/plugins/test/css/test.css +3 -0
- data/html/js/edit_area/plugins/test/images/Thumbs.db +0 -0
- data/html/js/edit_area/plugins/test/images/test.gif +0 -0
- data/html/js/edit_area/plugins/test/langs/cs.js +4 -0
- data/html/js/edit_area/plugins/test/langs/de.js +4 -0
- data/html/js/edit_area/plugins/test/langs/dk.js +4 -0
- data/html/js/edit_area/plugins/test/langs/en.js +4 -0
- data/html/js/edit_area/plugins/test/langs/eo.js +4 -0
- data/html/js/edit_area/plugins/test/langs/es.js +4 -0
- data/html/js/edit_area/plugins/test/langs/fr.js +4 -0
- data/html/js/edit_area/plugins/test/langs/hr.js +4 -0
- data/html/js/edit_area/plugins/test/langs/it.js +4 -0
- data/html/js/edit_area/plugins/test/langs/ja.js +4 -0
- data/html/js/edit_area/plugins/test/langs/mk.js +4 -0
- data/html/js/edit_area/plugins/test/langs/nl.js +4 -0
- data/html/js/edit_area/plugins/test/langs/pl.js +4 -0
- data/html/js/edit_area/plugins/test/langs/pt.js +4 -0
- data/html/js/edit_area/plugins/test/langs/ru.js +4 -0
- data/html/js/edit_area/plugins/test/langs/sk.js +4 -0
- data/html/js/edit_area/plugins/test/test.js +110 -0
- data/html/js/edit_area/plugins/test/test2.js +1 -0
- data/html/js/edit_area/reg_syntax.js +164 -0
- data/html/js/edit_area/reg_syntax/basic.js +69 -0
- data/html/js/edit_area/reg_syntax/brainfuck.js +44 -0
- data/html/js/edit_area/reg_syntax/c.js +62 -0
- data/html/js/edit_area/reg_syntax/coldfusion.js +119 -0
- data/html/js/edit_area/reg_syntax/cpp.js +65 -0
- data/html/js/edit_area/reg_syntax/css.js +84 -0
- data/html/js/edit_area/reg_syntax/html.js +50 -0
- data/html/js/edit_area/reg_syntax/js.js +93 -0
- data/html/js/edit_area/reg_syntax/pas.js +82 -0
- data/html/js/edit_area/reg_syntax/perl.js +88 -0
- data/html/js/edit_area/reg_syntax/php.js +156 -0
- data/html/js/edit_area/reg_syntax/python.js +144 -0
- data/html/js/edit_area/reg_syntax/robotstxt.js +24 -0
- data/html/js/edit_area/reg_syntax/ruby.js +67 -0
- data/html/js/edit_area/reg_syntax/sql.js +55 -0
- data/html/js/edit_area/reg_syntax/tsql.js +87 -0
- data/html/js/edit_area/reg_syntax/vb.js +52 -0
- data/html/js/edit_area/reg_syntax/xml.js +56 -0
- data/html/js/edit_area/regexp.js +135 -0
- data/html/js/edit_area/resize_area.js +82 -0
- data/html/js/edit_area/search_replace.js +174 -0
- data/html/js/edit_area/template.html +99 -0
- data/html/js/json-broker-client.js +61 -0
- data/html/js/page-manager.js +93 -0
- data/html/js/prototype.js +4184 -0
- data/html/js/result-page.js +707 -0
- data/html/js/rt-setting-page.js +122 -0
- data/html/js/sidebar.js +246 -0
- data/html/js/templates.js +208 -0
- data/html/js/utils.js +716 -0
- data/html/js/uuid.js +103 -0
- data/html/swf/chart.swf +0 -0
- data/lib/jiji/agent/agent.rb +93 -0
- data/lib/jiji/agent/agent_manager.rb +133 -0
- data/lib/jiji/agent/agent_registry.rb +248 -0
- data/lib/jiji/agent/permitter.rb +128 -0
- data/lib/jiji/agent/util.rb +16 -0
- data/lib/jiji/collector.rb +219 -0
- data/lib/jiji/command.rb +129 -0
- data/lib/jiji/configuration.rb +80 -0
- data/lib/jiji/dao/rate_dao.rb +149 -0
- data/lib/jiji/dao/timed_data_dao.rb +334 -0
- data/lib/jiji/dao/trade_result_dao.rb +128 -0
- data/lib/jiji/error.rb +33 -0
- data/lib/jiji/models.rb +169 -0
- data/lib/jiji/observer.rb +105 -0
- data/lib/jiji/operator.rb +405 -0
- data/lib/jiji/output.rb +165 -0
- data/lib/jiji/process.rb +182 -0
- data/lib/jiji/process_manager.rb +189 -0
- data/lib/jiji/registry.rb +255 -0
- data/lib/jiji/server.rb +115 -0
- data/lib/jiji/service/agent_service.rb +131 -0
- data/lib/jiji/service/hello_service.rb +10 -0
- data/lib/jiji/service/output_service.rb +58 -0
- data/lib/jiji/service/process_service.rb +78 -0
- data/lib/jiji/service/rate_service.rb +33 -0
- data/lib/jiji/service/system_service.rb +14 -0
- data/lib/jiji/service/trade_result_service.rb +32 -0
- data/lib/jiji/single_click_client.rb +95 -0
- data/lib/jiji/util/block_to_session.rb +70 -0
- data/lib/jiji/util/cache.rb +79 -0
- data/lib/jiji/util/csv_append_support.rb +15 -0
- data/lib/jiji/util/file_lock.rb +86 -0
- data/lib/jiji/util/fix_yaml_bug.rb +11 -0
- data/lib/jiji/util/iterator.rb +70 -0
- data/lib/jiji/util/json_broker.rb +53 -0
- data/lib/jiji/util/json_rpc_requestor.rb +30 -0
- data/lib/jiji/util/synchronize_interceptor.rb +41 -0
- data/lib/jiji/util/thread_use_generator.rb +52 -0
- data/lib/jiji/util/util.rb +179 -0
- data/swf/build.xml +23 -0
- data/swf/chart/FxChart-config.xml +9 -0
- data/swf/chart/FxChart.mxml +17 -0
- data/swf/chart/fx/chart/Chart.as +155 -0
- data/swf/chart/fx/chart/ctrl/AutoUpdate.as +96 -0
- data/swf/chart/fx/chart/ctrl/Controller.as +258 -0
- data/swf/chart/fx/chart/ctrl/Event.as +75 -0
- data/swf/chart/fx/chart/model/Model.as +226 -0
- data/swf/chart/fx/chart/model/TimedData.as +40 -0
- data/swf/chart/fx/chart/ui/AbstractChartUI.as +59 -0
- data/swf/chart/fx/chart/ui/AbstractDrawChartUI.as +63 -0
- data/swf/chart/fx/chart/ui/Constants.as +233 -0
- data/swf/chart/fx/chart/ui/InformationWindow.as +224 -0
- data/swf/chart/fx/chart/ui/LayerManager.as +95 -0
- data/swf/chart/fx/chart/ui/Loading.as +32 -0
- data/swf/chart/fx/chart/ui/Pointer.as +59 -0
- data/swf/chart/fx/chart/ui/RangeInfoWindow.as +84 -0
- data/swf/chart/fx/chart/ui/RenderingContext.as +54 -0
- data/swf/chart/fx/chart/ui/ScaleSelector.as +95 -0
- data/swf/chart/fx/chart/ui/Scroll.as +240 -0
- data/swf/chart/fx/chart/ui/ScrollBar.as +378 -0
- data/swf/chart/fx/chart/ui/Stage.as +97 -0
- data/swf/chart/fx/chart/ui/TradeDetailWindow.as +146 -0
- data/swf/chart/fx/chart/ui/TradeResult.as +334 -0
- data/swf/chart/fx/chart/ui/Window.as +96 -0
- data/swf/chart/fx/chart/ui/candle/Axis.as +112 -0
- data/swf/chart/fx/chart/ui/candle/Candle.as +79 -0
- data/swf/chart/fx/chart/ui/candle/CandleChart.as +81 -0
- data/swf/chart/fx/chart/ui/graph/Graph.as +198 -0
- data/swf/chart/fx/chart/ui/graph/GraphManager.as +177 -0
- data/swf/chart/fx/chart/ui/resource/buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/cursor_hand.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/diff_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy_3.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell_3.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/draw_buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/draw_sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/end_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/fixed.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/loading.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/max_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/min_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_handle.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_handle_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_handle_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_left.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_left_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_left_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_right.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_right_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_right_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_handle.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_info_handle.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_d.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_down.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_g.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_up.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_outer.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_outer_left.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_outer_right.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_d.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_down.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_g.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_up.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_slider_left.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_slider_right.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/start_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/stripe.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/stripe_b.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/stripe_r.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/unfixed.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy_3.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell_3.gif +0 -0
- data/swf/chart/fx/net/StubFactory.as +113 -0
- data/swf/chart/fx/util/ListenerSupport.as +55 -0
- data/swf/chart/fx/util/PositionManager.as +94 -0
- data/swf/chart/fx/util/ScaleFormatter.as +156 -0
- data/swf/chart/fx/util/Util.as +61 -0
- data/swf/chart/log.as +40 -0
- data/swf/lib/corelib.swc +0 -0
- data/test/BackCollectorTest/basic/2008-08-04/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-04/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-04/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-05/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-05/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-05/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-06/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-06/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-06/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-07/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-07/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-07/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-05.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-05.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-05.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-04/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-04/USDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-04/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-06/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-06/USDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-06/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-07/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-07/USDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-07/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-07.csv +5 -0
- data/test/ProcessManagerTest/agents/moving_average.rb +95 -0
- data/test/ProcessManagerTest/conf/configuration.yaml +19 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-21.csv +5853 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-22.csv +5821 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-23.csv +5921 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-24.csv +5956 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-25.csv +5796 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-21.csv +5853 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-22.csv +5821 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-23.csv +5921 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-24.csv +5956 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-25.csv +5796 -0
- data/test/all_tests.rb +26 -0
- data/test/service/all_service_tests.rb +10 -0
- data/test/service/test_AgentService.rb +185 -0
- data/test/service/test_OutputService.rb +33 -0
- data/test/service/test_RateService.rb +56 -0
- data/test/test_AgentManager.rb +307 -0
- data/test/test_AgentRegistory.rb +566 -0
- data/test/test_BackTestCollector.rb +281 -0
- data/test/test_BlockToSession.rb +74 -0
- data/test/test_CSV.rb +85 -0
- data/test/test_Collector.rb +246 -0
- data/test/test_Configuration.rb +61 -0
- data/test/test_Configuration_a.yaml +6 -0
- data/test/test_Operator.rb +501 -0
- data/test/test_Output.rb +169 -0
- data/test/test_Output_registry.rb +49 -0
- data/test/test_PeriodicallyAgent.rb +180 -0
- data/test/test_Permitter.rb +217 -0
- data/test/test_Process.rb +186 -0
- data/test/test_ProcessManager.rb +312 -0
- data/test/test_RateDao.rb +697 -0
- data/test/test_SingleClickClient.rb +115 -0
- data/test/test_SynchronizeInterceptor.rb +75 -0
- data/test/test_TradeResultDao.rb +487 -0
- data/test/test_configuration.yaml +16 -0
- data/test/testutils.rb +37 -0
- metadata +750 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
|
2
|
+
require 'thread'
|
3
|
+
require 'jiji/util/csv_append_support'
|
4
|
+
require 'jiji/util/thread_use_generator'
|
5
|
+
require 'jiji/util/util'
|
6
|
+
require 'jiji/models'
|
7
|
+
require 'jiji/dao/timed_data_dao'
|
8
|
+
require 'set'
|
9
|
+
|
10
|
+
module JIJI
|
11
|
+
module Dao
|
12
|
+
|
13
|
+
# 取引結果DAO
|
14
|
+
class TradeResultDao
|
15
|
+
|
16
|
+
def initialize( data_dir, scales=[] )
|
17
|
+
@data_dir = data_dir
|
18
|
+
@scales = scales
|
19
|
+
|
20
|
+
aggregators = @scales.map {|s| TradeAggregator.new(s) }
|
21
|
+
@trade_dao = dao( "trade", aggregators )
|
22
|
+
|
23
|
+
aggregators = @scales.map {|s| LastAggregator.new(s) }
|
24
|
+
@profit_or_loss_dao = dao( "profit_or_loss", aggregators )
|
25
|
+
|
26
|
+
@position_dir = "#{data_dir}/positions"
|
27
|
+
FileUtils.mkdir_p @position_dir unless File.exists? @position_dir
|
28
|
+
end
|
29
|
+
|
30
|
+
# ポジションデータを保存する
|
31
|
+
def save( position )
|
32
|
+
props = position.values
|
33
|
+
file = "#{@position_dir}/#{position.position_id}.yaml"
|
34
|
+
FileLock.new( file ).writelock {|f|
|
35
|
+
f.write( YAML.dump(props) )
|
36
|
+
}
|
37
|
+
end
|
38
|
+
# ポジションデータをロードする。
|
39
|
+
def load( id )
|
40
|
+
props = {}
|
41
|
+
file = "#{@position_dir}/#{id}.yaml"
|
42
|
+
if ( File.exist? file )
|
43
|
+
FileLock.new( file ).readlock {|f|
|
44
|
+
props = YAML.load f
|
45
|
+
}
|
46
|
+
end
|
47
|
+
props
|
48
|
+
end
|
49
|
+
|
50
|
+
# 指定期間のトレードデータを得る。
|
51
|
+
def list_positions( scale, start_date=nil, end_date=nil )
|
52
|
+
ids = Set.new
|
53
|
+
@trade_dao.each_data( scale, start_date, end_date ) {|r, t|
|
54
|
+
ids += r[0].split(" ")
|
55
|
+
}
|
56
|
+
|
57
|
+
# バッファ内に取得期間内のデータがある場合、それも追加する。
|
58
|
+
aggregator = @trade_dao.aggregator.find {|a| a.scale == scale }
|
59
|
+
if aggregator && aggregator.values
|
60
|
+
aggregator.values.each {|v| ids << v }
|
61
|
+
end
|
62
|
+
ids.inject({}) {|r,id|
|
63
|
+
v = load(id)
|
64
|
+
if ( !( start_date && v[:fix_date] != 0 && v[:fix_date] < start_date.to_i ) \
|
65
|
+
&& !( end_date && v[:date] > end_date.to_i ))
|
66
|
+
r[id] = v
|
67
|
+
end
|
68
|
+
r
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
# 指定の期間の損益データを得る。
|
73
|
+
def each( scale=:raw, start_date=nil, end_date=nil, &block )
|
74
|
+
@profit_or_loss_dao.each_data( scale, start_date, end_date ) {|row, time|
|
75
|
+
yield row
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
# 取引結果を記録する。
|
80
|
+
def next( operator, time )
|
81
|
+
@profit_or_loss_dao << BasicTimedData.new(
|
82
|
+
[operator.profit_or_loss, operator.fixed_profit_or_loss, operator.win_rate], time)
|
83
|
+
ids = operator.positions.map {|p| p[1].position_id }
|
84
|
+
@trade_dao << BasicTimedData.new( [ids], time)
|
85
|
+
end
|
86
|
+
|
87
|
+
# 取引結果を強制的に記録する。
|
88
|
+
def flush( time )
|
89
|
+
# 取引結果のみ(損益データは出力しない)
|
90
|
+
@trade_dao.flush(time)
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def dao( name, aggregators )
|
96
|
+
dir = "#{@data_dir}/#{name}"
|
97
|
+
FileUtils.mkdir_p dir unless File.exists? dir
|
98
|
+
|
99
|
+
TimedDataDao.new( dir, aggregators )
|
100
|
+
end
|
101
|
+
|
102
|
+
def lock(file)
|
103
|
+
FileLock.new( "#{file}.lock" ).writelock {
|
104
|
+
yield
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
class TradeAggregator < AbstractAggregator
|
109
|
+
def aggregate( timed_data )
|
110
|
+
@values = Set.new unless @values
|
111
|
+
@values += timed_data.values[0]
|
112
|
+
end
|
113
|
+
def aggregated
|
114
|
+
begin
|
115
|
+
str = @values.to_a.join(" ")
|
116
|
+
return BasicTimedData.new( [str] \
|
117
|
+
+ [@start.to_i, @end.to_i], @end)
|
118
|
+
ensure
|
119
|
+
@values.clear
|
120
|
+
end
|
121
|
+
end
|
122
|
+
attr_reader :values
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
data/lib/jiji/error.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module JIJI
|
3
|
+
# 致命的エラー
|
4
|
+
class FatalError < StandardError
|
5
|
+
def initialize( code, message="" )
|
6
|
+
super( message )
|
7
|
+
@code = code
|
8
|
+
end
|
9
|
+
attr :code
|
10
|
+
end
|
11
|
+
# ユーザー操作により発生しうるエラー
|
12
|
+
class UserError < StandardError
|
13
|
+
def initialize( code, message="" )
|
14
|
+
super( message )
|
15
|
+
@code = code
|
16
|
+
end
|
17
|
+
attr :code
|
18
|
+
end
|
19
|
+
|
20
|
+
# エラーコード:存在しない
|
21
|
+
ERROR_NOT_FOUND = "not_found"
|
22
|
+
# エラーコード:すでに存在する
|
23
|
+
ERROR_ALREADY_EXIST = "already_exist"
|
24
|
+
|
25
|
+
# エラーコード:不正な名前
|
26
|
+
ERROR_ILLEGAL_NAME = "illegal_name"
|
27
|
+
|
28
|
+
# エラーコード:想定外エラー
|
29
|
+
ERROR_FATAL = "fatal"
|
30
|
+
|
31
|
+
# エラーコード:サーバーに接続されていない
|
32
|
+
ERROR_NOT_CONNECTED = "not_connected"
|
33
|
+
end
|
data/lib/jiji/models.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
|
2
|
+
require 'jiji/util/util'
|
3
|
+
require "jiji/dao/timed_data_dao"
|
4
|
+
|
5
|
+
module JIJI
|
6
|
+
|
7
|
+
#==レートの集合
|
8
|
+
class Rates < Hash
|
9
|
+
|
10
|
+
include JIJI::Util::Model
|
11
|
+
|
12
|
+
def initialize( pair_infos, list, time=Time.now )
|
13
|
+
super()
|
14
|
+
@pair_infos = pair_infos.inject({}){ |r,pair|
|
15
|
+
code = JIJI::Util.convert_currency_pair_code(pair[0])
|
16
|
+
r[code] = pair[1]
|
17
|
+
r
|
18
|
+
}
|
19
|
+
@time = time
|
20
|
+
list.each_pair { |k,info|
|
21
|
+
self[k] = Rate.new( info.bid.to_f, info.ask.to_f,
|
22
|
+
info.sell_swap.to_f, info.buy_swap.to_f, time)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
# 通貨ペアの情報(取引数量など)
|
26
|
+
attr_reader :pair_infos
|
27
|
+
# 現在時刻
|
28
|
+
attr_reader :time
|
29
|
+
end
|
30
|
+
|
31
|
+
#==レート
|
32
|
+
class Rate
|
33
|
+
|
34
|
+
include JIJI::Util::Model
|
35
|
+
include JIJI::Dao::TimedData
|
36
|
+
|
37
|
+
def initialize( bid=nil, ask=nil, sell_swap=nil, buy_swap=nil, time=nil )
|
38
|
+
@bid = bid
|
39
|
+
@ask = ask
|
40
|
+
@sell_swap = sell_swap
|
41
|
+
@buy_swap = buy_swap
|
42
|
+
@time = time
|
43
|
+
end
|
44
|
+
# 値を配列で取得する
|
45
|
+
def values
|
46
|
+
[bid,ask,sell_swap,buy_swap,time.to_i]
|
47
|
+
end
|
48
|
+
# 値を配列で設定する
|
49
|
+
def values=(values)
|
50
|
+
@bid = values[0].to_f
|
51
|
+
@ask = values[1].to_f
|
52
|
+
@sell_swap = values[2].to_f
|
53
|
+
@buy_swap = values[3].to_f
|
54
|
+
end
|
55
|
+
attr_reader :bid, :ask, :sell_swap, :buy_swap
|
56
|
+
end
|
57
|
+
|
58
|
+
#==一定期間のレートの集合
|
59
|
+
class PeriodicallyRates < Hash
|
60
|
+
|
61
|
+
include JIJI::Util::Model
|
62
|
+
|
63
|
+
def initialize( pair_infos, list=[] )
|
64
|
+
super()
|
65
|
+
@pair_infos = pair_infos
|
66
|
+
list.each {|rates|
|
67
|
+
self << rates
|
68
|
+
}
|
69
|
+
end
|
70
|
+
def <<(rates)
|
71
|
+
now = rates.time
|
72
|
+
@start_time = now unless @start_time
|
73
|
+
@end_time = now
|
74
|
+
rates.each_pair { |code,rate|
|
75
|
+
self[code] = PeriodicallyRate.new unless key? code
|
76
|
+
self[code] << rate
|
77
|
+
}
|
78
|
+
end
|
79
|
+
def time
|
80
|
+
@start_time
|
81
|
+
end
|
82
|
+
attr_reader :pair_infos
|
83
|
+
attr :start_time, true
|
84
|
+
attr :end_time, true
|
85
|
+
end
|
86
|
+
|
87
|
+
#==一定期間のレート
|
88
|
+
#bid,ask,sell_swap,buy_swapは四本値(JIJI::PeriodicallyValue)で保持される。
|
89
|
+
class PeriodicallyRate
|
90
|
+
|
91
|
+
include JIJI::Util::Model
|
92
|
+
include JIJI::Dao::TimedData
|
93
|
+
|
94
|
+
def initialize( list=[] )
|
95
|
+
@bid = PeriodicallyValue.new
|
96
|
+
@ask = PeriodicallyValue.new
|
97
|
+
@sell_swap = PeriodicallyValue.new
|
98
|
+
@buy_swap = PeriodicallyValue.new
|
99
|
+
list.each { |item|
|
100
|
+
self << item
|
101
|
+
}
|
102
|
+
end
|
103
|
+
def <<( rate )
|
104
|
+
@bid << rate.bid
|
105
|
+
@ask << rate.ask
|
106
|
+
@sell_swap << rate.sell_swap
|
107
|
+
@buy_swap << rate.buy_swap
|
108
|
+
@start_time = rate.time unless @start_time
|
109
|
+
@end_time = rate.time
|
110
|
+
end
|
111
|
+
# 値を配列で取得する
|
112
|
+
def values
|
113
|
+
bid.values + ask.values + sell_swap.values + buy_swap.values \
|
114
|
+
+ [@start_time.to_i, @end_time.to_i]
|
115
|
+
end
|
116
|
+
# 値を配列で設定する
|
117
|
+
def values=(values)
|
118
|
+
@bid.values = values[0..3]
|
119
|
+
@ask.values = values[4..7]
|
120
|
+
@sell_swap.values = values[8..11]
|
121
|
+
@buy_swap.values = values[12..15]
|
122
|
+
@start_time = Time.at(values[16].to_i)
|
123
|
+
@end_time = Time.at(values[17].to_i)
|
124
|
+
end
|
125
|
+
def time
|
126
|
+
@end_time
|
127
|
+
end
|
128
|
+
def time=(t)
|
129
|
+
@end_time = t
|
130
|
+
end
|
131
|
+
attr_reader :bid, :ask, :sell_swap, :buy_swap
|
132
|
+
attr :start_time, true
|
133
|
+
attr :end_time, true
|
134
|
+
end
|
135
|
+
|
136
|
+
#==一定期間の値
|
137
|
+
#始値、終値、高値、安値の四本値
|
138
|
+
class PeriodicallyValue
|
139
|
+
|
140
|
+
include JIJI::Util::Model
|
141
|
+
|
142
|
+
def initialize( list=[] )
|
143
|
+
list.each { |item|
|
144
|
+
self << item
|
145
|
+
}
|
146
|
+
end
|
147
|
+
def <<( value )
|
148
|
+
@start = value if @start == nil
|
149
|
+
@end = value
|
150
|
+
@max = value if @max == nil || value > @max
|
151
|
+
@min = value if @min == nil || value < @min
|
152
|
+
end
|
153
|
+
# 値を配列で取得する
|
154
|
+
def values
|
155
|
+
[@start, @end, @max, @min]
|
156
|
+
end
|
157
|
+
# 値を配列で設定する
|
158
|
+
def values=(values)
|
159
|
+
@start = values[0].to_f
|
160
|
+
@end = values[1].to_f
|
161
|
+
@max = values[2].to_f
|
162
|
+
@min = values[3].to_f
|
163
|
+
end
|
164
|
+
attr :start
|
165
|
+
attr :end
|
166
|
+
attr :max
|
167
|
+
attr :min
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
require 'thread'
|
3
|
+
|
4
|
+
module JIJI
|
5
|
+
|
6
|
+
#==コレクターからのレートの通知を受け取るクラス。
|
7
|
+
class ObserverManager
|
8
|
+
#コンストラクタ
|
9
|
+
#observers:: オブサーバー
|
10
|
+
#logger:: ロガー
|
11
|
+
def initialize( observers, logger )
|
12
|
+
@logger = logger
|
13
|
+
@observers = observers
|
14
|
+
end
|
15
|
+
#レートの通知を受ける
|
16
|
+
#rates:: レート
|
17
|
+
def next_rates( rates )
|
18
|
+
@observers.each {|w|
|
19
|
+
w.next_rates( rates )
|
20
|
+
}
|
21
|
+
end
|
22
|
+
#オブザーバーを追加する
|
23
|
+
#observer:: オブザーバー
|
24
|
+
def <<(observer)
|
25
|
+
@observers << observer
|
26
|
+
end
|
27
|
+
#通知を停止する
|
28
|
+
def stop
|
29
|
+
end
|
30
|
+
#ロガー
|
31
|
+
attr :logger, true
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
#==コレクターからのレートの通知を受け取り、別スレッドで処理するクラス。
|
36
|
+
#- 登録されたオブザーバーごとに専用のスレッドを起こして情報を通知する。
|
37
|
+
#- スレッドを破棄する必要があるため、必ずstopで停止すること。
|
38
|
+
class WorkerThreadObserverManager
|
39
|
+
#コンストラクタ
|
40
|
+
#observers:: オブサーバー
|
41
|
+
#logger:: ロガー
|
42
|
+
def initialize( observers, logger )
|
43
|
+
@logger = logger
|
44
|
+
@workers = observers.map {|o|
|
45
|
+
Worker.new( o, @logger )
|
46
|
+
}
|
47
|
+
end
|
48
|
+
#レートの通知を受ける
|
49
|
+
#rates:: レート
|
50
|
+
def next_rates( rates )
|
51
|
+
@workers.each {|w|
|
52
|
+
w.next_rates( rates )
|
53
|
+
}
|
54
|
+
end
|
55
|
+
#オブザーバーを追加する
|
56
|
+
#observer:: オブザーバー
|
57
|
+
def <<(observer)
|
58
|
+
@workers << Worker.new( observer, @logger )
|
59
|
+
end
|
60
|
+
#通知を停止する
|
61
|
+
def stop
|
62
|
+
@logger.info( "observer manager stop" )
|
63
|
+
@workers.each {|w| w.alive = false }
|
64
|
+
@workers.each {|w| w.thread.join }
|
65
|
+
@workers.clear
|
66
|
+
end
|
67
|
+
#ロガー
|
68
|
+
attr :logger, true
|
69
|
+
end
|
70
|
+
|
71
|
+
# ワーカースレッド
|
72
|
+
class Worker
|
73
|
+
def initialize( observer, logger )
|
74
|
+
@logger = logger
|
75
|
+
@alive = true
|
76
|
+
@alive_mutex = Mutex.new
|
77
|
+
@q = Queue.new
|
78
|
+
@thread = Thread.start {
|
79
|
+
while( !@q.empty? || alive? )
|
80
|
+
JIJI::Util.log_if_error( @logger ) {
|
81
|
+
rates = @q.pop
|
82
|
+
observer.next_rates( rates ) if rates != nil
|
83
|
+
}
|
84
|
+
end
|
85
|
+
}
|
86
|
+
end
|
87
|
+
def next_rates( rates )
|
88
|
+
@q.push rates
|
89
|
+
end
|
90
|
+
def alive?
|
91
|
+
@alive_mutex.synchronize {
|
92
|
+
@alive
|
93
|
+
}
|
94
|
+
end
|
95
|
+
def alive=(value)
|
96
|
+
@alive_mutex.synchronize {
|
97
|
+
@alive = value
|
98
|
+
@q.push nil # 眠れるスレッドをたたき起こす。
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
attr_reader :thread
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,405 @@
|
|
1
|
+
|
2
|
+
require 'fileutils'
|
3
|
+
require 'delegate'
|
4
|
+
require 'jiji/util/util'
|
5
|
+
require 'jiji/single_click_client'
|
6
|
+
require 'jiji/util/util'
|
7
|
+
require 'jiji/dao/timed_data_dao'
|
8
|
+
require 'uuidtools'
|
9
|
+
|
10
|
+
module JIJI
|
11
|
+
|
12
|
+
#==オペレーター
|
13
|
+
class Operator
|
14
|
+
|
15
|
+
#===コンストラクタ
|
16
|
+
#*money*:: 保証金
|
17
|
+
def initialize( trade_result_dao=nil, money=nil )
|
18
|
+
@rate = nil
|
19
|
+
@money = money
|
20
|
+
@profit_or_loss = 0
|
21
|
+
@fixed_profit_or_loss = 0
|
22
|
+
@positions = {}
|
23
|
+
@draw = 0
|
24
|
+
@lose = 0
|
25
|
+
@win = 0.0
|
26
|
+
@trade_result_dao = trade_result_dao
|
27
|
+
end
|
28
|
+
|
29
|
+
#===レートを更新する。
|
30
|
+
def next_rates( rate )
|
31
|
+
@rate = rate
|
32
|
+
result = @positions.inject({:total=>0.0,:profit=>0}) {|r,e|
|
33
|
+
p = e[1]
|
34
|
+
p.next(rate)
|
35
|
+
r[:total] += p.price if p.state == Position::STATE_START
|
36
|
+
r[:profit] += p.profit_or_loss
|
37
|
+
r
|
38
|
+
}
|
39
|
+
@profit_or_loss = result[:profit] + @fixed_profit_or_loss
|
40
|
+
if @money && (( @money + result[:profit] ) / result[:total]) <= 0.007
|
41
|
+
raise "loss cut"
|
42
|
+
end
|
43
|
+
@trade_result_dao.next( self, rate.time ) if @trade_result_dao
|
44
|
+
end
|
45
|
+
|
46
|
+
#===購入する
|
47
|
+
#count:: 購入する数量
|
48
|
+
#pair:: 通貨ペア(:EURJPYなど)
|
49
|
+
#trader:: 取引実行者識別用の名前
|
50
|
+
#return:: Position
|
51
|
+
def buy(count, pair=:EURJPY, trader="")
|
52
|
+
rate = @rate[pair]
|
53
|
+
unit = @rate.pair_infos[pair].trade_unit
|
54
|
+
p = Position.new( UUID.random_create().to_s, Position::BUY, count,
|
55
|
+
unit, @rate.time, rate.ask, pair, trader, self )
|
56
|
+
p.next( @rate )
|
57
|
+
@profit_or_loss += p.profit_or_loss
|
58
|
+
@positions[p.position_id] = p
|
59
|
+
@trade_result_dao.save( p ) if @trade_result_dao
|
60
|
+
return p
|
61
|
+
end
|
62
|
+
|
63
|
+
#===売却する
|
64
|
+
#count:: 売却する数量
|
65
|
+
#pair:: 通貨ペア(:EURJPYなど)
|
66
|
+
#trader:: 取引実行者識別用の名前
|
67
|
+
#return:: Position
|
68
|
+
def sell(count, pair=:EURJPY, trader="")
|
69
|
+
rate = @rate[pair]
|
70
|
+
unit = @rate.pair_infos[pair].trade_unit
|
71
|
+
p = Position.new( UUID.random_create().to_s, Position::SELL, count,
|
72
|
+
unit, @rate.time, rate.bid, pair, trader, self )
|
73
|
+
p.next( @rate )
|
74
|
+
@profit_or_loss += p.profit_or_loss
|
75
|
+
@positions[p.position_id] = p
|
76
|
+
@trade_result_dao.save( p ) if @trade_result_dao
|
77
|
+
return p
|
78
|
+
end
|
79
|
+
|
80
|
+
# 取引を確定する
|
81
|
+
def commit(position)
|
82
|
+
position._commit
|
83
|
+
@trade_result_dao.save( position ) if @trade_result_dao
|
84
|
+
@positions.delete position.position_id
|
85
|
+
|
86
|
+
@fixed_profit_or_loss += position.profit_or_loss
|
87
|
+
if position.profit_or_loss == 0
|
88
|
+
@draw+=1
|
89
|
+
elsif position.profit_or_loss < 0
|
90
|
+
@lose+=1
|
91
|
+
else
|
92
|
+
@win+=1
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# 勝率
|
97
|
+
def win_rate
|
98
|
+
win > 0 ? win / (win+lose+draw) : 0.0
|
99
|
+
end
|
100
|
+
|
101
|
+
# 未約定のポジションデータを"ロスト"としてマークする。
|
102
|
+
def stop
|
103
|
+
@positions.each_pair {|k, v|
|
104
|
+
v.lost
|
105
|
+
@trade_result_dao.save( v ) if @trade_result_dao
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
# すべてのポジションデータを保存する。
|
110
|
+
def flush
|
111
|
+
@positions.each_pair {|k, v|
|
112
|
+
@trade_result_dao.save( v ) if @trade_result_dao
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
#現在の損益
|
117
|
+
attr_reader :profit_or_loss
|
118
|
+
#現在の確定済み損益
|
119
|
+
attr_reader :fixed_profit_or_loss
|
120
|
+
#建て玉
|
121
|
+
attr :positions
|
122
|
+
|
123
|
+
# 勝ち数
|
124
|
+
attr_reader :win
|
125
|
+
# 負け数
|
126
|
+
attr_reader :lose
|
127
|
+
# 引き分け
|
128
|
+
attr_reader :draw
|
129
|
+
|
130
|
+
attr :conf, true
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
#==ポジション
|
136
|
+
class Position
|
137
|
+
|
138
|
+
#売り/買い区分
|
139
|
+
SELL = 0
|
140
|
+
BUY = 1
|
141
|
+
|
142
|
+
#状態:注文中
|
143
|
+
STATE_WAITING = 0
|
144
|
+
#状態:新規
|
145
|
+
STATE_START = 1
|
146
|
+
#状態:決済注文中
|
147
|
+
STATE_FIX_WAITING = 2
|
148
|
+
#状態:決済済み
|
149
|
+
STATE_FIXED = 3
|
150
|
+
#状態:約定前にシステムが再起動された
|
151
|
+
STATE_LOST = 4
|
152
|
+
|
153
|
+
#===コンストラクタ
|
154
|
+
#
|
155
|
+
#*sell_or_buy*:: 売りor買い
|
156
|
+
#*count*:: 数量
|
157
|
+
#*unit*:: 取引単位
|
158
|
+
#*date*:: 取引日時
|
159
|
+
#*rate*:: レート
|
160
|
+
#*pair*:: 通貨ペア
|
161
|
+
#*trader*:: 取引実行者
|
162
|
+
#*operator*:: operator
|
163
|
+
#*open_interest_no*:: 建玉番号
|
164
|
+
#*order_no*:: 注文番号
|
165
|
+
def initialize( position_id, sell_or_buy, count, unit, date, rate, pair,
|
166
|
+
trader, operator, open_interest_no="", order_no="" )
|
167
|
+
@position_id = position_id
|
168
|
+
@sell_or_buy = sell_or_buy
|
169
|
+
@count = count
|
170
|
+
@unit = unit
|
171
|
+
@price = (count*unit*rate).to_i
|
172
|
+
@date = date
|
173
|
+
@profit_or_loss = 0
|
174
|
+
@state =STATE_START
|
175
|
+
@rate = rate
|
176
|
+
@pair = pair
|
177
|
+
@trader = trader
|
178
|
+
|
179
|
+
@open_interest_no = open_interest_no
|
180
|
+
@order_no = order_no
|
181
|
+
|
182
|
+
@operator = operator
|
183
|
+
@info = {}
|
184
|
+
@swap = 0
|
185
|
+
@swap_time = Time.local( date.year, \
|
186
|
+
date.month, date.day, operator.conf.get([:swap_time], 5 ))
|
187
|
+
@swap_time += 60*60*24 if date > @swap_time
|
188
|
+
end
|
189
|
+
|
190
|
+
def _commit
|
191
|
+
raise "illegal state" if @state != STATE_START
|
192
|
+
@state = STATE_FIXED
|
193
|
+
@fix_date = @current_date
|
194
|
+
@fix_rate = @current_rate
|
195
|
+
end
|
196
|
+
|
197
|
+
def lost
|
198
|
+
@state = STATE_LOST
|
199
|
+
end
|
200
|
+
|
201
|
+
#===現在価格を更新
|
202
|
+
def next(rates)
|
203
|
+
return if @state == STATE_FIXED
|
204
|
+
rate = rates[@pair]
|
205
|
+
@current_rate = @sell_or_buy == BUY ? rate.bid : rate.ask
|
206
|
+
@current_price = (@count * @unit * @current_rate).to_i
|
207
|
+
|
208
|
+
# swap
|
209
|
+
if @swap_time <= rates.time
|
210
|
+
@swap += @sell_or_buy == BUY ? rate.buy_swap : rate.sell_swap
|
211
|
+
@swap_time += 60*60*24
|
212
|
+
end
|
213
|
+
|
214
|
+
@profit_or_loss = @sell_or_buy == BUY \
|
215
|
+
? @current_price - @price + @swap\
|
216
|
+
: @price - @current_price + @swap
|
217
|
+
|
218
|
+
@current_date = rates.time
|
219
|
+
end
|
220
|
+
|
221
|
+
def [](key)
|
222
|
+
@info[key]
|
223
|
+
end
|
224
|
+
def []=(key, value)
|
225
|
+
@info[key] = value
|
226
|
+
end
|
227
|
+
|
228
|
+
def values
|
229
|
+
{
|
230
|
+
:position_id => position_id,
|
231
|
+
:open_interest_no=> open_interest_no,
|
232
|
+
:sell_or_buy => sell_or_buy == JIJI::Position::SELL ? :sell : :buy,
|
233
|
+
:state => state,
|
234
|
+
:date => date.to_i,
|
235
|
+
:fix_date => fix_date.to_i,
|
236
|
+
:count => count ,
|
237
|
+
:price => price,
|
238
|
+
:profit_or_loss => profit_or_loss.to_i,
|
239
|
+
:rate => rate,
|
240
|
+
:fix_rate => fix_rate,
|
241
|
+
:swap=> swap,
|
242
|
+
:pair => pair,
|
243
|
+
:trader => trader
|
244
|
+
}
|
245
|
+
end
|
246
|
+
|
247
|
+
# クライアント
|
248
|
+
attr :operator
|
249
|
+
# 建玉番号
|
250
|
+
attr :open_interest_no, true
|
251
|
+
# 注文番号
|
252
|
+
attr :order_no, true
|
253
|
+
|
254
|
+
# 一意な識別子
|
255
|
+
attr_reader :position_id
|
256
|
+
# 売りか買いか?
|
257
|
+
attr_reader :sell_or_buy
|
258
|
+
# 状態
|
259
|
+
attr_reader :state
|
260
|
+
|
261
|
+
# 購入日時
|
262
|
+
attr_reader :date
|
263
|
+
# 決済日時
|
264
|
+
attr_reader :fix_date
|
265
|
+
# 取引数量
|
266
|
+
attr_reader :count
|
267
|
+
# 取得金額
|
268
|
+
attr_reader :price
|
269
|
+
# 現在価値
|
270
|
+
attr_reader :current_price
|
271
|
+
# 現在の損益
|
272
|
+
attr_reader :profit_or_loss
|
273
|
+
# 購入時のレート
|
274
|
+
attr_reader :rate
|
275
|
+
# 決済時のレート
|
276
|
+
attr_reader :fix_rate
|
277
|
+
# 決済時のレート
|
278
|
+
attr_reader :swap
|
279
|
+
# 通貨ペア
|
280
|
+
attr_reader :pair
|
281
|
+
# 取引実行者
|
282
|
+
attr_reader :trader
|
283
|
+
end
|
284
|
+
|
285
|
+
#==リアル取引用オペレーター
|
286
|
+
class RmtOperator < Operator
|
287
|
+
|
288
|
+
#===コンストラクタ
|
289
|
+
#*client*:: クライアント
|
290
|
+
#*logger*:: ロガー
|
291
|
+
#*money*:: 保証金
|
292
|
+
def initialize( client, logger, trade_result_dao, trade_enable=true, money=nil )
|
293
|
+
super(trade_result_dao,money)
|
294
|
+
@client = client
|
295
|
+
@logger = logger
|
296
|
+
@trade_enable = trade_enable
|
297
|
+
end
|
298
|
+
|
299
|
+
#===購入する
|
300
|
+
#*count*:: 購入する数量
|
301
|
+
#*return*:: Position
|
302
|
+
def buy(count, pair=:EURJPY, trader="")
|
303
|
+
open_interest_no = nil
|
304
|
+
order_no = nil
|
305
|
+
if @trade_enable
|
306
|
+
JIJI::Util.log_if_error_and_throw( @logger ) {
|
307
|
+
rate = @rate[pair]
|
308
|
+
# 成り行きで買い
|
309
|
+
result = @client.request{ |fx|
|
310
|
+
fx.order( JIJI::Util.convert_currency_pair_code_r(pair),
|
311
|
+
ClickClient::FX::BUY, count, options={:slippage_base_rate=>rate.bid} )
|
312
|
+
}
|
313
|
+
open_interest_no = result.open_interest_no
|
314
|
+
order_no = result.order_no
|
315
|
+
}
|
316
|
+
end
|
317
|
+
p = super(count, pair, trader)
|
318
|
+
p.open_interest_no = open_interest_no
|
319
|
+
p.order_no = order_no
|
320
|
+
p
|
321
|
+
end
|
322
|
+
|
323
|
+
#===売却する
|
324
|
+
#*count*:: 売却する数量
|
325
|
+
#*return*:: Position
|
326
|
+
def sell(count, pair=:EURJPY, trader="")
|
327
|
+
open_interest_no = nil
|
328
|
+
order_no = nil
|
329
|
+
if @trade_enable
|
330
|
+
JIJI::Util.log_if_error_and_throw( @logger ) {
|
331
|
+
rate = @rate[pair]
|
332
|
+
# 成り行きで売り
|
333
|
+
result = @client.request {|fx|
|
334
|
+
fx.order( JIJI::Util.convert_currency_pair_code_r(pair),
|
335
|
+
ClickClient::FX::SELL, count, options={:slippage_base_rate=>rate.ask} )
|
336
|
+
}
|
337
|
+
open_interest_no = result.open_interest_no
|
338
|
+
order_no = result.order_no
|
339
|
+
}
|
340
|
+
end
|
341
|
+
p = super(count, pair, trader)
|
342
|
+
p.open_interest_no = open_interest_no
|
343
|
+
p.order_no = order_no
|
344
|
+
p
|
345
|
+
end
|
346
|
+
|
347
|
+
# 取引を確定する
|
348
|
+
def commit(position)
|
349
|
+
if @trade_enable
|
350
|
+
JIJI::Util.log_if_error_and_throw( @logger ) {
|
351
|
+
@client.request {|fx|
|
352
|
+
fx.settle( position.open_interest_no, position.count )
|
353
|
+
}
|
354
|
+
}
|
355
|
+
end
|
356
|
+
super(position)
|
357
|
+
end
|
358
|
+
|
359
|
+
attr :trade_enable, true
|
360
|
+
end
|
361
|
+
|
362
|
+
# 各エージェントに設定されるオペレータ。
|
363
|
+
# 取引者としてエージェント名を指定して売り買いを行なう。
|
364
|
+
# また、建玉を独自に保持する。(エージェント間で共有されない)
|
365
|
+
# 売/買ロジック自体ははオペレータに委譲する。
|
366
|
+
class AgentOperator
|
367
|
+
def initialize( operator, agent_name )
|
368
|
+
@operator = operator
|
369
|
+
@name = agent_name
|
370
|
+
@positions = {}.taint
|
371
|
+
end
|
372
|
+
|
373
|
+
#===購入する
|
374
|
+
#count:: 購入する数量
|
375
|
+
#pair:: 通貨ペア
|
376
|
+
#return:: ポジション
|
377
|
+
def buy(count, pair=:EURJPY)
|
378
|
+
p = @operator.buy( count, pair, @name )
|
379
|
+
@positions[p.position_id] = p
|
380
|
+
return p
|
381
|
+
end
|
382
|
+
|
383
|
+
#===売却する
|
384
|
+
#count:: 売却する数量
|
385
|
+
#pair:: 通貨ペア
|
386
|
+
#return:: ポジション
|
387
|
+
def sell(count, pair=:EURJPY)
|
388
|
+
p = @operator.sell( count, pair, @name )
|
389
|
+
@positions[p.position_id] = p
|
390
|
+
return p
|
391
|
+
end
|
392
|
+
|
393
|
+
# 取引を確定する
|
394
|
+
def commit(position)
|
395
|
+
@operator.commit(position)
|
396
|
+
@positions.delete position.position_id
|
397
|
+
end
|
398
|
+
|
399
|
+
#建て玉
|
400
|
+
attr_reader :positions
|
401
|
+
|
402
|
+
end
|
403
|
+
|
404
|
+
end
|
405
|
+
|