Drop global order lines map
Orders in order mode should be chart oriented since there's a mode per chart. If you want all orders just ask the ems or query all the charts in a loop. This fixes cancel-all-orders such that when 'cc' is tapped only the orders on the *current* chart are cancelled, lel.backup_asyncify_input_modes
							parent
							
								
									97a55156ed
								
							
						
					
					
						commit
						3a041e4f47
					
				| 
						 | 
				
			
			@ -1561,6 +1561,12 @@ async def display_symbol_data(
 | 
			
		|||
    # historical data fetch
 | 
			
		||||
    brokermod = brokers.get_brokermod(provider)
 | 
			
		||||
 | 
			
		||||
    # ohlc_status_done = sbar.open_status(
 | 
			
		||||
    #     'retreiving OHLC history.. ',
 | 
			
		||||
    #     clear_on_next=True,
 | 
			
		||||
    #     group_key=loading_sym_key,
 | 
			
		||||
    # )
 | 
			
		||||
 | 
			
		||||
    async with(
 | 
			
		||||
 | 
			
		||||
        data.open_feed(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,22 +86,14 @@ class ArrowEditor:
 | 
			
		|||
        self.chart.plotItem.removeItem(arrow)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# global store of order-lines graphics
 | 
			
		||||
# keyed by uuid4 strs - used to sync draw
 | 
			
		||||
# order lines **after** the order is 100%
 | 
			
		||||
# active in emsd
 | 
			
		||||
_order_lines: dict[str, LevelLine] = {}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@dataclass
 | 
			
		||||
class LineEditor:
 | 
			
		||||
    '''The great editor of linez.
 | 
			
		||||
 | 
			
		||||
    '''
 | 
			
		||||
    _order_lines: field(default_factory=_order_lines)
 | 
			
		||||
    chart: 'ChartPlotWidget' = None  # type: ignore # noqa
 | 
			
		||||
    _order_lines: dict[str, LevelLine] = field(default_factory=dict)
 | 
			
		||||
    _active_staged_line: LevelLine = None
 | 
			
		||||
    _stage_line: LevelLine = None
 | 
			
		||||
 | 
			
		||||
    def stage_line(
 | 
			
		||||
        self,
 | 
			
		||||
| 
						 | 
				
			
			@ -128,8 +120,6 @@ class LineEditor:
 | 
			
		|||
 | 
			
		||||
        symbol = chart._lc.symbol
 | 
			
		||||
 | 
			
		||||
        # line = self._stage_line
 | 
			
		||||
        # if not line:
 | 
			
		||||
        # add a "staged" cursor-tracking line to view
 | 
			
		||||
        # and cash it in a a var
 | 
			
		||||
        if self._active_staged_line:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ from pydantic import BaseModel
 | 
			
		|||
import trio
 | 
			
		||||
 | 
			
		||||
from ._graphics._lines import LevelLine, position_line
 | 
			
		||||
from ._editors import LineEditor, ArrowEditor, _order_lines
 | 
			
		||||
from ._editors import LineEditor, ArrowEditor
 | 
			
		||||
from ._window import MultiStatus, main_window
 | 
			
		||||
from ..clearing._client import open_ems, OrderBook
 | 
			
		||||
from ..data._source import Symbol
 | 
			
		||||
| 
						 | 
				
			
			@ -54,6 +54,8 @@ class OrderMode:
 | 
			
		|||
    This is the default mode that pairs with "follow mode"
 | 
			
		||||
    (when wathing the rt price update at the current time step)
 | 
			
		||||
    and allows entering orders using mouse and keyboard.
 | 
			
		||||
    This object is chart oriented, so there is an instance per
 | 
			
		||||
    chart / view currently.
 | 
			
		||||
 | 
			
		||||
    Current manual:
 | 
			
		||||
        a -> alert
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +72,7 @@ class OrderMode:
 | 
			
		|||
    lines: LineEditor
 | 
			
		||||
    arrows: ArrowEditor
 | 
			
		||||
    status_bar: MultiStatus
 | 
			
		||||
    name: str = 'order'
 | 
			
		||||
 | 
			
		||||
    _colors = {
 | 
			
		||||
        'alert': 'alert_yellow',
 | 
			
		||||
| 
						 | 
				
			
			@ -290,6 +293,9 @@ class OrderMode:
 | 
			
		|||
        )
 | 
			
		||||
 | 
			
		||||
    def cancel_all_orders(self) -> list[str]:
 | 
			
		||||
        '''Cancel all orders for the current chart.
 | 
			
		||||
 | 
			
		||||
        '''
 | 
			
		||||
        return self.cancel_orders_from_lines(
 | 
			
		||||
            self.lines.all_lines()
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			@ -355,7 +361,7 @@ async def open_order_mode(
 | 
			
		|||
):
 | 
			
		||||
    status_bar: MultiStatus = main_window().status_bar
 | 
			
		||||
    view = chart._vb
 | 
			
		||||
    lines = LineEditor(chart=chart, _order_lines=_order_lines)
 | 
			
		||||
    lines = LineEditor(chart=chart)
 | 
			
		||||
    arrows = ArrowEditor(chart, {})
 | 
			
		||||
 | 
			
		||||
    log.info("Opening order mode")
 | 
			
		||||
| 
						 | 
				
			
			@ -400,7 +406,7 @@ async def start_order_mode(
 | 
			
		|||
      - begin order handling loop
 | 
			
		||||
 | 
			
		||||
    '''
 | 
			
		||||
    done = chart.window().status_bar.open_status('Starting order mode...')
 | 
			
		||||
    done = chart.window().status_bar.open_status('starting order mode..')
 | 
			
		||||
 | 
			
		||||
    # spawn EMS actor-service
 | 
			
		||||
    async with (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue