2025-01-10 12:23:39,261 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:23:39,262 - oa_s_v1_0 - ERROR - Symbol eurjpy not found in database mapping.
2025-01-10 12:24:08,262 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:24:08,262 - oa_s_v1_0 - INFO - Mapped TradingView symbol eurusd to XTB API symbol EURUSD
2025-01-10 12:24:08,270 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:24:08,271 - oa_s_v1_0 - INFO - Symbol: EURUSD, Action: buy, Position ID: None
2025-01-10 12:24:08,271 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 12:24:08,382 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 12:24:08,382 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 12:24:08,382 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 12:24:08,488 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 12:24:08,502 - oa_s_v1_0 - INFO - Margin Free: 117279.76
2025-01-10 12:24:08,515 - oa_s_v1_0 - INFO - Free Margin Retrieved: 117279.76
2025-01-10 12:24:08,553 - oa_s_v1_0 - INFO - Initial Trade is succesful
2025-01-10 12:24:08,566 - oa_s_v1_0 - INFO - secondary Trade is succesful
2025-01-10 12:24:08,567 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'success', 'price': 1.03069, 'Volume': 11.38, 'pre_position': 730607316}
2025-01-10 12:24:08,567 - oa_s_v1_0 - INFO - Starting add_position function.
2025-01-10 12:24:08,568 - oa_s_v1_0 - INFO - Formatting buy_timestamp_xtb.
2025-01-10 12:24:08,568 - oa_s_v1_0 - INFO - Formatted buy_timestamp_xtb: 2025-01-10 12:24:08
2025-01-10 12:24:08,568 - oa_s_v1_0 - INFO - Getting database connection.
2025-01-10 12:24:08,577 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:24:08,577 - oa_s_v1_0 - INFO - Preparing SQL query.
2025-01-10 12:24:08,577 - oa_s_v1_0 - INFO - SQL Query: 
        INSERT INTO xtb_positions (user_id, tv_position_id, symbol, size, buy_timestamp_tv, buy_timestamp_xtb, buy_price_tv, buy_price_xtb, pre_position, status)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, 'open')
        
2025-01-10 12:24:08,577 - oa_s_v1_0 - INFO - Values: (1, '1', 'EURUSD', 11.38, '2024-12-12T12:00:00', '2025-01-10 12:24:08', 0, 1.03069, 730607316)
2025-01-10 12:24:08,577 - oa_s_v1_0 - INFO - Executing SQL query.
2025-01-10 12:24:08,578 - oa_s_v1_0 - INFO - Position added successfully to the database.
2025-01-10 12:24:08,578 - oa_s_v1_0 - INFO - Closing database connection.
2025-01-10 12:24:08,578 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'price': 1.03069, 'Volume': 11.38, 'pre_position': 730607316}
2025-01-10 12:24:31,476 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:24:31,477 - oa_s_v1_0 - INFO - Mapped TradingView symbol eurusd to XTB API symbol EURUSD
2025-01-10 12:24:31,486 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:24:31,486 - oa_s_v1_0 - INFO - Symbol: EURUSD, Action: sl, Position ID: None
2025-01-10 12:24:31,487 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 12:24:31,578 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 12:24:31,578 - oa_s_v1_0 - INFO - Action: sl
2025-01-10 12:24:31,578 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 12:24:31,581 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:24:31,595 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730607317, 'digits': 5, 'offset': 0, 'order2': 730607316, 'position': 730607317, 'symbol': 'EURUSD', 'comment': '', 'customComment': 'TradingView Signal', 'commission': 0.0, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 1.03056, 'open_price': 1.03068, 'nominalValue': 0.0, 'profit': -136.56, 'volume': 11.38, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736511871581, 'spread': 0, 'taxes': 0.0, 'open_time': 1736511848546, 'open_timeString': 'Fri Jan 10 13:24:08 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 12:24:31,609 - oa_s_v1_0 - INFO - Using bid price: 1.03056
2025-01-10 12:24:31,609 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "EURUSD",
      "type": 2,
      "volume": 11.38,
      "price": 1.03056,
      "order": 730607317
    }
  }
}
2025-01-10 12:24:31,632 - oa_s_v1_0 - INFO - Close trade response: {
  "status": true,
  "returnData": {
    "order": 730607419
  }
}
2025-01-10 12:24:31,632 - oa_s_v1_0 - INFO - Trade closed successfully.
2025-01-10 12:24:31,633 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'success', 'position_id': 730607317, 'price': 1.03056}
2025-01-10 12:24:31,639 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 12:24:31,640 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'position_id': 730607317, 'price': 1.03056}
2025-01-10 14:30:19,242 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:30:19,244 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:30:19,253 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:30:19,254 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: sl, Position ID: None
2025-01-10 14:30:19,254 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:30:19,381 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:30:19,381 - oa_s_v1_0 - INFO - Action: sl
2025-01-10 14:30:19,381 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 14:30:19,385 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:30:19,386 - oa_s_v1_0 - ERROR - An exception occurred during trade closing
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 426, in close_trade
    volume = float(position['size'])
