Coder Social home page Coder Social logo

zccz14 / yuan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from no-trade-no-life/yuan

1.0 1.0 0.0 12.82 MB

Yuan - Investment OS for everyone

Home Page: https://y.ntnl.io

License: MIT License

Shell 0.08% JavaScript 0.08% TypeScript 98.30% Dockerfile 0.84% HTML 0.07% CSS 0.26% CMake 0.07% C++ 0.30%

yuan's Introduction

Language TS Contributors Forks Stargazers MIT License

Discord Issues Bugs Open Bugs Closed


Logo

Yuan

The investment Operating System for everyone

AI empowered, global market, serverless, cloud-native, and privacy.

Access the Yuan GUI from any device »

Read the Docs 📖 · Report Bug 🐛 · Request Feature 💡 · Join Discord

Snapshots

image

image

image

Motivation

In the early stages of our quantitative trading endeavors, after extensively searching and researching various existing quantitative trading frameworks and products, we found that none could fully meet the development and research needs of our unique trading strategies. Thus, undeterred by the challenges, we embarked on creating our own product, Yuan, driven by our specific requirements.

Our fundamental demands are:

  1. Strong Privacy Security

    Quantitative model codes are the core assets of users and should not be at risk of theft. Many products on the market require uploading strategy codes to servers, where they can be fully assessed and potentially stolen. If a user's strategy can be grasped by potential competitors, the user will be at a disadvantage. Therefore, some products allow private deployment. We designed a local workspace for users that ensures privacy against various attacks and allows us to prove our integrity.

  2. Full Market Compatibility

    Users invest and trade in different markets. We aim for the same strategy code to be applicable across various market types, both for historical backtesting and live trading, without any additional costs. We also hope the platform can support a wide range of markets. However, existing products often only support a subset of markets due to regional regulations and business constraints, forcing users to use different platforms for different markets. Through architectural design, we have decoupled the core, deploying business plugins to the market, which not only reduces coupling and improves software quality but also overcomes compliance barriers, setting the stage for global expansion.

  3. Cross-Platform Compatibility

    We want our product to run without restrictions on any device, whether on desktop or mobile platforms. After all, the market does not cater to where users are. Users should be able to engage with the market at any time, in any setting.

  4. Low Cost with High Scalability

    The industry's initial licensing fees, often in the thousands, are daunting, not to mention the high additional and maintenance costs. We believe these costs are partly due to bundling to offset development expenses, partly due to inefficient operations, and partly due to profiteering. As a product aimed at individual investors rather than enterprises, we must consider the financial capabilities of ordinary investors. For investors, the most important aspect of tools is affordability and durability. Whether it's a personal computer or a server cluster, our product can operate effectively.

Yuan is an investment operating system designed to empower you to master your finances.

(back to top)

Why use Yuan

Powerful Web GUI

With Yuan Web GUI, you have access to a comprehensive solution for creating, testing, and managing your trading system, as well as deploying and monitoring your applications. The GUI is completely open-source and can be deployed anywhere, without an internet connection. You can easily switch between multiple environments using just one GUI, making your experience more streamlined.

We have designed the GUI with modern browsers in mind, and it integrates with the latest web technologies, such as WebWorker, FileSystemHandle, WebRTC, and more. It is highly responsive and fast, and we are constantly working to make it even better for you.

Although the GUI is currently written in Chinese, we have plans to make it internationalized, so you can use it in your native language in the future. We welcome contributions to the project's translation, so everyone can benefit from this amazing tool. You can access the GUI for free under the MIT license, without the need to install anything - simply use the GUI.

Simple language and AI assistant

If you're interested in developing a trading strategy without the need to learn a new language or DSL, the modern JavaScript/TypeScript language is an excellent option. You can use any IDE to write your code and any version control system to manage it. If you have difficulty with coding, you can seek assistance from an AI assistant by communicating your idea to it.

