Replies

bolatfx
19 Nov 2024, 03:51

It seems possible with the following code.

package main

import (
	"crypto/tls"
	"demo/openapi"
	"encoding/binary"
	"fmt"
	"net"
	"time"

	"google.golang.org/protobuf/proto"
)

func main() {
	var HOST string = "live.ctraderapi.com"
	var PORT uint32 = 5035
	var CLIENT_ID string = "x"
	var CLIENT_SECRET string = "x"

	addr := fmt.Sprintf("%s:%d", HOST, PORT)
	tcpAddr, _ := net.ResolveTCPAddr("tcp", addr)
	iconn, _ := net.DialTCP("tcp", nil, tcpAddr)

	cfg := tls.Config{
		InsecureSkipVerify: true,
	}
	conn := tls.Client(iconn, &cfg)

	req := &openapi.ProtoOAApplicationAuthReq{
		PayloadType:  nil,
		ClientId:     &CLIENT_ID,
		ClientSecret: &CLIENT_SECRET,
	}

	out, _ := proto.Marshal(req)

	//add
	msg := openapi.ProtoMessage{
		Payload:     out,
		PayloadType: proto.Uint32(uint32(2100)),
	}

	data, _ := proto.Marshal(&msg)

	lentgh := make([]byte, 4)
	binary.BigEndian.PutUint32(lentgh, uint32(len(data)))
	//out = append(length, out...)

	conn.Write(lentgh)
	conn.Write(data)

	for {
		head := make([]byte, 4)
		_, err := conn.Read(head)
		if err != nil {
			return
		}
		data = make([]byte, binary.BigEndian.Uint32(head))
		_, err = conn.Read(data)
		if err != nil {
			return
		}
		var res openapi.ProtoMessage
		err = proto.Unmarshal(data, &res)
		if err != nil {
			return
		}
		//buffer := make([]byte, 1024)
		//conn.Read(buffer)
		fmt.Println("Response:", &res)
		time.Sleep(time.Second)
	}
}

@bolatfx

bolatfx
07 Apr 2024, 05:34

I think you need to select "Trading" when issuing the app's token.


@bolatfx

bolatfx
25 Mar 2024, 08:39

RE: About prices used in real-time SMA

PanagiotisCharalampous said: 

Hi there,

It uses the last x prices defined by the MA period including the current one.

Best regards,

Panagiotis

thank you. I use the closing price of the candlestick for SMA calculation, but in real time, the candlestick is not completed yet. What should I use instead of the closing price in such a case?


@bolatfx

bolatfx
24 Mar 2024, 01:33

When I checked again, it seems that either Ask or Bid is missing.


@bolatfx

bolatfx
27 May 2023, 07:20 ( Updated at: 21 Dec 2023, 09:23 )

RE:

PanagiotisChar said:

Hi there,

Just tried it using the sample application and works fine

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

I solved it.
It seems that to use the new URL, it was necessary to turn off TLS certificate validation.


@bolatfx

bolatfx
25 May 2023, 16:30 ( Updated at: 25 May 2023, 16:31 )

RE:

PanagiotisChar said:

Hi there,

Try port 5035. Looks like a typo in the documentation.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Error on port 5034: TimeOut
Error on port 5035: invalid peer certificate: CertNotValidForName

 


@bolatfx

bolatfx
27 Dec 2019, 09:16

RE:

PanagiotisCharalampous said:

Hi bolatfx,

The first value represents an actual timestamp and an actual price (to get the price just divide by 100.000)

0 timestamp:1577428963249 tick:10950900 

The rest of the values represent the difference from the previous value. Let me know if this is clear.

Best Regards,

Panagiotis 

Join us on Telegram

 

 

Thanks, Panagiotis.

I want to confirm further,

1. Isn't it sorted in timestamp order?

2. Is the 0th element the last tickdata?


@bolatfx