TypeError: 'NoneType' object is not subscriptable
2025-01-10 14:30:19,387 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:30:19,387 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:31:12,205 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:31:12,206 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:31:12,216 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:31:12,217 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: sl, Position ID: None
2025-01-10 14:31:12,217 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:31:12,326 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:31:12,326 - oa_s_v1_0 - INFO - Action: sl
2025-01-10 14:31:12,326 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 14:31:12,332 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:31:12,333 - oa_s_v1_0 - ERROR - An exception occurred during trade closing
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 426, in close_trade
    volume = float(position['size'])
TypeError: 'NoneType' object is not subscriptable
2025-01-10 14:31:12,333 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:31:12,333 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:32:50,208 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:32:50,209 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:32:50,217 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:32:50,218 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: sl, Position ID: None
2025-01-10 14:32:50,218 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:32:50,322 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:32:50,322 - oa_s_v1_0 - INFO - Action: sl
2025-01-10 14:32:50,322 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 14:32:50,327 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:32:50,328 - oa_s_v1_0 - ERROR - An exception occurred during trade closing
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 426, in close_trade
    volume = float(position['size'])
TypeError: 'NoneType' object is not subscriptable
2025-01-10 14:32:50,328 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:32:50,329 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:33:06,559 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:33:06,559 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:33:06,567 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:33:06,567 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: sl, Position ID: None
2025-01-10 14:33:06,568 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:33:06,661 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:33:06,661 - oa_s_v1_0 - INFO - Action: sl
2025-01-10 14:33:06,661 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 14:33:06,664 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:33:06,665 - oa_s_v1_0 - ERROR - An exception occurred during trade closing
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 426, in close_trade
    volume = float(position['size'])
TypeError: 'NoneType' object is not subscriptable
2025-01-10 14:33:06,665 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:33:06,666 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:36:57,055 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:36:57,056 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:36:57,065 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:36:57,066 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: sl, Position ID: None
2025-01-10 14:36:57,066 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:36:57,169 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:36:57,169 - oa_s_v1_0 - INFO - Action: sl
2025-01-10 14:36:57,169 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 14:36:57,175 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:36:57,176 - oa_s_v1_0 - ERROR - An exception occurred during trade closing
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 426, in close_trade
    volume = float(position['size'])
TypeError: 'NoneType' object is not subscriptable
2025-01-10 14:36:57,176 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:36:57,177 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 14:42:04,299 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:42:04,300 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:42:04,311 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:42:04,312 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 14:42:04,312 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:42:04,414 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:42:04,414 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 14:42:04,414 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 14:42:04,542 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:42:04,556 - oa_s_v1_0 - INFO - Margin Free: 117143.2
2025-01-10 14:42:04,571 - oa_s_v1_0 - INFO - Free Margin Retrieved: 117143.2
2025-01-10 14:42:04,610 - oa_s_v1_0 - INFO - Initial Trade is succesful
2025-01-10 14:42:04,624 - oa_s_v1_0 - INFO - secondary Trade is succesful
2025-01-10 14:42:04,624 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'success', 'price': 334.29, 'Volume': 332.5, 'pre_position': 730698255}
2025-01-10 14:42:04,625 - oa_s_v1_0 - INFO - Starting add_position function.
2025-01-10 14:42:04,625 - oa_s_v1_0 - INFO - Formatting buy_timestamp_xtb.
2025-01-10 14:42:04,625 - oa_s_v1_0 - INFO - Formatted buy_timestamp_xtb: 2025-01-10 14:42:04
2025-01-10 14:42:04,625 - oa_s_v1_0 - INFO - Getting database connection.
2025-01-10 14:42:04,629 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:42:04,629 - oa_s_v1_0 - INFO - Preparing SQL query.
2025-01-10 14:42:04,629 - oa_s_v1_0 - INFO - SQL Query: 
        INSERT INTO xtb_positions (user_id, tv_position_id, symbol, size, buy_timestamp_tv, buy_timestamp_xtb, buy_price_tv, buy_price_xtb, pre_position, status)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, 'open')
        
