### __init__(exchanges, config_obj, database) ```plantuml @startuml start :Initialize config attribute; :Initialize max_records attribute; :Initialize data attribute; stop @enduml ``` ### get_last_n_candles(num_candles, asset, timeframe, exchange, user_name) ```plantuml @startuml start :Convert timeframe to minutes_per_candle; :Calculate start_datetime; :Generate a table name: format is __; :Fetch records from data; :Check if retrieved candles are less than num_candles; if (Yes) then (True) :Log result; :Return candles[-num_candles:]; else (False) :Return candles[-num_candles:]; endif stop @enduml ``` ### set_new_candle(cdata) ```plantuml @startuml start :cdata; :Raise ValueError; stop @enduml ``` ### set_cache(symbol=None, interval=None, exchange_name=None, user_name=None) ```plantuml @startuml start :Check if symbol is None; if (Yes) then (True) :Get symbol from config.users; endif :Check if interval is None; if (Yes) then (True) :Get interval from config.users; endif :Check if exchange_name is None; if (Yes) then (True) :Get exchange_name from config.users; endif :Load candles from database; stop @enduml ``` ### get_colour_coded_volume(candles) ```plantuml @startuml start :Reset index of candles; :Extract the open_time and volume columns; :Add the color field calling get_color() to supply the values; :Rename volume column to value; :Return volumes; stop @enduml ``` ### get_latest_values(value_name, symbol, timeframe, exchange, user_name, num_record = 1) ```plantuml @startuml start :Fetch last n candles; :Check if value_name is 'volume'; if (Yes) then (True) :Get color-coded volume; else (False) :Extract the specific values, indexed by open_time; endif :Rename open_time column to time; :Convert time to seconds from milliseconds; :Return values; stop @enduml ``` ### convert_candles(candles) ```plantuml @startuml start :Extract relevant columns; :Rename columns; :Convert time to seconds from milliseconds; :Return new_candles; stop @enduml ``` ### get_candle_history(num_records, symbol, interval, exchange_name, user_name): ```plantuml @startuml start :Check if symbol is None?; if (Symbol is None?) then (yes) :Get symbol from user configuration; else (no) :Use provided symbol; endif :Check if interval is None?; if (Interval is None?) then (yes) :Get interval from user configuration; else (no) :Use provided interval; endif :Check if exchange name is None?; if (Exchange name is None?) then (yes) :Get exchange name from user configuration; else (no) :Use provided exchange name; endif :Retrieve last N candles; note left Calls the 'get_last_n_candles' method passing the specified parameters. end note :Convert candles to lightweight charts format; note left Calls the 'convert_candles' method passing the retrieved candlesticks. end note :Return: Converted candles; stop @enduml ```