Convert symbol type to use pydantic

basic_orders
Tyler Goodlet 2021-02-06 14:38:00 -05:00
parent 0c184b1b41
commit c3fa31e731
2 changed files with 8 additions and 9 deletions

View File

@ -272,9 +272,10 @@ async def open_feed(
for sym, data in init_msg.items(): for sym, data in init_msg.items():
si = data['symbol_info'] si = data['symbol_info']
symbol = Symbol( symbol = Symbol(
sym, key=sym,
min_tick=si.get('minTick', 0.01), tick_size=si.get('price_tick_size', 0.01),
) )
symbol.broker_info[brokername] = si symbol.broker_info[brokername] = si

View File

@ -19,10 +19,10 @@ numpy data source coversion helpers.
""" """
from typing import Dict, Any, List from typing import Dict, Any, List
import decimal import decimal
from dataclasses import dataclass, field
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from pydantic import BaseModel
# from numba import from_dtype # from numba import from_dtype
@ -75,18 +75,16 @@ def ohlc_zeros(length: int) -> np.ndarray:
return np.zeros(length, dtype=base_ohlc_dtype) return np.zeros(length, dtype=base_ohlc_dtype)
@dataclass class Symbol(BaseModel):
class Symbol:
"""I guess this is some kinda container thing for dealing with """I guess this is some kinda container thing for dealing with
all the different meta-data formats from brokers? all the different meta-data formats from brokers?
Yah, i guess dats what it izz. Yah, i guess dats what it izz.
""" """
key: str = '' key: str
tick_size: float = 0.01 tick_size: float = 0.01
v_tick_size: float = 0.01 lot_tick_size: float = 0.01 # "volume" precision as min step value
broker_info: Dict[str, Dict[str, Any]] = field(default_factory=dict) broker_info: Dict[str, Dict[str, Any]] = {}
deriv: str = ''
@property @property
def brokers(self) -> List[str]: def brokers(self) -> List[str]: