pymmdrza commited on
Commit
6c0f809
·
verified ·
1 Parent(s): c91aea2

Update models/market_data.py

Browse files
Files changed (1) hide show
  1. models/market_data.py +9 -12
models/market_data.py CHANGED
@@ -4,7 +4,7 @@ from pydantic import BaseModel, Field
4
 
5
 
6
  class KlineData(BaseModel):
7
- timestamp: int
8
  open: float
9
  high: float
10
  low: float
@@ -34,13 +34,10 @@ class MarketData(BaseModel):
34
 
35
  @classmethod
36
  def from_kucoin_response(
37
- cls, response: Dict[str, Any], symbol: str, granularity: int
38
  ):
39
- return cls(
40
- symbol=symbol,
41
- granularity=granularity,
42
- klines=[KlineData.from_kucoin_data(k) for k in response.get("data", [])],
43
- )
44
 
45
 
46
  class SymbolInfo(BaseModel):
@@ -53,9 +50,9 @@ class SymbolInfo(BaseModel):
53
  @classmethod
54
  def from_kucoin_data(cls, data: Dict[str, Any]) -> "SymbolInfo":
55
  return cls(
56
- symbol=data["symbol"],
57
- name=data["name"],
58
- baseCurrency=data["baseCurrency"],
59
- quoteCurrency=data["quoteCurrency"],
60
- maxLeverage=int(data["maxLeverage"]),
61
  )
 
4
 
5
 
6
  class KlineData(BaseModel):
7
+ timestamp: int = Field(..., description="Timestamp in milliseconds")
8
  open: float
9
  high: float
10
  low: float
 
34
 
35
  @classmethod
36
  def from_kucoin_response(
37
+ cls, response_data: Dict[str, Any], symbol: str, granularity: int
38
  ):
39
+ klines = [KlineData.from_kucoin_data(k) for k in response_data.get("data", [])]
40
+ return cls(symbol=symbol, granularity=granularity, klines=klines)
 
 
 
41
 
42
 
43
  class SymbolInfo(BaseModel):
 
50
  @classmethod
51
  def from_kucoin_data(cls, data: Dict[str, Any]) -> "SymbolInfo":
52
  return cls(
53
+ symbol=data.get("symbol", ""),
54
+ name=data.get("name", ""),
55
+ baseCurrency=data.get("baseCurrency", ""),
56
+ quoteCurrency=data.get("quoteCurrency", ""),
57
+ maxLeverage=int(data.get("maxLeverage", 0)),
58
  )