@@ -39,8 +39,7 @@ def perform_analysis():
39
39
# Creates DataFrame for manipulation
40
40
columns = ['close' , 'high' , 'low' , 'open' , 'time' ]
41
41
df = pd .DataFrame (candle_dict , columns = columns )
42
- df ['time' ] = pd .to_datetime (df ['time' ], unit = 's' )
43
-
42
+ df ['time' ] = pd .to_datetime (df ['time' ], unit = 's' )
44
43
df = strategy (df )
45
44
print (df .tail (2 ))
46
45
@@ -98,14 +97,29 @@ def perform_analysis():
98
97
99
98
# Check Strategy
100
99
if df ['exit' ].iloc [- 1 ] == 1 :
101
- exit_msg = f"Soltrade has detected a sell signal for { input_amount } ${ config ().secondary_mint_symbol } .. "
100
+ exit_msg = f"Soltrade has detected a sell signal for { input_amount } ${ config ().secondary_mint_symbol } ."
102
101
log_transaction .info (exit_msg )
103
102
# log_transaction.info(get_statistics())
104
103
asyncio .run (perform_swap (input_amount , config ().secondary_mint ))
105
104
stoploss = takeprofit = 0
106
105
df ['entry_price' ] = None
107
106
107
+ # This starts the trading function on a timer
108
+ def start_trading ():
109
+ log_general .info ("Soltrade has now initialized the trading algorithm." )
108
110
trading_sched = BlockingScheduler ()
109
111
trading_sched .add_job (perform_analysis , 'interval' , seconds = config ().price_update_seconds , max_instances = 1 )
110
112
trading_sched .start ()
111
- perform_analysis ()
113
+ perform_analysis ()
114
+
115
+ # Function to save DataFrame to JSON file
116
+ def save_dataframe_to_json (df , file_path ):
117
+ df_json = df .to_json (orient = 'records' )
118
+ with open (file_path , 'w' ) as f :
119
+ json .dump (df_json , f )
120
+
121
+ # Function to read DataFrame from JSON file
122
+ def read_dataframe_from_json (file_path ):
123
+ with open (file_path , 'r' ) as f :
124
+ df_json = json .load (f )
125
+ return pd .read_json (df_json )
0 commit comments