shanji 3 years ago
parent
commit
258d41aca4
  1. 25
      ReplacePineScript/ReplacePineScript.sln
  2. 13
      ReplacePineScript/ReplacePineScript/CodeTemplate.txt
  3. 5
      ReplacePineScript/ReplacePineScript/CodeTemplate2.txt
  4. 76
      ReplacePineScript/ReplacePineScript/Program.cs
  5. 34
      ReplacePineScript/ReplacePineScript/ReplacePineScript.csproj
  6. 2
      ReplacePineScript/ReplacePineScript/Symbol.txt
  7. 1
      ReplacePineScript/ReplacePineScript/exchangeInfo.json
  8. 6
      SDKTestConsole/Program.cs

25
ReplacePineScript/ReplacePineScript.sln

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReplacePineScript", "ReplacePineScript\ReplacePineScript.csproj", "{F05BA3D7-F0B2-4F13-B991-D90A9FDF47BD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F05BA3D7-F0B2-4F13-B991-D90A9FDF47BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F05BA3D7-F0B2-4F13-B991-D90A9FDF47BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F05BA3D7-F0B2-4F13-B991-D90A9FDF47BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F05BA3D7-F0B2-4F13-B991-D90A9FDF47BD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {793BF4CE-89F5-4785-B2FF-308629C6BC0D}
EndGlobalSection
EndGlobal

13
ReplacePineScript/ReplacePineScript/CodeTemplate.txt

@ -0,0 +1,13 @@
//@version=4
study(title="币安U合约ATR%", overlay=false)
source = close
length = input(1, minval=1, title="EMA Length")
atrlen = input(10, minval=1, title="ATR Length")
ma = ema(source, length)
range = tr
rangema = ema(range, atrlen)
atrp = rangema / ma * 100
avg = ema(atrp, 30)
//plot(atrp, color=black)
plot(avg,title="本币" ,color=color.maroon)

5
ReplacePineScript/ReplacePineScript/CodeTemplate2.txt

@ -0,0 +1,5 @@
#Symbol_sig = security("BINANCE:#SymbolUSDTPERP", timeframe.period,ema(tr, atrlen)/ ema(close, length)* 100)
#s = ema(#Symbol_sig, 30)
plot(#s, title="#Symbol", style=plot.style_line, color=#color)
var label #Symbol = label.new(x=bar_index, y=0.0, text='#Symbol', xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#color, size=size.small, textalign=text.align_left)
label.set_xy(id=#Symbol, x=bar_index, y=#s)

76
ReplacePineScript/ReplacePineScript/Program.cs

@ -0,0 +1,76 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using io = System.IO;
namespace ReplacePineScript
{
internal class Program
{
static void Main(string[] args)
{
//Console.WriteLine(GetRandomColor());
var applicationPath = io.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var codeTemplate = io.File.ReadAllText(io.Path.Combine(applicationPath, "CodeTemplate.txt"));
var codeTemplate2 = io.File.ReadAllText(io.Path.Combine(applicationPath, "CodeTemplate2.txt"));
var stringBuilder = new StringBuilder(codeTemplate);
stringBuilder.AppendLine();
stringBuilder.AppendLine();
var symbolArray = io.File.ReadAllLines(io.Path.Combine(applicationPath, "Symbol.txt")).Select(x => x.Replace("USDT", string.Empty)).ToList();
var perBatchCount = 40;
var fileCount = (symbolArray.Count() - 1) / perBatchCount + 1;
for (var i = 0; i < fileCount; i++)
{
var currentSymbolArray = symbolArray.Skip(i * perBatchCount).Take(perBatchCount).ToList();
for (var j = 0; j < currentSymbolArray.Count(); j++)
{
stringBuilder.Append(codeTemplate2.Replace("#Symbol", currentSymbolArray[j])
.Replace("#s", $"s{j + 1}")
.Replace("#color", GetRandomColor()));
stringBuilder.AppendLine();
stringBuilder.AppendLine();
}
io.File.WriteAllText(io.Path.Combine(applicationPath, $"Result{i + 1}.txt"), stringBuilder.ToString(), Encoding.UTF8);
}
Console.WriteLine("生成完毕");
Console.ReadKey();
}
public static string GetRandomColor()
{
Random RandomNum_First = new Random((int)DateTime.Now.Ticks);
// 对于C#的随机数,没什么好说的
System.Threading.Thread.Sleep(RandomNum_First.Next(50));
Random RandomNum_Sencond = new Random((int)DateTime.Now.Ticks);
// 为了在白色背景上显示,尽量生成深色
int int_Red = RandomNum_First.Next(256);
int int_Green = RandomNum_Sencond.Next(256);
int int_Blue = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
int_Blue = (int_Blue > 255) ? 255 : int_Blue;
Color color = Color.FromArgb(int_Red, int_Green, int_Blue);
string strColor = "#" + Convert.ToString(color.ToArgb(), 16).PadLeft(8, '0').Substring(2, 6);
return strColor;
}
}
}

34
ReplacePineScript/ReplacePineScript/ReplacePineScript.csproj

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="CodeTemplate.txt" />
<None Remove="CodeTemplate2.txt" />
<None Remove="exchangeInfo.json" />
<None Remove="Symbol.txt" />
</ItemGroup>
<ItemGroup>
<Content Include="CodeTemplate2.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="CodeTemplate.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="exchangeInfo.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Symbol.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>

2
ReplacePineScript/ReplacePineScript/Symbol.txt

@ -0,0 +1,2 @@
BTC
ETH

1
ReplacePineScript/ReplacePineScript/exchangeInfo.json

File diff suppressed because one or more lines are too long

6
SDKTestConsole/Program.cs

@ -40,6 +40,12 @@ namespace SDKTestConsole
var binanceSocketClient = new BinanceSocketClient(); var binanceSocketClient = new BinanceSocketClient();
var r = client.GetIsolatedMarginAccountAssets();
//25.07786941
var i = client.IsolatedMarginRepay("GMTUSDT", 0.00009176M);
Console.ReadKey(); Console.ReadKey();
} }
} }

Loading…
Cancel
Save