// It's a simple trend-tracking trading strategy that uses the SMA indicator.
import { useSMA, useSimplePositionManager } from '@libs';
export default () => {
  const { close } = useOHLC('Y', 'XAUUSD', 'PT1H');
  const ma20 = useSMA(close, 20);
  const accountInfo = useAccountInfo();
  const [targetVolume, setTargetVolume] = useSimplePositionManager(accountInfo.account_id, 'XAUUSD');
  useEffect(() => {
    const idx = close.length - 2;
    if (close[idx] > ma20[idx]) {
      setTargetVolume(1);
    } else {
      setTargetVolume(0);
    }
  }, [close.length]);
};

More examples can be found here.

Local, cloud...or hybrid!

Yuan is a hybrid-cloud software that allows you to deploy your trading system in your home or public cloud simultaneously. You can start using your home PC and then gradually switch to the public cloud as your business grows. Choosing between your home PC or the public cloud will depend on your availability, costs, privacy, and security requirements.

Extension-first Ecosystem

In Yuan, extensions are treated as first-class citizens. Many core features are built and distributed as extensions. You can use extensions to add new features, connect with more markets, and enhance your experience. You can download extensions from the community or create your own extensions to share with others.

(back to top)

Built with

TypeScript reactivex react kubernetes docker prometheus mongodb zeromq openai nginx pnpm monaco editor vite rollup ajv webrtc letsencrypt

(back to top)

Getting started (for developers) 🚀

Prerequisites: nodejs >= 18.17.0, docker for image build, and rush for mono repo management.

npm install -g @microsoft/rush

Then you can install dependencies and build projects

rush update && rush build

If you have no docker installed, you can skip the docker build by setting the environment variable CI_RUN to true.

CI_RUN=true rush build

(back to top)

Packages

Libraries

All the libraries should be independent of the platform by default. They can be used in the browser, node.js, or other platforms. And provide both ESM and CommonJS modules.

  • @yuants/data-model Data Model and related utils.
  • @yuants/protocol Network protocol, service definition and infrastructure.
  • @yuants/utils Some general utils that are not found in the community.
  • @yuants/kernel The kernel of Time-Machine. Time-Machine can travel from history to the future. This package also contains some useful units and scenes.
  • @yuants/agent Agent is a trading bot. The agent contains the core of the trading strategy.
  • @yuants/extension This defined the extension interface. You can use extensions to enhance your experience.
  • @yuants/prometheus-client Prometheus client for the browser / node. Better performance than promjs.

Apps

All the apps should provide an image and publish it as a npm package. You can deploy the app by docker and Kubernetes. You can find the App List and get the image. All the apps implemented the extension interface. So you can treat them as extensions.

  • @yuants/app-host Host is a very lightweight message broker. Terminals can connect to the host and send messages to each other. Notice that all terminals in a host should trust each other. In practice, all the terminals in a host belong to the same owner. There's no need to verify every message. You can deploy multiple hosts to isolate the risk.
  • @yuants/app-market-data-collector This will deploy a terminal as a data-collecting service. The terminal collects market data from the market terminals continuously.
  • @yuants/app-data-collector This will deploy a terminal as a data-collecting service. The terminal collects series data from the data series provider terminals continuously. It's a general version of the market data collector. You can use it to collect any data series.
  • @yuants/app-agent This will deploy a terminal as the daemon service of the agent. You can run the agent in real mode. It can automatically correct the history data error. It can also automatically restart the agent when it crashes.
  • @yuants/app-alert-receiver This will deploy a terminal as an alert-receiving service. It receives alerts from the alert terminals and sends them to the notifier terminals.
  • @yuants/app-mongodb-storage This will deploy a terminal as a storage service. It stores data in MongoDB.
  • @yuants/app-email-notifier This will deploy a terminal as a notifier service. It sends notifications to your email.
  • @yuants/app-feishu-notifier This will deploy a terminal as a notifier service. It sends notifications to your Feishu by a Feishu bot.
  • @yuants/app-trade-copier This will deploy a terminal as a trade copier service. It watches the source accounts and ensures the target accounts follow the source accounts.
  • @yuants/app-metrics-collector This will deploy a terminal as a metrics-collecting service. The metrics collector collects metrics from terminals continuously. It works with Prometheus.
  • @yuants/app-account-composer This will deploy a terminal as an account-composing service. It composes multiple account info into one account info. So you can view your money dispersed across many accounts.
  • @yuants/app-general-datasource This will deploy a terminal as a general data source service. It composes multiple specific data sources into one general data source. Useful for creating an index price series.
  • @yuants/app-general-realtime-data-source This will deploy a terminal as a general real-time data source service. It's the real-time version of the general data source. Useful for creating an index price ticks.
  • @yuants/app-k8s-manifest-operator This will deploy a terminal as a Kubernetes manifest operator. It watches the manifest CRD of the Kubernetes cluster and ensures the Kubernetes cluster follows the manifest CRD. You can add manifest CRD to the k8s cluster and then the operator will deploy the resources defined in the manifest CRD.
  • @yuants/app-transfer-controller A transfer controller is a service that transfers money between accounts. It watches the transfer request and ensures the transfer is completed.
  • @yuants/app-risk-manager This will deploy a terminal as a risk manager. It makes transfer decisions based on the configured risk info.

