@@ -4,6 +4,7 @@ use chrono::{DateTime, TimeDelta, Utc};
44use derive_more:: { Deref , DerefMut } ;
55use eyre:: { Report , Result } ;
66use v_utils:: trades:: { Asset , Kline , Pair , Timeframe } ;
7+ use crate :: { binance, bybit} ;
78
89//TODO!!!!!!!!!!!!!: klines switch to defining the range via an Enum over either limit either start and end times
910
@@ -147,3 +148,42 @@ pub struct AssetBalance {
147148 //margin_available: bool,
148149 pub timestamp : i64 ,
149150}
151+
152+ #[ derive( Debug , Clone , Copy ) ]
153+ pub enum Market {
154+ Binance ( binance:: Market ) ,
155+ Bybit ( bybit:: Market ) ,
156+ //TODO
157+ }
158+ impl Default for Market {
159+ fn default ( ) -> Self {
160+ Self :: Binance ( binance:: Market :: default ( ) )
161+ }
162+ }
163+
164+ impl std:: fmt:: Display for Market {
165+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
166+ match self {
167+ Market :: Binance ( m) => write ! ( f, "Binance/{}" , m) ,
168+ Market :: Bybit ( m) => write ! ( f, "Bybit/{}" , m) ,
169+ }
170+ }
171+ }
172+
173+ impl std:: str:: FromStr for Market {
174+ type Err = eyre:: Error ;
175+
176+ fn from_str ( s : & str ) -> Result < Self > {
177+ let parts: Vec < & str > = s. split ( '/' ) . collect ( ) ;
178+ if parts. len ( ) != 2 {
179+ return Err ( eyre:: eyre!( "Invalid market string: {}" , s) ) ;
180+ }
181+ let market = parts[ 0 ] ;
182+ let exchange = parts[ 1 ] ;
183+ match market. to_lowercase ( ) . as_str ( ) {
184+ "binance" => Ok ( Self :: Binance ( exchange. parse ( ) ?) ) ,
185+ "bybit" => Ok ( Self :: Bybit ( exchange. parse ( ) ?) ) ,
186+ _ => Err ( eyre:: eyre!( "Invalid market string: {}" , s) ) ,
187+ }
188+ }
189+ }
0 commit comments