0

When I run the code, it executes the command and opens the incomming file, but I cannot implement any other function. The file does not exist or cannot be opened. ` import time import quickfix import quickfix44 from django.shortcuts import render from django.shortcuts import render import threading from django.http import JsonResponse from quickfix import Message, MsgType from django.views.decorators.csrf import csrf_exempt symbol=['EURUSD', 'NZDAUD'] messages=[] messages1=[] messages2=[] should_stop_data_flow = True

def messageToString(message):
 ............
def securityListRequest(sessionID):
 ...............

def marketDataRequest(sessionID):
............

class Application(quickfix.Application):
  def __init__(self):
    super().__init__()
     
  def onCreate(self, sessionID):
    print("onCreate:")
    self.session_id = sessionID
    target = sessionID.getTargetCompID().getString()
    sender = sessionID.getSenderCompID().getString()
   
    return
  def onLogon(self, sessionID):
  
    self.sessionID = sessionID
    print("onLogon:", f"Session ID: {self.sessionID}")
  
    message = marketDataRequest(sessionID)
    print("market data request:", messageToString(message))
    quickfix.Session.sendToTarget(message, sessionID)

  
def onLogout(self, sessionID):
    print("onLogout..")
    return
def toAdmin(self, message, sessionID):
    print("toAdmin:", messageToString(message), '\n')
    return
def toApp(self, message, sessionID):
  
    print("toApp:", messageToString(message), '\n')
  
    return
def fromAdmin(self, message, sessionID):  
    print("fromAdmin:", messageToString(message), '\n')
    return
 
    def fromApp( self,message, sessionID):

       msg = messageToString(message)
       print("fromApp:", msg, '\n')
    
    
    def keepAlive(self):
        while True:
          time.sleep(30)
def run_fix():
    global app
    settings = quickfix.SessionSettings("CCFIX.ini")
    app = Application()
    storeFactory = quickfix.FileStoreFactory(settings)
    logFactory = quickfix.FileLogFactory(settings)
    initiator = quickfix.SocketInitiator(app, storeFactory, settings, logFactory)
    initiator.start()
    app.keepAlive()

def start_fix_thread():
     fix_thread = threading.Thread(target=run_fix)
    fix_thread.start()

def fix_example_view(request):
     global symbol
     start_fix_thread()       
    return render(request, 'show_messages.html', {'messages': messages})`

1 Answer 1

0

"The file does not exist or cannot be opened." - that's your answer.

Some line in your code is trying to open a file, and it's not finding that file. It's probably the "CCFIX.ini" line. (Don't you have a stacktrace that shows line numbers?)

I'm guessing that your code is not looking in the directory that you think.

Sign up to request clarification or add additional context in comments.

2 Comments

The file exists and works when running the program, but sending a second command shows this error, but continues to execute the first command
Maybe your first execution is holding open a file handle that is preventing a second execution from concurrently opening it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.