2025-01-10 14:42:04,629 - oa_s_v1_0 - INFO - Values: (1, 'MSTR21097', 'MSTR.US_9', 332.5, '2025-01-10 13:42:00', '2025-01-10 14:42:04', '327.12', 334.29, 730698255)
2025-01-10 14:42:04,630 - oa_s_v1_0 - INFO - Executing SQL query.
2025-01-10 14:42:04,630 - oa_s_v1_0 - INFO - Position added successfully to the database.
2025-01-10 14:42:04,630 - oa_s_v1_0 - INFO - Closing database connection.
2025-01-10 14:42:04,631 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'price': 334.29, 'Volume': 332.5, 'pre_position': 730698255}
2025-01-10 14:46:35,056 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:46:35,057 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:46:35,064 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:46:35,065 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: tp, Position ID: None
2025-01-10 14:46:35,065 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:46:35,188 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:46:35,188 - oa_s_v1_0 - INFO - Action: tp
2025-01-10 14:46:35,188 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 14:46:35,192 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:46:35,206 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730698343, 'digits': 2, 'offset': 0, 'order2': 730698255, 'position': 730698343, 'symbol': 'MSTR.US_9', 'comment': '', 'customComment': 'TradingView Signal', 'commission': -224.56, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 334.04, 'open_price': 334.29, 'nominalValue': 111151.29, 'profit': -83.0, 'volume': 332.5, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736520395192, 'spread': 0, 'taxes': 0.0, 'open_time': 1736520131769, 'open_timeString': 'Fri Jan 10 15:42:11 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 14:46:35,221 - oa_s_v1_0 - INFO - Using bid price: 327.23
2025-01-10 14:46:35,221 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "MSTR.US_9",
      "type": 2,
      "volume": 332.5,
      "price": 327.23,
      "order": 730698343
    }
  }
}
2025-01-10 14:46:35,243 - oa_s_v1_0 - INFO - Close trade response: {
  "status": false,
  "errorCode": "SE199",
  "errorDescr": "Internal error"
}
2025-01-10 14:46:35,244 - oa_s_v1_0 - ERROR - Close trade failed: Internal error
2025-01-10 14:46:35,244 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 14:46:35,244 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 14:46:38,249 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:46:38,250 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:46:38,258 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:46:38,258 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 14:46:38,259 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:46:38,371 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:46:38,371 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 14:46:38,371 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 14:46:38,376 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:46:38,391 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730698343, 'digits': 2, 'offset': 0, 'order2': 730698255, 'position': 730698343, 'symbol': 'MSTR.US_9', 'comment': '', 'customComment': 'TradingView Signal', 'commission': -224.56, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 326.57, 'open_price': 334.29, 'nominalValue': 111151.29, 'profit': -2566.76, 'volume': 332.5, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736520398376, 'spread': 0, 'taxes': 0.0, 'open_time': 1736520131769, 'open_timeString': 'Fri Jan 10 15:42:11 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 14:46:38,405 - oa_s_v1_0 - INFO - Using bid price: 326.57
2025-01-10 14:46:38,405 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "MSTR.US_9",
      "type": 2,
      "volume": 332.5,
      "price": 326.57,
      "order": 730698343
    }
  }
}
2025-01-10 14:46:38,428 - oa_s_v1_0 - INFO - Close trade response: {
  "status": false,
  "errorCode": "SE199",
  "errorDescr": "Internal error"
}
2025-01-10 14:46:38,428 - oa_s_v1_0 - ERROR - Close trade failed: Internal error
2025-01-10 14:46:38,428 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 14:46:38,429 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 14:52:05,396 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:52:05,397 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 14:52:05,408 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:52:05,409 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 14:52:05,410 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 14:52:05,505 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:52:05,505 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 14:52:05,505 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 14:52:05,614 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 14:52:05,628 - oa_s_v1_0 - INFO - Margin Free: 5767.35
2025-01-10 14:52:05,641 - oa_s_v1_0 - INFO - Free Margin Retrieved: 5767.35
2025-01-10 14:52:05,683 - oa_s_v1_0 - INFO - Initial Trade is succesful
2025-01-10 14:52:05,697 - oa_s_v1_0 - INFO - secondary Trade is succesful
2025-01-10 14:52:05,697 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'success', 'price': 328.58, 'Volume': 16.15, 'pre_position': 730709513}
2025-01-10 14:52:05,698 - oa_s_v1_0 - INFO - Starting add_position function.
2025-01-10 14:52:05,698 - oa_s_v1_0 - INFO - Formatting buy_timestamp_xtb.
2025-01-10 14:52:05,698 - oa_s_v1_0 - INFO - Formatted buy_timestamp_xtb: 2025-01-10 14:52:05
2025-01-10 14:52:05,698 - oa_s_v1_0 - INFO - Getting database connection.
2025-01-10 14:52:05,703 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 14:52:05,703 - oa_s_v1_0 - INFO - Preparing SQL query.
2025-01-10 14:52:05,703 - oa_s_v1_0 - INFO - SQL Query: 
        INSERT INTO xtb_positions (user_id, tv_position_id, symbol, size, buy_timestamp_tv, buy_timestamp_xtb, buy_price_tv, buy_price_xtb, pre_position, status)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, 'open')
        
