Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (blaurock), 750 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Rotate script #487992
12/17/23 10:09
12/17/23 10:09
Joined: Oct 2017
Posts: 56
Munich
K
kalmar Offline OP
Junior Member
kalmar  Offline OP
Junior Member
K

Joined: Oct 2017
Posts: 56
Munich
Hi all,

There is a rotate.c script in Strategy folder. Is there any description what it could be used for? I'm reading it, but would be useful if there is more explanation.

Thx

Re: Rotate script [Re: kalmar] #487993
12/17/23 14:53
12/17/23 14:53
Joined: Sep 2017
Posts: 82
T
TipmyPip Offline
Junior Member
TipmyPip  Offline
Junior Member
T

Joined: Sep 2017
Posts: 82
Thank you for your interest, The rotate.C strategy is a portfolio management. The strategy functions as a mathematical model for portfolio optimization, drawing from a matrix-like dataset to align current asset holdings with predefined targets. It employs vector comparisons to calculate trade adjustments, ensuring alignment through sequential logic. Human oversight is integrated through a confirmation step before trade execution. The strategy then iteratively adjusts each asset's position, mirroring the process of solving a system of equations. Post-execution, a detailed log akin to an annotated mathematical proof records the strategy's actions, encapsulating a blend of algorithmic precision and strategic decision-making.


ZorroTraderGPT - https://bit.ly/3Gbsm4S
Re: Rotate script [Re: kalmar] #487995
12/17/23 20:41
12/17/23 20:41
Joined: Oct 2017
Posts: 56
Munich
K
kalmar Offline OP
Junior Member
kalmar  Offline OP
Junior Member
K

Joined: Oct 2017
Posts: 56
Munich
Sounds like Zorro GPT answer laugh

Re: Rotate script [Re: kalmar] #487999
12/20/23 12:38
12/20/23 12:38
Joined: Sep 2017
Posts: 82
T
TipmyPip Offline
Junior Member
TipmyPip  Offline
Junior Member
T

Joined: Sep 2017
Posts: 82
Well, your income sure depends on how flexible you can be, and adapt Technology.


ZorroTraderGPT - https://bit.ly/3Gbsm4S
Re: Rotate script [Re: kalmar] #488019
12/28/23 14:47
12/28/23 14:47
Joined: Sep 2017
Posts: 82
T
TipmyPip Offline
Junior Member
TipmyPip  Offline
Junior Member
T

Joined: Sep 2017
Posts: 82
Has anyone tried this code and found a way to improve it? Zorro S version has functions that can incorporate better remote algorithmic control

Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TO_CSVHDR "Asset,Weight%%,Margin,Lots,MarginCost"
#define TO_CSV "\n%s,%.0f,%.0f,%.0f,%.0f"

char* Filename = "Data\\MyStrategy.csv"; // rotation list
char* Fileformat = "ss,f,f,f";
char* Outfile = "Log\\Rotation.log";
char* TickerSymbol = "*";
// char* TickerSymbol = "*-STK-SMART-USD!STOOQ:*";
#define NEWWEIGHT 1 // weight percent field number
#define NEWLOTS 3   // lots field number
#define LEVERAGE 1

double AssetInt[12]; // Assuming AssetInt is an array of doubles

void folioTrade(int LS) {
    // Assuming used_assets is an array of asset names
    for (int i = 0; i < sizeof(used_assets) / sizeof(used_assets[0]); i++) {
        asset(used_assets[i]);
        if ((OpenLots > NewLots && LS < 0) || (OpenLots < NewLots && LS > 0)) {
            enterLong(NewLots - OpenLots);
        }
    }
}

