Skip to content

Commit b22472d

Browse files
author
todd
committed
Merge remote-tracking branch 'robcarver17/master' into missing-data
2 parents d9f31ff + 404a215 commit b22472d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1158
-805
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Note that the large contract prices will continue to be updated (best to keep do
189189

190190
## Version 0.51.0
191191

192-
- Essentially 'finished' production.md (in as much as anything can be finished...)
192+
- Essentially 'close' production.md (in as much as anything can be close...)
193193
- Changed data Blobs so now take lists of objects rather than str, easier to see dependencies
194194

195195
## Version 0.50.0

docs/dashboard_and_monitor.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Once your machine has started you should be able to go to `http://192.168.1.13:8
4646

4747
# Handling of crashed processes
4848

49-
Whilst running the monitor and dashboard will also handle any 'crashed' processes (those where the PID that is registered is killed without the process being properly finished); it will email the user, update the web log, and mark the process as finished so it can be run again. **It will not automatically respawn the processes!** (you will have to do that manually or wait until the crontab does so the next day).
49+
Whilst running the monitor and dashboard will also handle any 'crashed' processes (those where the PID that is registered is killed without the process being properly close); it will email the user, update the web log, and mark the process as close so it can be run again. **It will not automatically respawn the processes!** (you will have to do that manually or wait until the crontab does so the next day).
5050

5151
# Running a remote dashboard or monitor
5252

docs/production.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ Table of Contents
135135
* [View processes](#view-processes)
136136
* [Change status of process](#change-status-of-process)
137137
* [Global status change](#global-status-change)
138-
* [Mark as finished](#mark-as-finished)
139-
* [Mark all dead processes as finished](#mark-all-dead-processes-as-finished)
138+
* [Mark as close](#mark-as-finished)
139+
* [Mark all dead processes as close](#mark-all-dead-processes-as-finished)
140140
* [View process configuration](#view-process-configuration)
141141
* [Update configuration](#update-configuration)
142142
* [Interactive diagnostics](#interactive-diagnostics)
@@ -301,7 +301,7 @@ Before trading, and each time you restart the machine you should:
301301

302302
- [check a mongodb server is running with the right data directory](/docs/data.md#mongo-db) command line: `mongod --dbpath $MONGO_DATA` (the supplied crontab should do this)
303303
- launch an IB gateway (this could [be done automatically](https://github.com/IbcAlpha/IBC) depending on your security setup)
304-
- ensure all processes are [marked as 'finished'](#mark-as-finished)
304+
- ensure all processes are [marked as 'close'](#mark-as-finished)
305305

306306
Note that the system won't start trading until the next day, unless you manually launch the processes that would ordinarily have been started by the crontab or other [scheduler](#scheduling). [Linux screen](https://linuxize.com/post/how-to-use-linux-screen/) is helpful if you want to launch a process but not keep the window active (eg on a headless machine).
307307

@@ -1204,7 +1204,7 @@ Well the stack handler code regularly runs the method sysexecution/stack_handler
12041204
- first we look in the cached set of broker orders and control objects, that should include any orders made in this session (but that won't work if the order was done somewhere else, eg by interactive_order_stack). Remember that this was indexed by broker_tempid.
12051205
- if that fails then we get the orders and control objects actually from the broker.
12061206
- Again first we look for orders with the same broker_tempid (i.e. from the same account, clientid and with the same IB orderId).
1207-
- If that fails we look for an order with the same permid. This will work as long as the original broker order in the database got a permid before the stack handler had finished the original (failed?) execution process.
1207+
- If that fails we look for an order with the same permid. This will work as long as the original broker order in the database got a permid before the stack handler had close the original (failed?) execution process.
12081208
- if that fails we're buggered and we need to enter the fill manually using interactive_order_stack. Most likely this will happen if more than 24 hours passes after the order was executed, since IB only returns recent orders from it's API
12091209

12101210

@@ -1934,9 +1934,9 @@ Note that processes that have launched but waiting to properly start (perhaps be
19341934

19351935
##### Change status of process
19361936

1937-
You can change the status of any process to STOP, GO or NO RUN. A process which is NO RUN will continue running, but won't start again. This is the correct way to stop processes that you want to kill, as it will properly update their process state and (importantly in the case of run stack handler) do a graceful exit. Stop processes will only stop once they have finished running their current method, which means for run_systems and run_strategy_order_generator they will stop when the current strategy has finished processing (which can take a while!).
1937+
You can change the status of any process to STOP, GO or NO RUN. A process which is NO RUN will continue running, but won't start again. This is the correct way to stop processes that you want to kill, as it will properly update their process state and (importantly in the case of run stack handler) do a graceful exit. Stop processes will only stop once they have close running their current method, which means for run_systems and run_strategy_order_generator they will stop when the current strategy has close processing (which can take a while!).
19381938

1939-
If a process refuses to STOP, then as a last resort you can use `kill NNNN` at the command line where NNNN is the PID, but there may be data corruption, or weird behaviour (particularly if you do this with the stack handler), and you will definitely need to mark it as finished (see below).
1939+
If a process refuses to STOP, then as a last resort you can use `kill NNNN` at the command line where NNNN is the PID, but there may be data corruption, or weird behaviour (particularly if you do this with the stack handler), and you will definitely need to mark it as close (see below).
19401940

19411941
Marking a process as START won't actually launch it, you will have to do this manually or wait for the crontab to run it. Nor will the process run if it's preconditions aren't met (start and end time window, previous process).
19421942

@@ -1945,15 +1945,15 @@ Marking a process as START won't actually launch it, you will have to do this ma
19451945
Sometimes you might want to mark all processes as STOP (emergency shut down?) or GO (post emergency restart).
19461946

19471947

1948-
##### Mark as finished
1948+
##### Mark as close
19491949

1950-
This will manually mark a process as finished. This is done automatically when a process finishes normally, or is told to stop, but if it terminates unexpectedly then the status may well be set as 'running', which means a new version of the process can't be launched until this flag is cleared. Marking a process as finished won't stop it if it is still running! Use 'change status' instead. Check the process PID isn't running using `ps aux | grep NNNNN` where NNNN is the PID, before marking it as finished.
1950+
This will manually mark a process as close. This is done automatically when a process finishes normally, or is told to stop, but if it terminates unexpectedly then the status may well be set as 'running', which means a new version of the process can't be launched until this flag is cleared. Marking a process as close won't stop it if it is still running! Use 'change status' instead. Check the process PID isn't running using `ps aux | grep NNNNN` where NNNN is the PID, before marking it as close.
19511951

1952-
Note that the startup script will also mark all processes as finished (as there should be no processes running on startup). Also if you run the next option ('mark all dead processes as finished') this will be automatic.
1952+
Note that the startup script will also mark all processes as close (as there should be no processes running on startup). Also if you run the next option ('mark all dead processes as close') this will be automatic.
19531953

1954-
##### Mark all dead processes as finished
1954+
##### Mark all dead processes as close
19551955

1956-
This will check to see if a process PID is active, and if not it will mark a process as finished, assumed crashed. This is also done periodically by the [system monitor and/or dashboard](/docs/dashboard_and_monitor.md), if running.
1956+
This will check to see if a process PID is active, and if not it will mark a process as close, assumed crashed. This is also done periodically by the [system monitor and/or dashboard](/docs/dashboard_and_monitor.md), if running.
19571957

19581958
##### View process configuration
19591959

@@ -2199,7 +2199,7 @@ If the broker API has gone crazy or died for some reason then all instruments wi
21992199

22002200
##### Remove Algo lock on contract order
22012201

2202-
When an algo begins executing a contract order (in part or in full), it locks it. That lock is released when the order has finished executing. If the stack handler crashes before that can happen, then no other algo can execute it. Although the order will be deleted in the normal end of day stack clean up, if you can't wait that long you can manually clear the problem.
2202+
When an algo begins executing a contract order (in part or in full), it locks it. That lock is released when the order has close executing. If the stack handler crashes before that can happen, then no other algo can execute it. Although the order will be deleted in the normal end of day stack clean up, if you can't wait that long you can manually clear the problem.
22032203

22042204

22052205
#### Delete and clean
@@ -2378,7 +2378,7 @@ Linux script:
23782378
There is some housekeeping to do when a machine starts up, primarily in case it crashed and did not close everything gracefully:
23792379

23802380
- Clear IB client IDs: Do this when the machine restarts and IB is definitely not running (or we'll eventually run out of IDs)
2381-
- Mark all running processes as finished
2381+
- Mark all running processes as close
23822382

23832383
## Scripts under other (non-linux) operating systems
23842384

@@ -2471,7 +2471,7 @@ The scheduler built into pysystemtrade does not launch processes (this is still
24712471

24722472
- Record when processes have started and stopped, if they are still running, and what their process ID is.
24732473
- Run only in a specified time window (start time, end time)
2474-
- Run only when another process has already finished (i.e. do not run_systems until prices have been updated)
2474+
- Run only when another process has already close (i.e. do not run_systems until prices have been updated)
24752475
- Allow interactive_controls to STOP processes, or prevent them from starting.
24762476
- Call 'methods', which are effectively sub processes, multiple times (up to a specified limit) and at specified time intervals (if required).
24772477
- Provides a monitoring tool which can also be used from a remote machine
@@ -2526,7 +2526,7 @@ process_configuration_previous_process:
25262526
run_strategy_order_generator: 'run_systems' # will be no orders to generate until backtest system has run
25272527
run_cleaners: 'run_strategy_order_generator' # wait until the main 'big 3' daily processes have run before tidying up
25282528
run_backups: 'run_cleaners' # this can take a while, will be less stuff to back up if we've already cleaned
2529-
run_reports: 'run_strategy_order_generator' # will be more interesting reports if we run after other stuff has finished
2529+
run_reports: 'run_strategy_order_generator' # will be more interesting reports if we run after other stuff has close
25302530
25312531
```
25322532

@@ -2644,14 +2644,14 @@ Why won't my process run?
26442644
- is it set to STOP or DONT RUN? Fix with interactive_controls
26452645
- is it before the start_time? Change the start time, or wait
26462646
- is it after the end_time? Change the end time, or wait until tommorrow
2647-
- has the previous process finished? Wait, or remove dependency
2648-
- is it already running, or at least thinks it is already running because a previous iteration didn't fail? Mark the process as finished with interactive_controls
2647+
- has the previous process close? Wait, or remove dependency
2648+
- is it already running, or at least thinks it is already running because a previous iteration didn't fail? Mark the process as close with interactive_controls
26492649

26502650
Why has my process stopped?
26512651

26522652
- is it set to STOP?
26532653
- is it after the end_time?
2654-
- have all the methods finished running, because they have exceeded their `max_executions`?
2654+
- have all the methods close running, because they have exceeded their `max_executions`?
26552655

26562656
Why won't my method run?
26572657

@@ -3182,7 +3182,7 @@ KRWUSD 2020-10-19 23:00:00
31823182
31833183
31843184
"Optimal positions are generated by the backtest that runs daily; this hasn't
3185-
quite finished yet hence these are from the previous friday."
3185+
quite close yet hence these are from the previous friday."
31863186
31873187
=====================================================
31883188
Status of optimal position generation

sysbrokers/IB/ib_instruments_data.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,15 @@ def get_instrument_object_from_config(
173173
config_row = config[config.Instrument == instrument_code]
174174
symbol = config_row.IBSymbol.values[0]
175175
exchange = config_row.IBExchange.values[0]
176-
currency = return_another_value_if_nan(config_row.IBCurrency.values[0], NOT_REQUIRED_FOR_IB)
176+
currency = return_another_value_if_nan(
177+
config_row.IBCurrency.values[0], NOT_REQUIRED_FOR_IB
178+
)
177179
ib_multiplier = return_another_value_if_nan(
178180
config_row.IBMultiplier.values[0], NOT_REQUIRED_FOR_IB
179181
)
180-
price_magnifier = return_another_value_if_nan(config_row.priceMagnifier.values[0], 1.0)
182+
price_magnifier = return_another_value_if_nan(
183+
config_row.priceMagnifier.values[0], 1.0
184+
)
181185
ignore_weekly = config_row.IgnoreWeekly.values[0]
182186

183187
# We use the flexibility of futuresInstrument to add additional arguments

syscontrol/run_process.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ def _finish_control_process(self):
135135

136136
if result_of_finish is failure:
137137
self.log.warn(
138-
"Process %s won't finish in process control as already finished: weird!"
138+
"Process %s won't finish in process control as already close: weird!"
139139
% self.process_name
140140
)
141141
elif result_of_finish is success:
142-
self.log.msg("Process control %s marked finished" % self.process_name)
142+
self.log.msg("Process control %s marked close" % self.process_name)
143143

144144

145145
### STARTUP CODE

syscore/genutils.py

+24
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def get_unique_list(somelist: list) -> list:
7171
return list(set(somelist))
7272

7373

74+
def get_unique_list_slow(somelist):
75+
uniquelist = []
76+
77+
for somevalue in somelist:
78+
if somevalue not in uniquelist:
79+
uniquelist.append(somevalue)
80+
81+
return uniquelist
82+
83+
7484
def round_significant_figures(x: float, figures: int = 3) -> float:
7585
"""
7686
>>> round_significant_figures(0.0234, 2)
@@ -240,6 +250,13 @@ def if_object_matches_return_empty_string(x, object_to_match):
240250
return x
241251

242252

253+
"""
254+
255+
NAMED TUPLES AND OBJECTS
256+
257+
"""
258+
259+
243260
def transfer_object_attributes(named_tuple_object, original_object):
244261
kwargs = dict(
245262
[
@@ -252,6 +269,13 @@ def transfer_object_attributes(named_tuple_object, original_object):
252269
return new_object
253270

254271

272+
"""
273+
274+
COMMON FACTORS
275+
276+
"""
277+
278+
255279
def highest_common_factor_for_list(list_of_ints: List[int]) -> int:
256280
"""
257281

0 commit comments

Comments
 (0)