2025-01-10 14:52:05,703 - oa_s_v1_0 - INFO - Values: (1, 'MSTR21107', 'MSTR.US_9', 16.15, '2025-01-10 13:52:00', '2025-01-10 14:52:05', '330.5', 328.58, 730709513)
2025-01-10 14:52:05,703 - oa_s_v1_0 - INFO - Executing SQL query.
2025-01-10 14:52:05,704 - oa_s_v1_0 - INFO - Position added successfully to the database.
2025-01-10 14:52:05,704 - oa_s_v1_0 - INFO - Closing database connection.
2025-01-10 14:52:05,704 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'price': 328.58, 'Volume': 16.15, 'pre_position': 730709513}
2025-01-10 15:06:20,492 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:06:20,493 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 15:06:20,500 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:06:20,500 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: sl, Position ID: None
2025-01-10 15:06:20,501 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 15:06:20,620 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:06:20,620 - oa_s_v1_0 - INFO - Action: sl
2025-01-10 15:06:20,620 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 15:06:20,623 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:06:20,639 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730709515, 'digits': 2, 'offset': 0, 'order2': 730709513, 'position': 730709515, 'symbol': 'MSTR.US_9', 'comment': '', 'customComment': 'TradingView Signal', 'commission': -10.74, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 324.07, 'open_price': 329.21, 'nominalValue': 5316.73, 'profit': -83.0, 'volume': 16.15, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736521580624, 'spread': 0, 'taxes': 0.0, 'open_time': 1736520725708, 'open_timeString': 'Fri Jan 10 15:52:05 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 15:06:20,654 - oa_s_v1_0 - INFO - Using bid price: 329.37
2025-01-10 15:06:20,654 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "MSTR.US_9",
      "type": 2,
      "volume": 16.15,
      "price": 329.37,
      "order": 730709515
    }
  }
}
2025-01-10 15:06:20,676 - oa_s_v1_0 - INFO - Close trade response: {
  "status": false,
  "errorCode": "SE199",
  "errorDescr": "Internal error"
}
2025-01-10 15:06:20,676 - oa_s_v1_0 - ERROR - Close trade failed: Internal error
2025-01-10 15:06:20,676 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 15:06:20,677 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 15:17:03,963 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:17:03,964 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 15:17:03,975 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:17:03,976 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 15:17:03,977 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 15:17:04,081 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:17:04,081 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 15:17:04,082 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 15:17:04,196 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:17:04,210 - oa_s_v1_0 - INFO - Margin Free: 439.88
2025-01-10 15:17:04,224 - oa_s_v1_0 - INFO - Free Margin Retrieved: 439.88
2025-01-10 15:17:04,263 - oa_s_v1_0 - INFO - Initial Trade is succesful
2025-01-10 15:17:04,277 - oa_s_v1_0 - INFO - secondary Trade is succesful
2025-01-10 15:17:04,277 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'success', 'price': 327.09, 'Volume': 0.95, 'pre_position': 730734146}
2025-01-10 15:17:04,278 - oa_s_v1_0 - INFO - Starting add_position function.
2025-01-10 15:17:04,278 - oa_s_v1_0 - INFO - Formatting buy_timestamp_xtb.
2025-01-10 15:17:04,278 - oa_s_v1_0 - INFO - Formatted buy_timestamp_xtb: 2025-01-10 15:17:04
2025-01-10 15:17:04,278 - oa_s_v1_0 - INFO - Getting database connection.
2025-01-10 15:17:04,281 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:17:04,282 - oa_s_v1_0 - INFO - Preparing SQL query.
2025-01-10 15:17:04,282 - oa_s_v1_0 - INFO - SQL Query: 
        INSERT INTO xtb_positions (user_id, tv_position_id, symbol, size, buy_timestamp_tv, buy_timestamp_xtb, buy_price_tv, buy_price_xtb, pre_position, status)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, 'open')
        