int main() {
    int i;
    int Records;
    double Invest = 0;

    LookBack = 0;
    StartDate = NOW;
    set(LOGFILE);
    SaveMode = 0;

    Filename = file_select("Data", "Rotation Lists\0*.csv\0\0");
    Records = dataParse(1, Fileformat, Filename);
    if (!Records) {
        return quit("CSV file not found");
    }

    printf("\nSubscribing %i assets..", Records);
    brokerCommand(SET_PRICETYPE, 8); // get prices fast
    char Box[50000] = "\n---------------------------------";
    int Changed = 0;

    for (i = 0; i < Records; i++) {
        printf(".");
        char* Ticker = dataStr(1, i, 0);
        assetAdd(Ticker, TickerSymbol);
        if (!asset(Ticker)) continue;
        NewLots = dataVar(1, i, NEWLOTS);
        OpenLots = brokerCommand(GET_POSITION, Ticker);
        double Margin = NewLots * priceC(0) / LEVERAGE;
        Invest += Margin;

        if (OpenLots != NewLots) {
            Changed = 1;
            strcat(Box, strf("\n%s \t%d -> %d@%s ($%.2f)",
                Asset, OpenLots, NewLots, sftoa(priceC(0), 2), Margin));
        } else if (OpenLots) {
            strcat(Box, strf("\n%s \t%d@%s ($%.2f)",
                Asset, OpenLots, sftoa(priceC(0), 2), Margin));
        }
    }

    strcat(Box, "\n---------------------------------");
    strcat(Box, strf("\nTotal margin $%s at %s",
        sftoa(Invest, 4), strdate(YMDHMS, NOW)));

    if (!Changed) {
        printf("\nPortfolio unchanged");
    } else {
        strcat(Box, "\nModify Portfolio?");
        if (msg(Box)) {
            strcat(Box, " Y");
            setf(TradeMode, TR_GTC);
            folioTrade(-1); // Short
            folioTrade(1);  // Long
            file_append(Outfile, Box, 0);
            exec("Editor", Outfile, 0);
        } else {
            printf("\nNo positions entered");
        }
    }

    return 0;
}


ZorroTraderGPT - https://bit.ly/3Gbsm4S
Re: Rotate script [Re: kalmar] #488020
12/28/23 14:58
12/28/23 14:58
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Code
for (int i = 0; i < sizeof(used_assets) / sizeof(used_assets[0]); i++) {
This GPT-generated code clearly does not know how the Zorro macros work. It seems to think the macro is a struct.

You should discipline your GPT.

Re: Rotate script [Re: AndrewAMD] #488025
12/29/23 18:19
12/29/23 18:19
Joined: Sep 2017
Posts: 82
T
TipmyPip Offline
Junior Member
TipmyPip  Offline
Junior Member
T

Joined: Sep 2017
Posts: 82
Thank you for your suggestion Andrew, we always want to improve on our knowledge, and abilities to cooperate.

The code is meant for users to explore, learn, and try out new ideas... If I will share code without errors, no one will learn anything new, and just forget about it in 4 hours. (In addition, when you are inspired by different ideas, you improve your level and go beyond your limits, because loops aren't structures, rather than building blocks that require you to dig deeper, and find ideas you have not thought about.)

It would be even more informative for you to work with it together and improve your own ideas... We are all here to learn together.

In addition, users will enjoy your input even more, when you too share some code and explain yourself, we are all here to enjoy your contribution, please...

And remember you are always blessed, with happiness and money as well as new ideas.

Last edited by TipmyPip; 12/29/23 18:43.

ZorroTraderGPT - https://bit.ly/3Gbsm4S
Re: Rotate script [Re: AndrewAMD] #488026
12/30/23 16:48
12/30/23 16:48
Joined: Sep 2017
Posts: 82
T
TipmyPip Offline
Junior Member
TipmyPip  Offline
Junior Member
T

Joined: Sep 2017
Posts: 82
Dear Andrew, I believe that you are a very clever person and a great programmer...

Would you kindly please share with us your understanding, and knowledge of what is the reason you think the following statement has anything to do with struct and why are you referring to macros?

Code
for (int i = 0; i < sizeof(used_assets) / sizeof(used_assets[0]); i++) {


We truly want to learn from you... Thank you.

Last edited by TipmyPip; 12/30/23 16:48.

ZorroTraderGPT - https://bit.ly/3Gbsm4S

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1