Web UI

@yuants/ui-web is the GUI. You can do anything with the GUI because we prefer to implement the feature in GUI rather than CLI. All the users use the same GUI distribution. It's independent of hosts and scenes. User has their own workspace locally. The workspace is secret. You can install extensions to enhance your workspace. Any device with a modern browser can access the GUI and its features. But currently, the layout on the desktop is the most friendly. We will enhance the experience of mobile in the future.

Documents

@yuants/docs is the document of Yuan.

It's built by Docusaurus. You can find the latest documents here.

Toolkit

@yuants/tool-kit is all you need. This provides a CLI when you need to build an extension. It helps you to build a docker image, create a bundle and more. To ensure your extension is ready to use.

Vendors

Vendors include markets, exchanges, and data sources. You can access the global market through various vendors. For some legal reason, they are probably not open to everyone. But you can use them if you gain permission from the provider.

Every vendor is a gateway to connect the external service directly. Your private data including account info and market data will not be stored in Yuan Cloud Service. You can deploy the vendor in your own cloud or local machine.

  • @yuants/vendor-ctp This connects to the "Comprehensive Transaction Platform" (CTP). The CTP platform was developed by the Shanghai Futures Exchange (SHFE). CTP provides China's future exchanges. To comply with regulations, you might have to request permission from your broker company.

  • @yuants/vendor-ccxt This connects to the "CryptoCurrency eXchange Trading Library" (CCXT). CCXT is a JavaScript / Python / PHP cryptocurrency trading library that supports many cryptocurrency exchanges and trading markets. You can use it to trade cryptocurrencies.

  • @yuants/vendor-binance This connects to Binance, which is a famous crypto exchange.

  • @yuants/vendor-okx This connects to OKX, which is a famous crypto exchange.

  • @yuants/vendor-huobi This connects to Huobi, which is a famous crypto exchange.

  • @yuants/vendor-gate This connects to Gate, which is a famous crypto exchange.

  • @yuants/vendor-bitget This connects to BitGet, which is a famous crypto exchange.

  • @yuants/vendor-coinex This connects to CoinEX, which is a famous crypto exchange.

(back to top)

Contributing

Contributions make the open-source community a fantastic place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open a feature request issue. Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contributors

Thanks sincerely to the contributors:

Zheng Chen
Zheng Chen

🧑‍🏫 💻 🎨 👀
Siyuan Wang
Siyuan Wang

💻 🚇
Jinhaolin
Jinhaolin

💻
Hobo Chen
Hobo Chen

🐛
Yalun Lin Hsu
Yalun Lin Hsu

💻
SakurazukaKen
SakurazukaKen

💻
Haoran Ren
Haoran Ren

💻
pruderior
pruderior

💻
playground
playground

💻

(back to top)

Contact

  • Join Discord server: Discord

(back to top)

Acknowledgments 📖

  1. Yuan-Public-Workspace You can learn how to write strategy models from this repository. You can import it to your workspace from the GUI. The repository is embedded in AI with a vector database. Contribute with your examples is greatly appreciated!
  2. Yuan-Public-Data Our public data is maintained here as a repository. Free to use. Welcome to contribute if you have other data!

(back to top)

Star History

Star History Chart

(back to top)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.