2025-01-10 15:17:04,282 - oa_s_v1_0 - INFO - Values: (1, 'MSTR21132', 'MSTR.US_9', 0.95, '2025-01-10 14:17:00', '2025-01-10 15:17:04', '321.46', 327.09, 730734146)
2025-01-10 15:17:04,282 - oa_s_v1_0 - INFO - Executing SQL query.
2025-01-10 15:17:04,283 - oa_s_v1_0 - INFO - Position added successfully to the database.
2025-01-10 15:17:04,283 - oa_s_v1_0 - INFO - Closing database connection.
2025-01-10 15:17:04,283 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'price': 327.09, 'Volume': 0.95, 'pre_position': 730734146}
2025-01-10 15:21:04,307 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:21:04,308 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 15:21:04,316 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:21:04,317 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 15:21:04,317 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 15:21:04,418 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:21:04,418 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 15:21:04,418 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 15:21:04,421 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:21:04,437 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730734148, 'digits': 2, 'offset': 0, 'order2': 730734146, 'position': 730734148, 'symbol': 'MSTR.US_9', 'comment': '', 'customComment': 'TradingView Signal', 'commission': -10.31, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 324.92, 'open_price': 321.58, 'nominalValue': 305.5, 'profit': 3.17, 'volume': 0.95, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736522464422, 'spread': 0, 'taxes': 0.0, 'open_time': 1736522224338, 'open_timeString': 'Fri Jan 10 16:17:04 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 15:21:04,451 - oa_s_v1_0 - INFO - Using bid price: 323.48
2025-01-10 15:21:04,451 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "MSTR.US_9",
      "type": 2,
      "volume": 0.95,
      "price": 323.48,
      "order": 730734148
    }
  }
}
2025-01-10 15:21:04,471 - oa_s_v1_0 - INFO - Close trade response: {
  "status": false,
  "errorCode": "SE199",
  "errorDescr": "Internal error"
}
2025-01-10 15:21:04,471 - oa_s_v1_0 - ERROR - Close trade failed: Internal error
2025-01-10 15:21:04,472 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 15:21:04,473 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 15:28:07,821 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:28:07,822 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 15:28:07,832 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:28:07,833 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 15:28:07,833 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 15:28:07,924 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:28:07,925 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 15:28:07,925 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 15:28:07,930 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:28:07,945 - oa_s_v1_0 - ERROR - No position id is found buddy
2025-01-10 15:28:07,945 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error'}
2025-01-10 15:28:07,946 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error'}
2025-01-10 15:29:02,431 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:29:02,432 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 15:29:02,443 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:29:02,444 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 15:29:02,444 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 15:29:02,534 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:29:02,535 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 15:29:02,535 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 15:29:02,539 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:29:02,553 - oa_s_v1_0 - ERROR - No position id is found buddy
2025-01-10 15:29:02,554 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error'}
2025-01-10 15:29:02,554 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error'}
2025-01-10 15:45:18,089 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:45:18,090 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 15:45:18,097 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:45:18,098 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: tp, Position ID: None
2025-01-10 15:45:18,098 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 15:45:18,193 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:45:18,193 - oa_s_v1_0 - INFO - Action: tp
2025-01-10 15:45:18,193 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 15:45:18,198 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:45:18,212 - oa_s_v1_0 - ERROR - No position id is found buddy
2025-01-10 15:45:18,213 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error'}
2025-01-10 15:45:18,213 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error'}
2025-01-10 15:52:35,476 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:52:35,478 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 15:52:35,486 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:52:35,487 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: tp, Position ID: None
2025-01-10 15:52:35,487 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 15:52:35,596 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 15:52:35,596 - oa_s_v1_0 - INFO - Action: tp
2025-01-10 15:52:35,596 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 15:52:35,601 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 15:52:35,616 - oa_s_v1_0 - ERROR - No position id is found buddy
2025-01-10 15:52:35,616 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error'}
2025-01-10 15:52:35,617 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error'}
2025-01-10 16:11:04,439 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:11:04,440 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 16:11:04,452 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:11:04,453 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 16:11:04,453 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 16:11:04,573 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 16:11:04,573 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 16:11:04,573 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 16:11:04,679 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 16:11:04,693 - oa_s_v1_0 - INFO - Margin Free: 112468.17
2025-01-10 16:11:04,706 - oa_s_v1_0 - INFO - Free Margin Retrieved: 112468.17
2025-01-10 16:11:04,756 - oa_s_v1_0 - INFO - Initial Trade is succesful
2025-01-10 16:11:04,769 - oa_s_v1_0 - INFO - secondary Trade is succesful
2025-01-10 16:11:04,769 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'success', 'price': 327.83, 'Volume': 325.85, 'pre_position': 730787360}
2025-01-10 16:11:04,770 - oa_s_v1_0 - INFO - Starting add_position function.
2025-01-10 16:11:04,770 - oa_s_v1_0 - INFO - Formatting buy_timestamp_xtb.
2025-01-10 16:11:04,770 - oa_s_v1_0 - INFO - Formatted buy_timestamp_xtb: 2025-01-10 16:11:04
2025-01-10 16:11:04,770 - oa_s_v1_0 - INFO - Getting database connection.
2025-01-10 16:11:04,775 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:11:04,775 - oa_s_v1_0 - INFO - Preparing SQL query.
2025-01-10 16:11:04,775 - oa_s_v1_0 - INFO - SQL Query: 
        INSERT INTO xtb_positions (user_id, tv_position_id, symbol, size, buy_timestamp_tv, buy_timestamp_xtb, buy_price_tv, buy_price_xtb, pre_position, status)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, 'open')
        
