Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

Programming Languages

Programming Languages
52 posts | Last Activity on 07-11-2024 05:17 by Kevin
K
Kevin 07-11-2024 05:17, 5 days ago
Re: Setting up SFML (Simple and Fast Multimedia Library) in Visual Studio Code (VSCode)
Step 7: Configure SFML DLLs To avoid runtime errors, you need to copy SFML DLLs to your project directory: Go to the SFML/bin folder in your SFML installation and copy all .dll files. Paste them in your project folder, where main.exe will be generated. Step 8: Build and Run the Program In VSCode, open the Terminal (View > Terminal). To build, press Ctrl+Shift+B or go to Terminal > Run Build Task, and select the build task if prompted. Once built successfully, you can run it by pressing F5 (to debug) or simply run main.exe from the terminal. If everything is set up correctly, an SFML window should open, displaying a green circle. This means you’ve successfully set up SFML in VSCode!
K
Kevin 07-11-2024 05:16, 5 days ago
Re: Setting up SFML (Simple and Fast Multimedia Library) in Visual Studio Code (VSCode)
Step 6: Create launch.json for Debugging Configuration Inside the .vscode folder, create a file called launch.json. Add the following configuration: { "version": "0.2.0", "configurations": [ { "name": "Debug SFML", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/main.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "build", "miDebuggerPath": "C:/mingw64/bin/gdb.exe", // Adjust this path based on your MinGW installation "internalConsoleOptions": "openOnSessionStart" } ] } Make sure to update miDebuggerPath with the path to gdb.exe in your MinGW installation.
K
Kevin 07-11-2024 05:15, 5 days ago
Re: Setting up SFML (Simple and Fast Multimedia Library) in Visual Studio Code (VSCode)
Step 5: Create tasks.json for Build Configuration Inside the .vscode folder, create a file called tasks.json. Paste the following configuration, adjusting the paths to match your SFML installation: { "version": "2.0", "tasks": [ { "label": "build", "type": "shell", "command": "g++", "args": [ "-g", "${workspaceFolder}/main.cpp", "-o", "${workspaceFolder}/main.exe", "-I", "C:/SFML/include", "-L", "C:/SFML/lib", "-lsfml-graphics", "-lsfml-window", "-lsfml-system" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": ["$gcc"], "detail": "Compiles SFML program using g++" } ] } Adjust "C:/SFML/include" and "C:/SFML/lib" to match the actual location of your SFML installation.
K
Kevin 07-11-2024 05:14, 5 days ago
Re: Setting up SFML (Simple and Fast Multimedia Library) in Visual Studio Code (VSCode)
### Step 4: Write a Simple SFML Program In `main.cpp`, add a simple SFML program to test the setup: ```cpp #include <SFML/Graphics.hpp> int main() { sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!"); sf::CircleShape shape(50); shape.setFillColor(sf::Color::Green); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); } window.clear(); window.draw(shape); window.display(); } return 0; } ```
K
Kevin 07-11-2024 05:14, 5 days ago
Re: Setting up SFML (Simple and Fast Multimedia Library) in Visual Studio Code (VSCode)
Setting up **SFML (Simple and Fast Multimedia Library)** in **Visual Studio Code** (VSCode) requires a few steps, but with the right approach, you’ll have it running smoothly. Here’s a step-by-step guide to get SFML up and running in VSCode on Windows. I'll include steps for setting up with **MinGW** if you're using **GCC** as your compiler. ### Prerequisites - **Visual Studio Code** installed - **SFML library** downloaded from the [official website](https://www.sfml-dev.org/download.php) (make sure to download the version compatible with your compiler, usually the MinGW version if you are using GCC). - **MinGW** (for the GCC compiler) or another compiler of choice. ### Step 1: Install MinGW (if not installed) 1. Download and install MinGW from the [MinGW website](http://www.mingw.org/). 2. During installation, select the **gcc-g++**, **mingw32-gcc-g++**, and **mingw32-base** packages. 3. Add MinGW’s `bin` folder to your **system PATH** to access the compiler globally. ### Step 2: Extract SFML Files 1. Unzip the SFML package to a location on your computer (e.g., `C:SFML`). 2. Inside the SFML folder, you should see subfolders like `bin`, `include`, `lib`, etc. ### Step 3: Configure Your Project in VSCode 1. Open **Visual Studio Code** and create a new folder for your SFML project. 2. Inside this project folder, create the following files and folders: - `main.cpp` – this will hold your SFML test code. - `.vscode` – a folder to store VSCode configuration files.
C
caa 01-11-2024 23:10, 10 days ago
Re: Interactive Brokers (IBKR) Python API
### 9. **Error Handling and Logging** - Use `try-except` blocks to handle potential API errors, as network issues or invalid symbols could cause interruptions. --- ### Summary of Key Concepts with IBKR Python API: - **ib_insync** is a simplified and effective library for IBKR automation. - You can connect to TWS or IB Gateway and perform trading tasks, fetch market and account data, and create automated trading strategies. - **Event listeners** allow for reactive trading based on real-time data, suitable for algorithmic trading or monitoring. This setup provides you with a complete workflow to automate trading and manage portfolios with IBKR in Python. Let me know if you'd like examples on any specific functionality!
C
caa 01-11-2024 23:10, 10 days ago
Re: Interactive Brokers (IBKR) Python API
### 7. **Automating Trades with Event Listeners** - **ib_insync** provides event listeners to automate responses to market conditions. #### Example: Automated Trade Execution Based on Price Threshold ```python def on_bar_update(bars, hasNewBar): last_price = bars[-1].close print(f"Last Price: {last_price}") if last_price < 150: order = MarketOrder('BUY', 10) ib.placeOrder(stock, order) # Listen to bar updates for the specified stock ib.reqRealTimeBars(stock, 5, 'MIDPOINT', False) ib.realtimeBarEvent += on_bar_update ib.run() ``` --- ### 8. **Disconnecting and Closing the Session** - Always disconnect after completing tasks. ```python ib.disconnect() print("Disconnected from IBKR API") ```
C
caa 01-11-2024 23:10, 10 days ago
Re: Interactive Brokers (IBKR) Python API
# Monitor the order status ib.sleep(1) print(f"Limit Order Status: {trade.orderStatus.status}") ``` --- ### 6. **Managing Account Information and Portfolio** - Retrieve account and portfolio data with simple calls. #### Example: Fetching Account Information ```python account_values = ib.accountValues() for value in account_values: print(f"{value.tag}: {value.value}") ``` #### Example: Fetching Portfolio Holdings ```python portfolio = ib.portfolio() for position in portfolio: print(f"Symbol: {position.contract.symbol}, Quantity: {position.position}, Market Value: {position.marketValue}") ``` ---
C
caa 01-11-2024 23:09, 10 days ago
Re: Interactive Brokers (IBKR) Python API
# Convert to pandas DataFrame df = util.df(bars) print(df.head()) ``` --- ### 5. **Placing an Order** - Place orders programmatically by defining the **contract** and **order** types. #### Example: Placing a Market Order ```python from ib_insync import MarketOrder # Define a contract and order order = MarketOrder('BUY', 10) # Buy 10 shares trade = ib.placeOrder(stock, order) # Monitor the order status ib.sleep(1) print(f"Order Status: {trade.orderStatus.status}") ``` #### Example: Placing a Limit Order ```python from ib_insync import LimitOrder # Define a limit order to buy 10 shares at a specific price order = LimitOrder('BUY', 10, 150.00) # Buy 10 shares at $150 trade = ib.placeOrder(stock, order)
C
caa 01-11-2024 23:09, 10 days ago
Re: Interactive Brokers (IBKR) Python API
### 4. **Fetching Market Data** - Use the `ib_insync` API to get real-time or historical market data. #### Example: Fetching Real-Time Quotes ```python from ib_insync import Stock # Define the stock symbol and request market data stock = Stock('AAPL', 'SMART', 'USD') ib.qualifyContracts(stock) # Request market data ticker = ib.reqMktData(stock) ib.sleep(2) # Wait a couple of seconds to receive data print(f"Current Price for {ticker.contract.symbol}: {ticker.last}") ``` #### Example: Fetching Historical Data ```python bars = ib.reqHistoricalData( stock, endDateTime='', durationStr='1 D', barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True )
C
caa 01-11-2024 23:07, 10 days ago
Re: Interactive Brokers (IBKR) Python API
Interactive Brokers (IBKR) provides a Python API called **ib_insync** to interact with the TWS (Trader Workstation) or IB Gateway. This API allows Python applications to place trades, retrieve market data, manage accounts, and more. Here’s a guide to getting started with the **IBKR API using Python**: ### 1. **Setting Up Your IBKR Account and Enable API Access** - **Open an IBKR account** if you don’t have one. - **Enable API access** in the TWS or IB Gateway under `Configuration > API > Settings`, and allow connections from localhost. - **Download and install IB Gateway or Trader Workstation (TWS)** as the API requires one of these to be running. ### 2. **Installing ib_insync** - **ib_insync** is a popular Python wrapper for the IB API, making it simpler to work with than the official `ibapi` library. - Install `ib_insync`: ```bash pip install ib_insync ``` ### 3. **Connecting to IBKR with ib_insync** - Run TWS or IB Gateway and note the **port** (usually 7497 for TWS paper trading or 4001 for IB Gateway paper trading). - Connect to the IB API by creating an instance of `IB()`. #### Example: Establishing a Connection ```python from ib_insync import IB # Initialize and connect to the IBKR API ib = IB() ib.connect('127.0.0.1', 7497, clientId=1) # clientId should be unique for each connection # Check connection if ib.isConnected(): print("Connected to IBKR API") else: print("Connection failed") ```
C
caa 01-11-2024 10:40, 11 days ago
Re: popular online Python compilers
Here are some popular online Python compilers that you can use to write, run, and test Python code: 1. **Repl.it** - [https://replit.com/](https://replit.com/) - Supports multiple programming languages and includes a collaborative coding environment. 2. **Google Colab** - [https://colab.research.google.com/](https://colab.research.google.com/) - Provides access to GPU and TPU resources, making it ideal for machine learning and data science projects. 3. **Programiz** - [https://www.programiz.com/python-programming/online-compiler/](https://www.programiz.com/python-programming/online-compiler/) - Offers a simple interface with basic Python functionalities. 4. **OnlineGDB** - [https://www.onlinegdb.com/](https://www.onlinegdb.com/) - Supports debugging, multiple languages, and has a beginner-friendly interface. 5. **PythonAnywhere** - [https://www.pythonanywhere.com/](https://www.pythonanywhere.com/) - Good for running longer scripts and provides a simple, in-browser Python environment with free and paid plans. 6. **JDoodle** - [https://www.jdoodle.com/python3-programming-online/](https://www.jdoodle.com/python3-programming-online/) - Has basic features for executing Python code and allows for easy sharing and collaboration. These platforms vary in functionality, so you may choose one depending on your specific needs (like basic scripting vs. machine learning).
C
caa 25-10-2024 05:49, 18 days ago
Re: Python to pull data for Nifty 50 stocks and save it as an Excel file
To get all Nifty 50 stocks into an Excel sheet, you can use the NSE India website, an API, or a web scraping method. Here are three methods: Method 1: Manual Download from NSE India Go to the NSE India website: https://www.nseindia.com/market-data/live-equity-market. Click on Nifty 50 under the benchmark indices section. Select the option to Download CSV (usually available on the page). Open the downloaded file in Excel.
C
caa 25-10-2024 05:47, 18 days ago
Re: Python to pull data for Nifty 50 stocks and save it as an Excel file
you can use Python to pull data for Nifty 50 stocks and save it directly as an Excel file: Steps: Install yfinance and pandas if you haven't already: [code]pip install yfinance pandas openpyxl[/code] Run the following code to fetch the Nifty 50 stocks and save them in an Excel file: [code] import yfinance as yf import pandas as pd # Fetch Nifty 50 tickers (replace with actual tickers if needed) nifty50_tickers = [ "RELIANCE.NS", "TCS.NS", "HDFCBANK.NS", "INFY.NS", "HINDUNILVR.NS", "ICICIBANK.NS", "HDFC.NS", "SBIN.NS", "KOTAKBANK.NS", "BHARTIARTL.NS", # Add all other tickers here ] # Fetch data and create a DataFrame data = {ticker: yf.Ticker(ticker).info for ticker in nifty50_tickers} df = pd.DataFrame(data).T # Transpose for a better view # Select and clean the columns as needed df = df[['symbol', 'longName', 'sector', 'marketCap']] # Save to Excel df.to_excel("Nifty50_Stocks.xlsx", index=False) print("Data saved to Nifty50_Stocks.xlsx")[/code] This code fetches basic data on Nifty 50 stocks like name, sector, and market cap, but you can add more fields as required. The final output is an Excel file named Nifty50_Stocks.xlsx in the current directory.
K
Kevin 24-10-2024 00:42, 19 days ago
Re: execute trades simultaneously across multiple brokers such as Upstox, Zerodha, and Alice Blue
### 4. **Order Flow Logic** Write logic for: - **Placing an order**: Based on market conditions or trading signals. - **Order monitoring**: Track whether the orders are filled, partially filled, or rejected. - **Retry mechanism**: In case an order fails on one platform, retry it. ### 5. **Security and Scalability** - Store API keys securely using **environment variables** or a secrets manager. - Use HTTPS and ensure your system has proper rate limiting in place to avoid hitting API request limits. ### 6. **Broker Fees & Latency** Consider the differences in fees, latency, and execution times across brokers to avoid slippage or missed opportunities.
K
Kevin 24-10-2024 00:42, 19 days ago
Re: execute trades simultaneously across multiple brokers such as Upstox, Zerodha, and Alice Blue
To execute trades simultaneously across multiple brokers such as Upstox, Zerodha, and Alice Blue, you can build a solution that uses APIs provided by each broker. Here's a high-level approach: ### 1. **API Integration** Each broker offers APIs that allow you to place orders, retrieve market data, and manage your portfolio. You will need to: - Sign up for API access for each broker. - Implement API clients to interact with the respective broker systems. **Broker API Links:** - **Upstox API**: [Upstox Developer](https://upstox.com/developer/) - **Zerodha Kite API**: [Zerodha Kite Connect](https://kite.trade/) - **Alice Blue API**: [Alice Blue Developer API](https://docs.aliceblueonline.com/) ### 2. **Unified Trading System** Develop a unified system that can: - **Authenticate**: Log into all brokers using API keys or OAuth. - **Order Placement**: Send the same order (buy/sell) across multiple brokers. - **Error Handling**: Manage cases where one broker succeeds while another fails (retry or fallback strategies). - **Order Synchronization**: Ensure that order statuses are consistent and track fills, partial fills, and rejections. ### 3. **Multithreading or Asynchronous Execution** Use **multithreading** (in Python) or **async programming** (like in Node.js) to ensure orders are executed simultaneously: - In Python, you can use libraries like `threading` or `asyncio` to place orders concurrently. - For Node.js, use `Promise.all()` or other asynchronous constructs.
K
Kevin 13-10-2024 22:24, 29 days ago
Re: Creating Instagram Reels with Excel
### 5. **Use Excel Themed Elements** - **Highlight important sections**: Use colored boxes or zoom in on cells with key formulas. - **Add transitions**: Show before-and-after shots of data being transformed using Excel functions. - **Animate Excel content**: Use PowerPoint to create animated charts and then screen record them. ### 6. **Export and Post on Instagram** - Export the video in **vertical format (9:16)** as Instagram Reels are optimized for that. - Keep the size under **500MB** and the video length under 60 seconds for smooth uploads. - Use Excel-related hashtags like #ExcelTips, #ExcelHacks, or #DataVisualization to increase visibility. ### 7. **Add Engaging Captions and Tags** - **Ask questions**: E.g., “Did you know about this Excel hack?” to boost interaction. - **Hashtags**: Use trending hashtags like #Excel, #Productivity, #TechTips. - **Engage with comments**: Encourage people to ask questions about the Excel tip you showcased. ### Optional Tools: - **Canva or InShot** for adding dynamic effects, captions, and other elements. - **Snagit** or **LightShot** for screenshot annotations if you want to highlight steps with images. Would you like suggestions for specific content ideas, or do you need help with a particular step in the creation process?
K
Kevin 13-10-2024 22:24, 29 days ago
Re: Creating Instagram Reels with Excel
Creating Instagram Reels with Excel can be a fun way to showcase tips, tricks, and creative hacks using Excel. Here's how you can do it, even if you’re not a pro at video creation: ### 1. **Plan the Content** - **Pick a theme**: Think of useful Excel tricks (e.g., conditional formatting, formulas, pivot tables, charts). - **Keep it short**: Instagram Reels are 15 to 90 seconds long, so choose quick tips or hacks that can be shown briefly. - **Add value**: Show solutions to common Excel problems (e.g., “How to automate reports” or “5 cool Excel shortcuts”). ### 2. **Record Excel Screen** - **Use screen recording software**: Record yourself performing the Excel tricks. - On Windows, you can use the **Xbox Game Bar** (Win + G). - On Mac, you can use **QuickTime**. - Use third-party tools like OBS Studio or Loom for more features (narration, webcam). - **Use a good resolution**: Ensure the text is readable on mobile screens (1280x720 is a good starting point). ### 3. **Edit Your Video for Reels** - **Trim and cut**: Use video editing software to cut unnecessary parts and keep it under 60 seconds. - Free options: iMovie, CapCut (for mobile editing), or DaVinci Resolve (for advanced editing). - **Add text overlays**: Highlight key points using captions, arrows, or pop-ups. - **Add transitions and effects**: Use effects to make transitions smoother and keep the audience engaged. ### 4. **Add Background Music or Voiceover** - Instagram provides a library of music you can use. - **Voiceovers**: Explain your steps while recording or add voiceover narration in post-production using the editing tool.
C
caa 13-10-2024 00:22, 1 month ago
Re: create a live stock chart (candle stick chart) in excel
Make sure to handle your API key properly. Automating updates using VBA can allow live chart updates at intervals.
C
caa 13-10-2024 00:21, 1 month ago
Re: create a live stock chart (candle stick chart) in excel
To create a live candlestick stock chart in Excel, follow these steps: ### Step-by-Step Guide: #### 1. **Prepare Your Data**: - Create columns for **Date**, **Open**, **High**, **Low**, **Close** values of the stock price. - Fill this data manually or fetch it from a stock API using a VBA script (e.g., Alpha Vantage or Yahoo Finance). #### 2. **Insert a Candlestick Chart**: - Highlight your data (Date, Open, High, Low, Close columns). - Go to **Insert** > **Charts** > **Stock Charts** > **Open-High-Low-Close Chart**. - Excel will generate a basic candlestick chart. #### 3. **Format the Chart**: - Customize colors for bullish/bearish candles. - Add titles, gridlines, and other formatting options. #### 4. **Automate with Live Data** (Optional): - Use a VBA macro to periodically refresh stock prices from the API. - Here's a simple VBA script to fetch live stock data (using Alpha Vantage): ```vba Sub GetStockData() Dim url As String Dim xmlHttp As Object Dim json As Object url = "https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=IBM&interval=1min&apikey=YOUR_API_KEY" Set xmlHttp = CreateObject("MSXML2.XMLHTTP") xmlHttp.Open "GET", url, False xmlHttp.Send ' Parse and update your Excel sheet with data ' You'll need to use a JSON parser or manually handle it. End Sub ``` ### Final Notes: - Make sure to handle your API key properly. - Automating updates using VBA can allow live chart updates at intervals.
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?
Users Online Now
Guests Online 1
Members Online 0

Total Members: 11
Newest Member: Jhilam