This document serves as an informative guide, detailing the functionality and setup process of a Python script integral to the NinjaView application. It is worth mentioning that, although the application is secure, certain antivirus programs might mistakenly identify it as a potential threat. This document aims to address these concerns and guide users through the installation and execution process.
nv.py
uses NinjaTrader's Advanced Trade Interface (ATI) to place trades and manage orders. It establishes a connection to NinjaTrader's ATI port and sends trading commands directly, ensuring a seamless and swift execution of trades. Below is a simplified example of how it sends a trade command to NinjaTrader:
import os
import winreg
import sys
import uuid
import time
import logging
import hashlib
import socket
import signal
import threading
import psutil
import PIL.Image
import tkinter as tk
import base64
import atexit
import subprocess
import requests
import pyperclip
import base64
from tkinter import simpledialog, messagebox, filedialog
from io import BytesIO
from datetime import datetime
from pystray import Icon as icon, Menu as menu, MenuItem as item
from threading import Thread as FlaskThread
import flask
from flask import request, jsonify, current_app
ngrok_process = None
is_verified = False
ngrok_started = False
public_url = None
details = {
"ngrokAUTHTOKEN": "Default",
"ngrokDOMAIN": "Default",
"ngrokLOCATION": "Default"
}
def send_ati_command(command):
try:
# Connect to NinjaTrader ATI port
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(('localhost', 36973)) # Adjust IP and port as necessary
s.sendall(command.encode())
data = s.recv(1024)
print('Received', repr(data))
except Exception as e:
print("An error occurred:", e)
# Example command (replace with actual ATI command)
command = "PLACE;Account=Sim1;Instrument=ES 12-23;Action=BUY;Qty=1;OrderType=LIMIT;LimitPrice=4139;TIF=DAY"
send_ati_command(command)
NinjaView is a paid application because it represents the culmination of extensive research, development, and overcoming numerous challenges to provide a reliable and effective trading solution. The integration with NinjaTrader through its ATI port, as demonstrated in nv.py, required significant time and effort to perfect. Your purchase and support ensure continued development, improvements, and customer support for NinjaView, enabling traders to enhance their trading experience seamlessly.
NinjaView is a relatively new entrant in the trading software domain. We understand that building trust within the trading community takes time, especially when introducing innovative solutions that have never been seen before. Our commitment to transparency, security, and relentless improvement is unwavering. We are here to revolutionize trading automation and provide traders with unparalleled tools for success.
We encourage users to reach out with any questions, concerns, or feedback. Your insights and experience with NinjaView are invaluable to us and the wider trading community. Together, we are shaping the future of trading automation.
Before proceeding, ensure that you have the following prerequisites installed on your system:
- Python: Version 3.6 or later
- pip: A package installer for Python
You can install the required Python packages using the following command:
pip install flask pystray Pillow requests psutil pyperclip
Download the Script: Clone the repository or download the script from the provided source.
Navigate to the Script's Directory: Use your command line tool to go to the script's folder.
cd path/to/script/directory
Install Virtual Environment (Optional): It is a good practice to create a virtual environment to isolate the project dependencies.
cd path/to/script/directory
python -m venv venv
.\venv\Scripts\activate # On Windows
source venv/bin/activate # On Unix or MacOS
Install Requirements: Install the required packages using pip:
pip install -r requirements.txt
or
pip install flask pystray Pillow requests psutil pyperclip
Note: Some of the packages that might be required include os, winreg, sys, uuid, time, logging, hashlib, signal, threading, psutil, PIL, tkinter, base64, atexit, subprocess, requests, pyperclip, pystray, flask, and ngrok.
Running the Script Execute the Script: Run the script using Python.
python nv.py
Compiling with PyInstaller Install PyInstaller: If you don’t have PyInstaller installed, you can install it using pip:
pip install pyinstaller
Compile the Script: Use PyInstaller to compile the script.
pyinstaller --onefile --noconsole nv.py
If you want to add an icon to the executable, you can use the --icon option (This will cause more false anti-virus flags:
pyinstaller --onefile --noconsole --icon=icon.ico nv.py
Replace icon.ico with the path to your icon file.
When compiling Python scripts to executable files using PyInstaller, the resulting executable might be flagged by some antivirus programs as suspicious or malicious. This is a known issue with PyInstaller and other similar tools, and it happens because:
Heuristic Analysis: Antivirus programs use heuristic analysis to detect unusual patterns that might indicate malicious behavior. Compiled Python scripts often exhibit such patterns because the Python interpreter, script, and all dependencies are bundled into a single executable file.
Code Obfuscation: Some parts of the Python script may be obfuscated to protect intellectual property, which can trigger false positives.
Lack of Reputation: Newly created or rarely downloaded files might not have an established reputation, making them more likely to be flagged as potential threats.
Use in Malware: Unfortunately, attackers sometimes use tools like PyInstaller to package malicious scripts, which has led to a negative reputation for executables created with these tools.