2025-01-10 16:11:04,775 - oa_s_v1_0 - INFO - Values: (1, 'MSTR21186', 'MSTR.US_9', 325.85, '2025-01-10 15:11:00', '2025-01-10 16:11:04', '327.65', 327.83, 730787360)
2025-01-10 16:11:04,775 - oa_s_v1_0 - INFO - Executing SQL query.
2025-01-10 16:11:04,776 - oa_s_v1_0 - INFO - Position added successfully to the database.
2025-01-10 16:11:04,776 - oa_s_v1_0 - INFO - Closing database connection.
2025-01-10 16:11:04,776 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'price': 327.83, 'Volume': 325.85, 'pre_position': 730787360}
2025-01-10 16:11:04,782 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:11:04,782 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 16:11:04,794 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:11:04,795 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 16:11:04,795 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 16:11:04,910 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 16:11:04,910 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 16:11:04,910 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 16:11:04,918 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:11:04,933 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730787360, 'digits': 2, 'offset': 0, 'order2': 730787360, 'position': 730787360, 'symbol': 'MSTR.US_9', 'comment': '', 'customComment': 'TradingView Signal', 'commission': 0.0, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 0.0, 'open_price': 327.83, 'nominalValue': 106544.75, 'profit': 0.0, 'volume': 325.0, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736525464918, 'spread': 0, 'taxes': 0.0, 'open_time': 1736525464731, 'open_timeString': 'Fri Jan 10 17:11:04 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 16:11:04,948 - oa_s_v1_0 - INFO - Using bid price: 327.47
2025-01-10 16:11:04,948 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "MSTR.US_9",
      "type": 2,
      "volume": 325.85,
      "price": 327.47,
      "order": 730787360
    }
  }
}
2025-01-10 16:11:04,968 - oa_s_v1_0 - INFO - Close trade response: {
  "status": false,
  "errorCode": "SE199",
  "errorDescr": "Internal error"
}
2025-01-10 16:11:04,968 - oa_s_v1_0 - ERROR - Close trade failed: Internal error
2025-01-10 16:11:04,969 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 16:11:04,969 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 16:12:05,789 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:12:05,790 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 16:12:05,798 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:12:05,799 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 16:12:05,799 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 16:12:05,901 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 16:12:05,901 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 16:12:05,901 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 16:12:06,017 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 16:12:06,032 - oa_s_v1_0 - INFO - Margin Free: 5428.83
2025-01-10 16:12:06,045 - oa_s_v1_0 - INFO - Free Margin Retrieved: 5428.83
2025-01-10 16:12:06,085 - oa_s_v1_0 - INFO - Initial Trade is succesful
2025-01-10 16:12:06,099 - oa_s_v1_0 - INFO - secondary Trade is succesful
2025-01-10 16:12:06,099 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'success', 'price': 327.81, 'Volume': 15.2, 'pre_position': 730788298}
2025-01-10 16:12:06,100 - oa_s_v1_0 - INFO - Starting add_position function.
2025-01-10 16:12:06,100 - oa_s_v1_0 - INFO - Formatting buy_timestamp_xtb.
2025-01-10 16:12:06,100 - oa_s_v1_0 - INFO - Formatted buy_timestamp_xtb: 2025-01-10 16:12:06
2025-01-10 16:12:06,100 - oa_s_v1_0 - INFO - Getting database connection.
2025-01-10 16:12:06,105 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 16:12:06,105 - oa_s_v1_0 - INFO - Preparing SQL query.
2025-01-10 16:12:06,105 - oa_s_v1_0 - INFO - SQL Query: 
        INSERT INTO xtb_positions (user_id, tv_position_id, symbol, size, buy_timestamp_tv, buy_timestamp_xtb, buy_price_tv, buy_price_xtb, pre_position, status)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, 'open')
        
