3.3 KiB
3.3 KiB
init(exchanges, config_obj, database)
@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)
@startuml
start
:Convert timeframe to minutes_per_candle;
:Calculate start_datetime;
:Generate a table name: format is <symbol>_<timeframe>_<exchange_name>;
: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)
@startuml
start
:cdata;
:Raise ValueError;
stop
@enduml
set_cache(symbol=None, interval=None, exchange_name=None, user_name=None)
@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)
@startuml
start
:Reset index of candles;
:Extract the `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)
@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 time;
endif
:Rename time column to time;
:Convert time to seconds from milliseconds;
:Return values;
stop
@enduml
convert_candles(candles)
@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):
@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