Skip to content

Commit

Permalink
Docs updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikasoukhov committed Apr 22, 2024
1 parent d2a499a commit b5f151e
Show file tree
Hide file tree
Showing 63 changed files with 1,622 additions and 2,548 deletions.
16 changes: 8 additions & 8 deletions API/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# StockSharp API Examples Directory

This directory contains a collection of example projects and scripts demonstrating the use of the StockSharp API for developing trading applications. These examples are intended specifically for developers who are programming in C# and are looking to create comprehensive trading robots or tools that do not integrate directly with the Designer platform.
This directory contains a collection of example projects and scripts demonstrating the use of the [StockSharp API](https://doc.stocksharp.com/topics/api.html) for developing trading applications. These examples are intended specifically for developers who are programming in C# and are looking to create comprehensive trading robots or tools that do not integrate directly with the Designer platform.

## Overview

The examples provided in this folder serve as practical guides to various aspects of the StockSharp API, showcasing how to leverage its capabilities to access market data, execute trades, and manage portfolios. These examples are particularly useful for users with a background in software development and an interest in financial markets.
The examples provided in this folder serve as practical guides to various aspects of the [StockSharp API](https://doc.stocksharp.com/topics/api.html), showcasing how to leverage its capabilities to access market data, execute trades, and manage portfolios. These examples are particularly useful for users with a background in software development and an interest in financial markets.

## Contents

- **Basic API Usage**: Simple scripts demonstrating the initialization of the API, connection to trading services, and basic data handling.
- **Advanced Trading Algorithms**: More complex examples that implement full trading strategies or algorithms using the StockSharp API.
- **Data Management**: Scripts that show how to fetch, store, and manage historical market data for analysis.
- **Utility Tools**: Utility programs that assist with account management, order placement, and other trading operations.
- **Basic API Usage**: Simple scripts demonstrating the initialization of the API, [connection to trading services](https://doc.stocksharp.com/topics/api/connectors.html), and basic data handling.
- **Advanced Trading Algorithms**: More complex examples that implement full [trading strategies](https://doc.stocksharp.com/topics/api/strategies.html) or algorithms using the StockSharp API.
- **Data Management**: Scripts that show how to fetch, store, and manage historical [market data](https://doc.stocksharp.com/topics/api/market_data_storage.html) for analysis.
- **Utility Tools**: Utility programs that assist with account management, [order placement](https://doc.stocksharp.com/topics/api/orders_management.html), and other trading operations.

## Purpose

Expand All @@ -26,6 +26,6 @@ Each example comes with a detailed explanation of the code and instructions on h

## Important Note

Please note that the examples provided in this folder are not compatible with the Designer platform. They are intended for direct use and modification within C# projects and require a solid understanding of programming concepts and the .NET framework.
Please note that the examples provided in this folder are not compatible with the Designer platform. They are intended for direct use and modification within C# projects and require a solid understanding of programming concepts and the .NET. Additionally, some examples may require adding a connector from StockSharp's private NuGet server. For more information on accessing and using this server, please visit [StockSharp's NuGet server manual](https://stocksharp.com/products/nuget_manual/#privateserver).

By exploring and utilizing these examples, developers can gain a deeper understanding of how to implement robust trading solutions using the StockSharp API, paving the way for the development of sophisticated trading robots and analytical tools.
By exploring and utilizing these examples, developers can gain a deeper understanding of how to implement robust trading solutions using the StockSharp API, paving the way for the development of sophisticated trading robots and analytical tools.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ This repository contains a .NET application using the StockSharp trading framewo

## Getting Started

### Prerequisites

Ensure you have the following installed:
- .NET 6
- StockSharp library (available via NuGet)

### Installation

1. Clone the repository.
Expand Down
17 changes: 12 additions & 5 deletions API/lesson_01(simple_terminal)/02_MarketDepths_Trades/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ This guide explains how to handle market data using the StockSharp trading frame

## Key Components

1. **Market Depths**: Market depth data represents the bids and offers at various price levels for a particular security.
2. **Trades**: Real-time trade data shows actual trades that have occurred.
1. **Market Depths**: [Market depth](https://doc.stocksharp.com/topics/api/order_books.html) data represents the bids and offers at various price levels for a particular security.
2. **Trades**: [Real-time](https://doc.stocksharp.com/topics/api/market_data/subscriptions.html) trade data shows actual trades that have occurred.

## Setup and Event Handlers

### Installation

1. Clone the repository.
2. Open the solution in Visual Studio.
3. Find and add required connector via [NuGet package](https://stocksharp.com/products/nuget_manual/#privateserver)
4. Build and run the application.

### Initialize and Connect

First, the application initializes the connector and sets up event handlers for receiving market data:
Expand Down Expand Up @@ -40,7 +47,7 @@ private void Connect_Click(object sender, RoutedEventArgs e)

### Handling Market Depth Data

When the market depth data is received, the application updates the UI component showing the market depth:
When the market depth data is received, the application updates the [UI component](https://doc.stocksharp.com/topics/api/graphical_user_interface/market_data/order_book.html) showing the market depth:

```csharp
private void ConnectorOnMarketDepthReceived(Subscription sub, IOrderBookMessage depth)
Expand All @@ -52,7 +59,7 @@ private void ConnectorOnMarketDepthReceived(Subscription sub, IOrderBookMessage

### Handling Trade Data

When trade data is received, it is added to a grid that displays trades:
When trade data is received, it is added to a [grid](https://doc.stocksharp.com/topics/api/graphical_user_interface/market_data/ticks.html) that displays trades:

```csharp
private void ConnectorOnTickTradeReceived(Subscription sub, ITickTradeMessage trade)
Expand All @@ -64,7 +71,7 @@ private void ConnectorOnTickTradeReceived(Subscription sub, ITickTradeMessage tr

## Subscribing to Market Data

When a security is selected, the application subscribes to level 1 data, trades, and market depth for that security:
When a security is selected, the application [subscribes](https://doc.stocksharp.com/topics/api/market_data/subscriptions.html) to level 1 data, trades, and market depth for that security:

```csharp
private void SecurityPicker_SecuritySelected(Security security)
Expand Down
19 changes: 13 additions & 6 deletions API/lesson_01(simple_terminal)/03_Work_with_orders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ This section of the documentation explains how to manage orders in a .NET applic

## Key Components

1. **Order Handling**: Submitting buy and sell orders.
1. **Order Handling**: Submitting buy and sell [orders](https://doc.stocksharp.com/topics/api/orders_management.html).
2. **UI Components**: `SecurityEditor` and `PortfolioEditor` for selecting securities and portfolios.
3. **Order Feedback**: Handling responses for new orders and failed orders.
3. **Order Feedback**: Handling responses for [new orders and failed orders](https://doc.stocksharp.com/topics/api/orders_management/orders_states.html).

## Code Explanation and Usage

### Installation

1. Clone the repository.
2. Open the solution in Visual Studio.
3. Find and add required connector via [NuGet package](https://stocksharp.com/products/nuget_manual/#privateserver)
4. Build and run the application.

### Initialization and Connection Setup

The constructor initializes the application and loads existing settings. The `Connect_Click` method sets up necessary bindings and event handlers for order operations:
The constructor initializes the application and [loads existing settings](https://doc.stocksharp.com/topics/api/connectors/save_and_load_settings.html). The `Connect_Click` method sets up necessary bindings and event handlers for order operations:

```csharp
public MainWindow()
Expand All @@ -41,7 +48,7 @@ private void Connect_Click(object sender, RoutedEventArgs e)

### Submitting Orders

The application provides methods to submit buy and sell orders. These methods are triggered by UI events (e.g., button clicks) and use the selected security and portfolio details to create and register orders with the trading service:
The application provides methods to submit buy and sell [orders](https://doc.stocksharp.com/topics/api/orders_management.html). These methods are triggered by UI events (e.g., button clicks) and use the selected security and portfolio details to create and register orders with the trading service:

```csharp
private void Buy_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -75,7 +82,7 @@ private void Sell_Click(object sender, RoutedEventArgs e)

## Handling Order Responses

The application listens for new orders and failed order registration events to update the UI appropriately:
The application listens for new orders and failed order registration events to update the [UI](https://doc.stocksharp.com/topics/api/graphical_user_interface/trading/orders.html) appropriately:

```csharp
_connector.NewOrder += OrderGrid.Orders.Add;
Expand All @@ -84,6 +91,6 @@ _connector.OrderRegisterFailed += OrderGrid.AddRegistrationFail;

## Conclusion

This setup allows users to interactively manage trading orders through a UI, offering capabilities to buy and sell securities using configured trading services. This guide should help users understand the order handling process within the application and provide clear instructions on how to extend or modify this functionality.
This setup allows users to interactively manage trading orders [through a UI](https://doc.stocksharp.com/topics/api/graphical_user_interface/trading/orders.html), offering capabilities to buy and sell securities using configured trading services. This guide should help users understand the order handling process within the application and provide clear instructions on how to extend or modify this functionality.

Feel free to adjust the snippets and explanations to better fit the actual implementation details or specific configurations in your project.
15 changes: 11 additions & 4 deletions API/lesson_02(candles)/01_Getting_realtime_candles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ This documentation section explains how to handle and visualize real-time candle

## Key Components

1. **Candle Series Setup**: Configuration of candle data types and subscription settings.
2. **Real-Time Data Subscription**: Subscribing to candle data and handling incoming data updates.
3. **Data Visualization**: Integrating with charting components to visualize the data.
1. **Candle Series Setup**: Configuration of [candle data](https://doc.stocksharp.com/topics/api/candles.html) types and subscription settings.
2. **Real-Time Data Subscription**: [Subscribing](https://doc.stocksharp.com/topics/api/market_data/subscriptions.html) to candle data and handling incoming data updates.
3. **Data Visualization**: Integrating with [charting components](https://doc.stocksharp.com/topics/api/graphical_user_interface/charts.html) to visualize the data.

## Code Explanation and Usage

### Installation

1. Clone the repository.
2. Open the solution in Visual Studio.
3. Find and add required connector via [NuGet package](https://stocksharp.com/products/nuget_manual/#privateserver)
4. Build and run the application.

### Initialization and Configuration

The constructor initializes components and sets default settings for candle data types:
Expand Down Expand Up @@ -60,7 +67,7 @@ private void SecurityPicker_SecuritySelected(Security security)

### Handling Candle Data

Implementing an event handler for processing received candle data and updating the chart:
Implementing an event handler for processing received candle data and [updating the chart](https://doc.stocksharp.com/topics/api/candles/chart.html):

```csharp
private void Connector_CandleSeriesProcessing(CandleSeries series, Candle candle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ This section of the documentation outlines how to manage and visualize both hist

## Key Components

1. **Data Storage**: Utilizes CSV storage for historical data and local market data drives.
2. **Real-Time Subscription**: Subscribing to real-time candle data and merging it with historical data.
3. **Charting**: Visualization of both historical and real-time data on a chart.
1. **Data Storage**: Utilizes CSV [storage](https://doc.stocksharp.com/topics/api/market_data_storage.html) for historical data and local market [data drives](https://doc.stocksharp.com/topics/api/market_data_storage/api.html).
2. **Real-Time Subscription**: Subscribing to [real-time candle data](https://doc.stocksharp.com/topics/api/candles.html) and [merging it with historical data](https://doc.stocksharp.com/topics/api/candles/gluing_candles_history_real_time.html).
3. **Charting**: Visualization of both historical and real-time data on a [chart](https://doc.stocksharp.com/topics/api/graphical_user_interface.html).

## Code Explanation and Usage

### Installation

1. Clone the repository.
2. Open the solution in Visual Studio.
3. Find and add required connector via [NuGet package](https://stocksharp.com/products/nuget_manual/#privateserver)
4. Build and run the application.

### Initialization and Configuration

The constructor sets up data storage, initializes components, and configures default settings for candle data types:
Expand Down Expand Up @@ -57,7 +64,7 @@ private void Connector_CandleSeriesProcessing(CandleSeries candleSeries, ICandle

### Selecting Security and Subscribing to Data

When a security is selected, the application subscribes to both historical and real-time candle data, setting up the charting components accordingly:
When a security is selected, the application [subscribes](https://doc.stocksharp.com/topics/api/market_data/subscriptions.html) to both historical and real-time candle data, setting up the charting components accordingly:

```csharp
private void SecurityPicker_SecuritySelected(Security security)
Expand Down
10 changes: 5 additions & 5 deletions API/lesson_03(historical_data)/01_LocalStorage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

This program is designed to load and display various types of market data using the StockSharp framework, interacting with a local market data drive. It handles securities, candles, trades, market depths, level1 messages, and an expression-based index.
This program is designed to load and display various types of market data using the StockSharp framework, interacting with a [local market data drive](https://doc.stocksharp.com/topics/api/market_data_storage.html). It handles securities, candles, trades, market depths, level1 messages, and an expression-based index.

## Detailed Code Explanation

Expand All @@ -24,7 +24,7 @@ foreach (var sec in securities)
}
Console.ReadLine();
```
Here, the program lists all securities stored in the local drive and outputs each to the console.
Here, the program lists all [securities](https://doc.stocksharp.com/topics/api/instruments.html) stored in the local drive and outputs each to the console.

### Loading and Displaying Candle Data

Expand All @@ -38,7 +38,7 @@ foreach (var candle in candles)
}
Console.ReadLine();
```
This code loads candle data for the security `SBER@TQBR` using a one-minute timeframe, from April 1, 2020, to April 2, 2020. Each candle is then printed to the console.
This code loads [candle data](https://doc.stocksharp.com/topics/api/candles.html) for the security `SBER@TQBR` using a one-minute timeframe, from April 1, 2020, to April 2, 2020. Each candle is then printed to the console.

### Loading and Displaying Trade Data

Expand All @@ -64,7 +64,7 @@ foreach (var marketDepth in marketDepths)
}
Console.ReadLine();
```
This part of the program loads and displays market depth data, showing bid and ask prices and quantities.
This part of the program loads and displays [market depth](https://doc.stocksharp.com/topics/api/order_books.html) data, showing bid and ask prices and quantities.

### Loading and Displaying Level1 Messages

Expand All @@ -90,7 +90,7 @@ var basketSecurity = new ExpressionIndexSecurity
BasketExpression = "SBER@TQBR + 987654321",
};
```
This configures an expression-based index which is calculated using the specified formula. This demonstrates how to extend the application to handle composite securities based on expressions.
This configures an [expression-based index](https://doc.stocksharp.com/topics/api/instruments/index.html) which is calculated using the specified formula. This demonstrates how to extend the application to handle composite securities based on expressions.

### Calculating and Displaying Index Candles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ private void Start_Click(object sender, RoutedEventArgs e)
_connector.NewOrder += OrderGrid.Orders.Add;
_connector.OrderRegisterFailed += OrderGrid.AddRegistrationFail;

// uncomment required strategy
_strategy = new OneCandleCountertrend(_candleSeries)
//_strategy = new OneCandleTrend(_candleSeries)
//_strategy = new StairsCountertrend(_candleSeries)
//_strategy = new StairsTrend(_candleSeries)
//
// !!! IMPORTANT !!!
// Uncomment the desired strategy
//
_strategy = new OneCandleCountertrendStrategy(_candleSeries)
//_strategy = new OneCandleTrendStrategy(_candleSeries)
//_strategy = new StairsCountertrendStrategy(_candleSeries)
//_strategy = new StairsTrendStrategy(_candleSeries)
{
Security = _security,
Connector = _connector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

namespace First_strategies
{
public class OneCandleCountertrend : Strategy
public class OneCandleCountertrendStrategy : Strategy
{
private readonly CandleSeries _candleSeries;
private Subscription _subscription;

public OneCandleCountertrend(CandleSeries candleSeries)
public OneCandleCountertrendStrategy(CandleSeries candleSeries)
{
_candleSeries = candleSeries;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This strategy aims to take advantage of small reversals or "countertrend" moves
The strategy is initialized with a `CandleSeries`, which specifies the security and timeframe for the candle data it will process.

```csharp
public OneCandleCountertrend(CandleSeries candleSeries)
public OneCandleCountertrendStrategy(CandleSeries candleSeries)
{
_candleSeries = candleSeries;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

namespace First_strategies
{
public class OneCandleTrend : Strategy
public class OneCandleTrendStrategy : Strategy
{
private readonly CandleSeries _candleSeries;
private Subscription _subscription;

public OneCandleTrend(CandleSeries candleSeries)
public OneCandleTrendStrategy(CandleSeries candleSeries)
{
_candleSeries = candleSeries;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This strategy is designed to capitalize on the momentum within each trading cand
The constructor initializes the strategy with a specific `CandleSeries`, which defines the security and the timeframe for which the strategy should receive and process candle data.

```csharp
public OneCandleTrend(CandleSeries candleSeries)
public OneCandleTrendStrategy(CandleSeries candleSeries)
{
_candleSeries = candleSeries;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ private void Start_Click(object sender, RoutedEventArgs e)
_connector = new HistoryEmulationConnector(new[] { _security }, new[] { _portfolio }) { ... };
_logManager.Sources.Add(_connector);

// Initialize and select strategy
_strategy = new OneCandleCountertrend(_candleSeries); // Uncomment the desired strategy
//_strategy = new OneCandleTrend(_candleSeries);
//_strategy = new StairsCountertrend(_candleSeries);
//_strategy = new StairsTrend(_candleSeries);
//
// !!! IMPORTANT !!!
// Uncomment the desired strategy
//
_strategy = new OneCandleCountertrendStrategy(_candleSeries);
//_strategy = new OneCandleTrendStrategy(_candleSeries);
//_strategy = new StairsCountertrendStrategy(_candleSeries);
//_strategy = new StairsTrendStrategy(_candleSeries);
_logManager.Sources.Add(_strategy);
_connector.Connected += Connector_Connected;
Expand Down
Loading

0 comments on commit b5f151e

Please sign in to comment.