2025-01-10 16:12:06,105 - oa_s_v1_0 - INFO - Values: (1, 'MSTR21187', 'MSTR.US_9', 15.2, '2025-01-10 15:12:00', '2025-01-10 16:12:06', '328.26', 327.81, 730788298)
2025-01-10 16:12:06,105 - oa_s_v1_0 - INFO - Executing SQL query.
2025-01-10 16:12:06,106 - oa_s_v1_0 - INFO - Position added successfully to the database.
2025-01-10 16:12:06,107 - oa_s_v1_0 - INFO - Closing database connection.
2025-01-10 16:12:06,107 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'price': 327.81, 'Volume': 15.2, 'pre_position': 730788298}
2025-01-10 17:30:24,462 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:30:24,463 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 17:30:24,474 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:30:24,475 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 17:30:24,476 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 17:30:24,592 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:30:24,592 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 17:30:24,592 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 17:30:24,596 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:30:24,611 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730788301, 'digits': 2, 'offset': 0, 'order2': 730788298, 'position': 730788301, 'symbol': 'MSTR.US_9', 'comment': '', 'customComment': 'TradingView Signal', 'commission': -10.29, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 326.4, 'open_price': 328.16, 'nominalValue': 4988.08, 'profit': -26.8, 'volume': 15.2, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736530224596, 'spread': 0, 'taxes': 0.0, 'open_time': 1736525526364, 'open_timeString': 'Fri Jan 10 17:12:06 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 17:30:24,626 - oa_s_v1_0 - INFO - Using bid price: 327.26
2025-01-10 17:30:24,626 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "MSTR.US_9",
      "type": 2,
      "volume": 15.2,
      "price": 327.26,
      "order": 730788301
    }
  }
}
2025-01-10 17:30:24,645 - oa_s_v1_0 - INFO - Close trade response: {
  "status": false,
  "errorCode": "SE199",
  "errorDescr": "Internal error"
}
2025-01-10 17:30:24,645 - oa_s_v1_0 - ERROR - Close trade failed: Internal error
2025-01-10 17:30:24,645 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 17:30:24,646 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 17:31:15,052 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:31:15,053 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 17:31:15,064 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:31:15,065 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 17:31:15,067 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 17:31:15,173 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:31:15,173 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 17:31:15,173 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 17:31:15,177 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:31:15,192 - oa_s_v1_0 - INFO - RETURNED DATA: {'cmd': 0, 'order': 730788301, 'digits': 2, 'offset': 0, 'order2': 730788298, 'position': 730788301, 'symbol': 'MSTR.US_9', 'comment': '', 'customComment': 'TradingView Signal', 'commission': -10.29, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 326.56, 'open_price': 328.16, 'nominalValue': 4988.08, 'profit': -24.37, 'volume': 15.2, 'sl': 0.0, 'tp': 0.0, 'closed': False, 'timestamp': 1736530275178, 'spread': 0, 'taxes': 0.0, 'open_time': 1736525526364, 'open_timeString': 'Fri Jan 10 17:12:06 CET 2025', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None}
2025-01-10 17:31:15,207 - oa_s_v1_0 - INFO - Using bid price: 326.56
2025-01-10 17:31:15,207 - oa_s_v1_0 - INFO - Close trade payload: {
  "command": "tradeTransaction",
  "arguments": {
    "tradeTransInfo": {
      "symbol": "MSTR.US_9",
      "type": 2,
      "volume": 15.2,
      "price": 326.56,
      "order": 730788301
    }
  }
}
2025-01-10 17:31:15,230 - oa_s_v1_0 - INFO - Close trade response: {
  "status": false,
  "errorCode": "SE199",
  "errorDescr": "Internal error"
}
2025-01-10 17:31:15,230 - oa_s_v1_0 - ERROR - Close trade failed: Internal error
2025-01-10 17:31:15,230 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 17:31:15,231 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Internal error'}
2025-01-10 17:32:05,347 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:32:05,347 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 17:32:05,355 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:32:05,355 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 17:32:05,356 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 17:32:05,457 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:32:05,457 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 17:32:05,457 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 17:32:05,574 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:32:05,589 - oa_s_v1_0 - INFO - Margin Free: 430.46
2025-01-10 17:32:05,602 - oa_s_v1_0 - INFO - Free Margin Retrieved: 430.46
2025-01-10 17:32:05,638 - oa_s_v1_0 - INFO - Initial Trade is succesful
2025-01-10 17:32:05,652 - oa_s_v1_0 - INFO - secondary Trade is succesful
2025-01-10 17:32:05,652 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'success', 'price': 327.95, 'Volume': 0.95, 'pre_position': 730839837}
2025-01-10 17:32:05,652 - oa_s_v1_0 - INFO - Starting add_position function.
2025-01-10 17:32:05,653 - oa_s_v1_0 - INFO - Formatting buy_timestamp_xtb.
2025-01-10 17:32:05,653 - oa_s_v1_0 - INFO - Formatted buy_timestamp_xtb: 2025-01-10 17:32:05
2025-01-10 17:32:05,653 - oa_s_v1_0 - INFO - Getting database connection.
2025-01-10 17:32:05,656 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:32:05,657 - oa_s_v1_0 - INFO - Preparing SQL query.
2025-01-10 17:32:05,657 - oa_s_v1_0 - INFO - SQL Query: 
        INSERT INTO xtb_positions (user_id, tv_position_id, symbol, size, buy_timestamp_tv, buy_timestamp_xtb, buy_price_tv, buy_price_xtb, pre_position, status)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, 'open')
        
