-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V0.2 fin alpha for review #170
Conversation
* prototype finance scenario * runnable finance demo * update for pylint * update for pylint * update for pylint * refactoring finance scenario part1 * part2 * part 3 * part 4 * remove unused code * remove not used file * update name * update for lint * update for lint
maro/simulator/scenarios/finance/sub_engines/stock/stock_business_engine.py
Outdated
Show resolved
Hide resolved
maro/simulator/scenarios/finance/sub_engines/stock/stock_business_engine.py
Outdated
Show resolved
Hide resolved
maro/simulator/scenarios/finance/sub_engines/stock/stock_business_engine.py
Outdated
Show resolved
Hide resolved
maro/simulator/scenarios/finance/sub_engines/stock/stock_business_engine.py
Outdated
Show resolved
Hide resolved
if order_action.number < 0: | ||
order_direction = -1 | ||
actual_price = deal_price * (1 + self.__slippage_rate * order_direction / 2) | ||
return actual_price |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return the price delta instead of price in Slippage. Modify the code using slippage respectively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still using price, can discuss
* prototype finance scenario * runnable finance demo * update for pylint * update for pylint * update for pylint * refactoring finance scenario part1 * part2 * part 3 * part 4 * remove unused code * remove not used file * update name * update for lint * update for lint * V0.2 rl toolkit refinement (#165) * refined rl abstractions * fixed formattin issues * checked out error-code related code from v0.2_pg * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * fixed a bug * renamed save_models to dump_models * 1. set default batch_norm_enabled to True; 2. used state_dict in dqn model saving * renamed dump_experience_store to dump_experience_pool * fixed a bug in the dump_experience_pool method * fixed some PR comments * fixed more PR comments * 1.fixed some PR comments; 2.added early_stopping_checker; 3.revised explorer class * fixed cim example according to rl toolkit changes * fixed some more PR comments * rewrote multi_process_launcher to eliminate the distributed section in config * 1. fixed a typo; 2. added logging before early stopping * fixed a bug * fixed a bug * fixed a bug * added early stopping feature to CIM exmaple * fixed a typo * fixed some issues with early stopping * changed early stopping metric func * fixed a bug * fixed a bug * added early stopping to dist mode cim * added experience collecting func * edited notebook according to changes in CIM example * fixed bugs in nb * fixed lint formatting issues * fixed a typo * fixed some PR comments * fixed more PR comments * revised docs * removed nb output * fixed a bug in simple_learner * fixed a typo in nb * fixed a bug * fixed a bug * fixed a bug * removed unused import * fixed a bug * 1. changed early stopping default config; 2. renamed param in early stopping checker and added typing * fixed some doc issues * added output to nb Co-authored-by: ysqyang <v-yangqi@microsoft.com> * finance business engine refine ver1 * day trading * remove not used files * refine cancel order * fix cancel order * add split trade support * fix split trade * remove not used file * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint Co-authored-by: ysqyang <ysqyang@gmail.com> Co-authored-by: ysqyang <v-yangqi@microsoft.com>
Codecov Report
@@ Coverage Diff @@
## v0.2 #170 +/- ##
==========================================
- Coverage 71.36% 71.23% -0.13%
==========================================
Files 89 89
Lines 4190 4203 +13
==========================================
+ Hits 2990 2994 +4
- Misses 1200 1209 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
To simulate real markets, we implement the typical order types, cost of the trading. | ||
|
||
A typical trading process is: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid image path
* prototype finance scenario * runnable finance demo * update for pylint * update for pylint * update for pylint * refactoring finance scenario part1 * part2 * part 3 * part 4 * remove unused code * remove not used file * update name * update for lint * update for lint * finance business engine refine ver1 * day trading * remove not used files * refine cancel order * fix cancel order * add split trade support * fix split trade * remove not used file * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint * update for comments * update for lint * update for lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty file? remaining TODO?
misoperation, skip this |
self._event_buffer.insert_event(evt) | ||
|
||
def post_step(self, tick: int): | ||
if (not self._conf["trade_constraint"]["allow_day_trade"]) and self.is_market_closed(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add detail comment for this part. Why we add holding_quantity here, and how we make sure the operation is valid.
if direction == OrderDirection.buy: | ||
money_needed = executing_price * executing_volume + executing_commission + executing_tax | ||
ret = ret - math.ceil( | ||
(money_needed - remaining_money) / (executing_price * self._conf["trade_constraint"]["min_buy_unit"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we initialize
self._min_buy_unit = self._conf["trade_constraint"]["min_buy_unit"]
in self._init()?
or using other meaning name
|
||
return DocableDict( | ||
metrics_desc, | ||
operation_number=len(self._finished_action) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have more discussion about the metrics with Arthur together.
Fulfill the pr description, such as data source, feature list, etc. |
why we need the 0000X.bin, we never host data, if it was test purpose, just keep one, and mv it to maro/tests/data/finance or maro/tests/data/stock |
|
||
class CommissionType(Enum): | ||
no_commission = 0 | ||
stamp_tax_commission = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since there are both tax
and commission
in TradeResult
, they are 2 types of cost? But here the stamp_tax_commission
belongs to commission
?
|
||
class SlippageType(Enum): | ||
# TODO: zhanyu add correct slippage | ||
no_slippage = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if currently only by_money is available, remove the others from the Type.
Or, add them but throw NotImplementationError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
def __init__(self, min_fee): | ||
self.min_fee = min_fee | ||
|
||
def execute(self, direction: OrderDirection, actual_price: float, actual_volume: int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absmethod?
* prototype finance scenario * runnable finance demo * update for pylint * update for pylint * update for pylint * refactoring finance scenario part1 * part2 * part 3 * part 4 * remove unused code * remove not used file * update name * update for lint * update for lint * finance business engine refine ver1 * day trading * remove not used files * refine cancel order * fix cancel order * add split trade support * fix split trade * remove not used file * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint * update for comments * update for lint * update for lint * update for comments * update for comments part 1 * update for comments * update for comments part2 * update for lint * add help function for convert start tick * update for lint * remove not used import
* prototype finance scenario * runnable finance demo * update for pylint * update for pylint * update for pylint * refactoring finance scenario part1 * part2 * part 3 * part 4 * remove unused code * remove not used file * update name * update for lint * update for lint * finance business engine refine ver1 * day trading * remove not used files * refine cancel order * fix cancel order * add split trade support * fix split trade * remove not used file * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint * update for lint * update for comments * update for lint * update for lint * update for comments * update for comments part 1 * update for comments * fixed a bug in learner's test() (#193) Co-authored-by: ysqyang <v-yangqi@microsoft.com> * V0.2 double dqn (#188) * added dueling action value model * renamed params in dueling_action_value_model * renamed shared_features to features * replaced IdentityLayers with nn.Identity * 1. added skip connection option in FC_net; 2. generalized learning model * added skip_connection option in config * removed type casting in fc_net * fixed lint formatting issues * refined docstring * mv dueling_actiovalue_model and fixed some bugs * added multi-head functionality to LearningModel * refined learning model docstring * added head_key param in learningModel forward * added double DQN and dueling features to DQN * fixed a bug * added DuelingQModelHead enum * fixed a bug * removed unwanted file * fixed PR comments * added top layer logic and is_top option in fc_net * fixed a bug * fixed a bug * reverted some changes in learning model * reverted some changes in learning model * added members to learning model to fix the mode issue * fixed a bug * fixed mode setting issue in learning model * fixed PR comments * revised cim example according to DQN changes * renamed eval_model to q_value_model in cim example * more fixes * fixed a bug * fixed a bug * added doc per PR comments * removed learner.exit() in single_process_launcher * removed learner.exit() in single_process_launcher * fixed PR comments * fixed rl/__init__ * fixed issues in example * fixed a bug * fixed a bug * fixed lint formatting issues * double DQN feature * fixed a bug * fixed a bug * fixed PR comments * fixed lint issue * 1. fixed PR comments related to load/dump; 2. removed abstract load/dump methods from AbsAlgorithm * added load_models in simple_learner * minor docstring edits * minor docstring edits * set is_double to true in DQN config Co-authored-by: ysqyang <v-yangqi@microsoft.com> Co-authored-by: Arthur Jiang <ArthurSJiang@gmail.com> * update for comments part2 * V0.2 feature predefined image (#183) * feat: support predefined image provision * style: fix linting errors * style: fix linting errors * style: fix linting errors * style: fix linting errors * fix: error scripts invocation after using relative import * fix: missing init.py * fixed a bug in learner's test() * feat: add distributed_config for dqn example * test: update test for grass * test: update test for k8s * feat: add promptings for steps * fix: change relative imports to absolute imports Co-authored-by: ysqyang <v-yangqi@microsoft.com> Co-authored-by: Arthur Jiang <ArthurSJiang@gmail.com> * update for lint * add help function for convert start tick * update for lint * remove not used import * update for review comments 11.17 * refine code for review 11.18 * V0.2 feature proxy rejoin (#158) * update dist decorator * replace proxy.get_peers by proxy.peers * update proxy rejoin (draft, not runable for proxy rejoin) * fix bugs in proxy * add message cache, and redesign rejoin parameter * feat: add checkpoint with test * update proxy.rejoin * fixed rejoin bug, rename func * add test example(temp) * feat: add FaultToleranceAgent, refine other MasterAgents and NodeAgents. * capital env vari name * rm json.dumps; change retries to 10; temp add warning level for rejoin * fix: unable to load FaultToleranceAgent, missing params * fix: delete mapping in StopJob if FaultTolerance is activated, add exception handler for FaultToleranceAgent * feat: add node_id to node_details * fix: add a new dependency for tests * style: meet linting requirements * style: remaining linting problems * lint fixed; rm temp test folder. * fixed lint f-string without placeholder * fix: add a flag for "remove_container", refine restart logic and Redis keys naming * proxy rejoin update. * variable rename. * fixed lint issues * fixed lint issues * add exit code for different error * feat: add special errors handler * add max rejoin times * remove unused import * add rejoin UT; resolve rejoin comments * lint fixed * fixed UT import problem * rm MessageCache in proxy * fix: refine key naming * update proxy rejoin; add topic for broadcast * feat: support predefined image provision * update UT for communication * add docstring for rejoin * fixed isort and zmq driver import * fixed isort and UT test * fix isort issue * proxy rejoin update (comments v2) * fixed isort error * style: fix linting errors * style: fix linting errors * style: fix linting errors * style: fix linting errors * feat: add exists method for checkpoint * fix: error scripts invocation after using relative import * fix: missing init.py * fixed a bug in learner's test() * add driver close and socket SUB disconnect for rejoin * feat: add distributed_config for dqn example * test: update test for grass * test: update test for k8s * feat: add promptings for steps * fix: change relative imports to absolute imports * fixed comments and update logger level * mv driver in proxy.__init__ for issue temp fixed. * Update docstring and comments * style: fix code reviews problems * fix code format Co-authored-by: Lyuchun Huang <romic.kid@gmail.com> Co-authored-by: ysqyang <v-yangqi@microsoft.com> * update for review comments 11.18 part 2 * update for review comments 11.18 part3 * remove unfinished code * update for lint Co-authored-by: ysqyang <ysqyang@gmail.com> Co-authored-by: ysqyang <v-yangqi@microsoft.com> Co-authored-by: Arthur Jiang <ArthurSJiang@gmail.com> Co-authored-by: Romic Huang <romic.kid@gmail.com> Co-authored-by: kaiqli <59279714+kaiqli@users.noreply.github.com>
Reopen or create a new one when it is ready |
Description
alpha version of finance scenario
Linked issue(s)/Pull request(s)
Type of Change
Related Component
Has Been Tested
Needs Follow Up Actions
Checklist