#How difficult is building a p2p exchange using c++?

114 messages · Page 1 of 1 (latest)

analog pilotBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

wheat cobalt
#

"how difficult" questions are generally not helpful

#

since difficulty is based on experience and the innate difficulty of a task, not just the innate difficulty alone

#

but pretty difficult I would say

#

there are more difficult things, there are less difficult things

past hearth
#

well what are the difficult aspects in developing this project

#

isnt it just a orderbook and matching engine

#

Like I am confused where the difficulties lie?

scarlet barn
#

What is p2p

#

Peer to to peer?

wheat cobalt
#

difficulty lies in the generic difficulity of networking

past hearth
#

yes

past hearth
#

sorry I am quite new to c++ I know C, python and R. I really don't know how this is a project that is not doable

wheat cobalt
# past hearth explain
  1. dealing with failures (which are guaranteed to happen with networks)
  2. security
  3. multithreading usually required for any sort of efficeincy
  • all the stuff you want on top of that
#

oh don't get me wrong Im not saying don't try

past hearth
#

ok

wheat cobalt
#

if you;ve never done c++ before its going to be hard because structuring c++ in a large project is itself an ordeal
and then you're going to need to learn a networking library/api on top of this

#

BUUT

#

go for it

#

if its something you're passionate about don't let difficulty be a reason not to do something

#

you learn the most from difficult things

past hearth
#

well, you have to break this project in different pieces

#

you cant build an API off the bat

wheat cobalt
#

you probably should otherwise how are you going to test anything

past hearth
#

what if it was manual click: buy stock of x and sell stock of x

#

sorry am I naive in building this project

scarlet barn
#

See for yourself try to build a multiple client single server project in Boost asio.

past hearth
#

like I might be

scarlet barn
#

You want a GUi too?

past hearth
#

but yeah

#

yeah

scarlet barn
#

Okay

wheat cobalt
#

im not saying start off with what you want from the beginning. IM saying you should probably have something to test as you go

scarlet barn
#

Then that's gonna be really far more complicated

#

You are better off reading the QT framework

past hearth
#

qt meaning quality testing?

wheat cobalt
#

idk I would say likely similar amount of complicated since you're jsut going to learn a UI library like QT anyway

scarlet barn
#

And see all the tools you need to build a GUI

#

No

wheat cobalt
#

not QT is the name of a gui library

scarlet barn
#

QT Framework

wheat cobalt
#

/generic framework for lots of things

#

but often use for guis

past hearth
#

okay

#

so how should I build this like if you were in my shoes and passionate about building a demo, what would you build first

scarlet barn
#

Try yourself

#

Build a a simple app in QT

#

See how well you do

wheat cobalt
past hearth
#

is it free

#

or what is the cost

scarlet barn
#

Yeah its free for people with open license

#

My company doesn't use Qt even though we do have exchange trading system

#

For crypto and derivatives

past hearth
#

is it built on c++?

scarlet barn
#

Yes

past hearth
#

how long did it take to develop it

scarlet barn
#

Wxwidgets

#

Our company has 4 million lines of code

#

Lol

past hearth
#

how many years tho

scarlet barn
#

20 years

#

Lol

past hearth
#

is this coinbase

#

lmao

scarlet barn
#

No

#

It's interactive brokers

past hearth
#

okay but a demo

#

does not need to be 4M lines

#

lol

#

like that is a bit unreasonable

#

i just wanted to show buying and selling

#

on a single exchange server

#

maybe even skip the gui

#

just you know proof of concept

scarlet barn
#

Oh without the GUI

#

Then that stuff is easy

past hearth
#

yes

#

you can build gui later right

scarlet barn
#

Try to build a single server multiple client

#

In boost asio

#

See how well you do

#

If you can make that work on your own then that's a start

past hearth
#

within the single server multiple client you can build a orderbook

#

and matching engine correct?

scarlet barn
#

Yes

past hearth
#

how many lines of code should this be btw

scarlet barn
#

To do this properly? Implement sha 256 properly, a synchronized order keeping queue. I estimate about 2k to 3k

past hearth
#

okay

#

let me create a design document then

#

for my own peace of mind

scarlet barn
#

Try it yourself build a simple single client multiple server project in boost asio. If just want to do it raw on the TCP then maybe take a look at websocketpp

past hearth
#

what are the pros and cons

#

if you dont mind me asking

scarlet barn
#

Websocketpp is strictly a websocket library

#

And its easier

#

To use standardize payloads with other libraries

#

Like protobuf

past hearth
#

I asked chatgpt: 1. Set Up Boost.Asio in Your Project
Make sure Boost and Boost.Asio are installed and configured in your development environment.
2. Create a Server Class
Start by creating a server class that will manage client connections.
The server should have an io_context object from Boost.Asio, which provides core synchronous and asynchronous I/O functionality.
Implement a method to start accepting client connections. This typically involves setting up an asynchronous accept operation with a socket that waits for new client connections.
3. Handle Client Connections
When a client connects, the accept operation should create a new session or connection object.
Each client connection can be handled in a separate session object, which holds a socket for client communication.
Implement read and write operations for the session. These can be asynchronous to handle I/O without blocking.
4. Create a Client Class
Similar to the server, create a client class that can connect to the server.
The client will also need an io_context and a socket.
Implement functionality to connect to the server, and to send and receive data.
5. Implement Asynchronous Operations
Both server and client should use asynchronous operations (like async_read, async_write, and async_accept) to handle I/O. This allows the server to manage multiple clients simultaneously without blocking on individual operations.
6. Run the io_context
The io_context's run method needs to be called to start processing asynchronous operations. This can be done in a separate thread if you need to perform other tasks concurrently.
7. Error Handling
Properly handle errors in network operations, such as disconnections and data transfer errors.
8. Testing
Test the server with multiple clients to ensure it handles simultaneous connections and data communication correctly.

scarlet barn
#

How would you standardize messages?

#

And payloads?

#

In boost asio

past hearth
#

but arent websockets platform dependent?

scarlet barn
#

No when you use websocketpp

#

It's pretty cross platform

#

Only authentication is different

past hearth
#

so websockets are better?

scarlet barn
#

For raw speed? Yeah

#

For continous reads on thr wire? ho yes

analog pilotBOT
#

<@undefined>

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

past hearth
#

!Solved

#

!solved