2025-01-10 17:32:05,657 - oa_s_v1_0 - INFO - Values: (1, 'MSTR21267', 'MSTR.US_9', 0.95, '2025-01-10 16:32:00', '2025-01-10 17:32:05', '330.76', 327.95, 730839837)
2025-01-10 17:32:05,657 - oa_s_v1_0 - INFO - Executing SQL query.
2025-01-10 17:32:05,658 - oa_s_v1_0 - INFO - Position added successfully to the database.
2025-01-10 17:32:05,658 - oa_s_v1_0 - INFO - Closing database connection.
2025-01-10 17:32:05,658 - oa_s_v1_0 - INFO - Trade Result: {'status': 'success', 'price': 327.95, 'Volume': 0.95, 'pre_position': 730839837}
2025-01-10 17:40:10,789 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:40:10,790 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 17:40:10,800 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:40:10,801 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 17:40:10,802 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 17:40:10,901 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:40:10,901 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 17:40:10,901 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 17:40:11,011 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:40:11,025 - oa_s_v1_0 - INFO - Margin Free: 105.72
2025-01-10 17:40:11,038 - oa_s_v1_0 - INFO - Free Margin Retrieved: 105.72
2025-01-10 17:40:11,070 - oa_s_v1_0 - ERROR - Initial trade didni't work
2025-01-10 17:40:11,070 - oa_s_v1_0 - ERROR - An exception occurred during trade execution
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 256, in execute_trade
    "order": fakeposition_id
UnboundLocalError: local variable 'fakeposition_id' referenced before assignment
2025-01-10 17:40:11,071 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'error', 'message': 'Trade execution error'}
2025-01-10 17:40:11,071 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade execution error'}
2025-01-10 17:43:04,420 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:43:04,421 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 17:43:04,428 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 17:43:04,429 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 17:43:04,429 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 17:43:04,535 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:43:04,535 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 17:43:04,535 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 17:43:04,650 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 17:43:04,663 - oa_s_v1_0 - INFO - Margin Free: 105.72
2025-01-10 17:43:04,676 - oa_s_v1_0 - INFO - Free Margin Retrieved: 105.72
2025-01-10 17:43:04,710 - oa_s_v1_0 - ERROR - Initial trade didni't work
2025-01-10 17:43:04,710 - oa_s_v1_0 - ERROR - An exception occurred during trade execution
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 256, in execute_trade
    "order": fakeposition_id
UnboundLocalError: local variable 'fakeposition_id' referenced before assignment
2025-01-10 17:43:04,710 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'error', 'message': 'Trade execution error'}
2025-01-10 17:43:04,711 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade execution error'}
2025-01-10 18:01:16,425 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 18:01:16,426 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 18:01:16,434 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 18:01:16,435 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: min_tp, Position ID: None
2025-01-10 18:01:16,436 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 18:01:16,537 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 18:01:16,538 - oa_s_v1_0 - INFO - Action: min_tp
2025-01-10 18:01:16,538 - oa_s_v1_0 - INFO - Executing sell trade...
2025-01-10 18:01:16,541 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 18:01:16,542 - oa_s_v1_0 - ERROR - An exception occurred during trade closing
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 426, in close_trade
    volume = float(position['size'])
TypeError: 'NoneType' object is not subscriptable
2025-01-10 18:01:16,542 - oa_s_v1_0 - INFO - Sell trade result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 18:01:16,543 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade closing error'}
2025-01-10 18:36:14,580 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 18:36:14,581 - oa_s_v1_0 - INFO - Mapped TradingView symbol MSTR to XTB API symbol MSTR.US_9
2025-01-10 18:36:14,592 - oa_s_v1_0 - INFO - DB Connection Success
2025-01-10 18:36:14,593 - oa_s_v1_0 - INFO - Symbol: MSTR.US_9, Action: buy, Position ID: None
2025-01-10 18:36:14,593 - oa_s_v1_0 - INFO - Starting process_trade function...
2025-01-10 18:36:14,823 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 18:36:14,823 - oa_s_v1_0 - INFO - Action: buy
2025-01-10 18:36:14,823 - oa_s_v1_0 - INFO - Executing buy trade...
2025-01-10 18:36:14,940 - oa_s_v1_0 - INFO - Login successful.
2025-01-10 18:36:14,954 - oa_s_v1_0 - INFO - Margin Free: 105.72
2025-01-10 18:36:14,967 - oa_s_v1_0 - INFO - Free Margin Retrieved: 105.72
2025-01-10 18:36:14,999 - oa_s_v1_0 - ERROR - Initial trade didni't work
2025-01-10 18:36:14,999 - oa_s_v1_0 - ERROR - An exception occurred during trade execution
Traceback (most recent call last):
  File "/home/magsbae/projects/stocks/v1_0/oa_s_v1_0.py", line 256, in execute_trade
    "order": fakeposition_id
UnboundLocalError: local variable 'fakeposition_id' referenced before assignment
2025-01-10 18:36:15,000 - oa_s_v1_0 - INFO - Buy trade result: {'status': 'error', 'message': 'Trade execution error'}
2025-01-10 18:36:15,001 - oa_s_v1_0 - INFO - Trade Result: {'status': 'error', 'message': 'Trade execution error'}
